code: def Run(script, container=None, exit_on_error=False, gas=Fixed8.Zero(), test_mode=True):
          
  
          from neo.Core.Blockchain import Blockchain
          from neo.SmartContract.StateMachine import StateMachine
          from neo.EventHub import events
  
          bc = Blockchain.Default()
  
          accounts = DBCollection(bc._db, DBPrefix.ST_Account, AccountState)
          assets = DBCollection(bc._db, DBPrefix.ST_Asset, AssetState)
          validators = DBCollection(bc._db, DBPrefix.ST_Validator, ValidatorState)
          contracts = DBCollection(bc._db, DBPrefix.ST_Contract, ContractState)
          storages = DBCollection(bc._db, DBPrefix.ST_Storage, StorageItem)
  
          script_table = CachedScriptTable(contracts)
          service = StateMachine(accounts, validators, assets, contracts, storages, None)
  
          engine = ApplicationEngine(
              trigger_type=TriggerType.Application,
              container=container,
              table=script_table,
              service=service,
              gas=gas,
              testMode=test_mode,
              exit_on_error=exit_on_error
          )
  
          script = binascii.unhexlify(script)
  
          engine.LoadScript(script)
  
          try:
              success = engine.Execute()
              engine.testMode = True
              service.ExecutionCompleted(engine, success)
          except Exception as e:
              engine.testMode = True
              service.ExecutionCompleted(engine, False, e)
  
          for event in service.events_to_dispatch:
              events.emit(event.event_type, event)
  
          return engine
docs: Runs a script in a test invoke environment
  
          Args:
              script (bytes): The script to run
              container (neo.Core.TX.Transaction): [optional] the transaction to use as the script container
  
          Returns:
              ApplicationEngine