public void TestByteArrayInequalityFalse() { byte[] program = ExecutionHelper.Compile("HubContract"); var engine = new ExecutionEngine(null, Crypto.Default); engine.LoadScript(program); using (ScriptBuilder sb = new ScriptBuilder()) { sb.EmitPush(0); // arg3 sb.EmitPush(new byte[] { }); // arg2 sb.EmitPush(new byte[] { 1, 2, 3, 4, 5 }); // arg1 sb.EmitPush(new byte[] { 1, 2, 3, 4, 5 }); // arg0 sb.EmitPush("test_sanity_bytearrayneq"); // operation engine.LoadScript(sb.ToArray()); } engine.Execute(); Assert.False(engine.State == VMState.FAULT, "FAULT"); bool result = engine.EvaluationStack.Peek().GetBoolean(); Assert.False(result); }
public void TestMethod1() { byte[] program = ExecutionHelper.Compile("HubContract"); var engine = new ExecutionEngine(null, Crypto.Default); engine.LoadScript(program); using (ScriptBuilder sb = new ScriptBuilder()) { sb.EmitPush(0); // arg3 sb.EmitPush(new byte[] { }); // arg2 sb.EmitPush(new byte[] { }); // arg1 sb.EmitPush(SCRIPT_HASH); // arg0 sb.EmitPush("test_hash160reverse"); // operation engine.LoadScript(sb.ToArray()); } engine.Execute(); Assert.False(engine.State == VMState.FAULT, "FAULT"); byte[] result = engine.EvaluationStack.Peek().GetByteArray(); byte[] reversedScriptHash = (byte[])SCRIPT_HASH.Clone(); Array.Reverse(reversedScriptHash); Assert.Equal(reversedScriptHash, result); }
protected ExecutionEngine LoadContract(string contractName) { byte[] program = ExecutionHelper.Compile(contractName); var engine = new ExecutionEngine(null, Crypto.Default, null, InteropService); engine.LoadScript(program); return(engine); }
public void HelloWorld() { byte[] program = ExecutionHelper.Compile(nameof(HelloWorld)); using (ExecutionEngine ee = new ExecutionEngine(null, Crypto.Default, null, null)) { ee.LoadScript(program); ee.Execute(); } }
public void Calculator() { byte[] program = ExecutionHelper.Compile(nameof(Calculator)); using (ScriptBuilder sb = new ScriptBuilder()) using (ExecutionEngine ee = new ExecutionEngine(null, Crypto.Default, null, null)) { ee.LoadScript(program); sb.EmitPush(5); sb.EmitPush(5); ee.LoadScript(sb.ToArray()); ee.Execute(); var result = ee.EvaluationStack.Peek().GetBigInteger(); // set the return value here Assert.Equal(result, 10); } }