private bool Rewrite(IContractModuleDefinition moduleDefinition, IILRewriter rewriter) { try { moduleDefinition.Rewrite(rewriter); return(true); } catch (Exception e) { this.logger.LogError("Exception occurred: {0}", e.ToString()); this.logger.LogTrace("(-)[CONTRACT_REWRITE_FAILED]"); } return(false); }
public ObserverInstanceRewriterTests() { var context = new ContractExecutorTestContext(); this.TestAddress = "0x0000000000000000000000000000000000000001".HexToAddress(); this.repository = context.State; this.moduleReader = new ContractModuleDefinitionReader(); this.assemblyLoader = new ContractAssemblyLoader(); this.gasMeter = new GasMeter((Gas)5000000); var block = new TestBlock { Coinbase = this.TestAddress, Number = 1 }; var message = new TestMessage { ContractAddress = this.TestAddress, Sender = this.TestAddress, Value = Value }; var getBalance = new Func <ulong>(() => Balance); var persistentState = new TestPersistentState(); var network = new SmartContractsRegTest(); var serializer = new ContractPrimitiveSerializerV2(network); this.state = new SmartContractState( new Block(1, this.TestAddress), new Message(this.TestAddress, this.TestAddress, 0), new PersistentState(new MeteredPersistenceStrategy(this.repository, this.gasMeter, new BasicKeyEncodingStrategy()), context.Serializer, this.TestAddress.ToUint160()), context.Serializer, new ContractLogHolder(), Mock.Of <IInternalTransactionExecutor>(), new InternalHashHelper(), () => 1000); this.rewriter = new ObserverInstanceRewriter(); }
/// <inheritdoc /> public void Rewrite(IILRewriter rewriter) { this.ModuleDefinition = rewriter.Rewrite(this.ModuleDefinition); }