diff --git a/FirstContract/tests/contract_test.go b/FirstContract/tests/contract_test.go index 9c1b007..8abd6fd 100644 --- a/FirstContract/tests/contract_test.go +++ b/FirstContract/tests/contract_test.go @@ -6,7 +6,6 @@ import ( "path" "testing" - "github.com/davecgh/go-spew/spew" _ "github.com/nspcc-dev/neo-go/pkg/compiler" "github.com/nspcc-dev/neo-go/pkg/neotest" "github.com/nspcc-dev/neo-go/pkg/neotest/chain" @@ -59,31 +58,23 @@ func TestContract_Add(t *testing.T) { e := newExecutor(t) ctrAdd := neotest.CompileFile(t, e.CommitteeHash, ctrPath, path.Join(ctrPath, "neo-go.yml")) e.DeployContract(t, ctrAdd, nil) - spew.Dump(ctrAdd.Manifest) + inv := e.CommitteeInvoker(ctrAdd.Hash) + inv.Invoke(t, 3, "add", 1, 2) govm := vm.New() govm.LoadNEFMethod(ctrAdd.NEF, ctrAdd.Hash, ctrAdd.Hash, callflag.All, true, 170, -1, nil) govm.Context().Estack().PushVal(1) - govm.Context().Estack().PushVal(3) - //fmt.Println(govm.Context().CurrInstr()) - _, curInstr := govm.Context().CurrInstr() - //while curInstr != RET do - for curInstr != 0x40 { - fmt.Println(curInstr) + govm.Context().Estack().PushVal(2) + + fmt.Println("\nPrinting opcodes:") + for !govm.HasStopped() { + nStr, curInstr := govm.Context().NextInstr() + fmt.Println(nStr, " ", curInstr) govm.Step() - _, curInstr = govm.Context().CurrInstr() } - fmt.Println(govm.Context().CurrInstr()) - //govm.DumpEStack() - //govm.Run() - res := govm.Context().Estack().Pop().Value() - fmt.Println(res) - - // manif, _ := json.MarshalIndent(ctrAdd.Manifest, "", " ") - // fmt.Println(string(manif)) - inv := e.CommitteeInvoker(ctrAdd.Hash) - inv.Invoke(t, 3, "add", 1, 2) + res := govm.Estack().Pop().Value() + fmt.Println("\nresult = ", res) } func Test(t *testing.T) { @@ -94,13 +85,10 @@ func Test(t *testing.T) { t.FailNow() } govm.PrintOps(os.Stdout) - //step in a loop for debug - // govm.Context().Jump(170) govm.Context().Estack().PushVal(1) govm.Context().Estack().PushVal(2) - govm.Run() - res := govm.Context().Estack().Pop().Value() + res := govm.Estack().Pop().Value() fmt.Println(res) }