diff --git a/covertest/run.go b/covertest/run.go index 173f13d..98dae12 100644 --- a/covertest/run.go +++ b/covertest/run.go @@ -9,7 +9,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" ) -// InstrHash maps Instruction with its Script Hash. +// InstrHash maps instruction with scripthash of a contract it belongs to. type InstrHash struct { Offset int Instruction opcode.Opcode @@ -17,9 +17,9 @@ type InstrHash struct { } // Run starts execution of the loaded program and accumulates all seen opcodes -// together with the scripthash they belong to. +// together with the scripthash of a contract they belong to. +// Original vm.Run(): https://github.com/nspcc-dev/neo-go/blob/v0.101.3/pkg/vm/vm.go#L418 func Run(v *vm.VM) ([]InstrHash, error) { - if !v.Ready() { return nil, errors.New("no program loaded") } diff --git a/tests/contract_test.go b/tests/contract_test.go index caa41d8..6f9dc8d 100644 --- a/tests/contract_test.go +++ b/tests/contract_test.go @@ -20,7 +20,7 @@ import ( const ctrPath = "../impulse" -// Key for tests +// keys for tests var ( validKey = []byte{1, 2, 3, 4, 5} invalidKey = []byte{1, 2, 3} @@ -63,22 +63,22 @@ func TestRun(t *testing.T) { someNum := getNumToPut() - // setting up a VM for covertest.Run() + // set up a VM for covertest.Run() covertestRunVM := setUpVMForPut(t, e, ctrDI.Contract, hasResult, startOffsetPutNumber, someNum, invalidKey) res, covErr := covertest.Run(covertestRunVM) t.Log("Printing collected instructions:") spew.Dump(res) t.Log("covertest.Run() returned an error: ", covErr) - // setting up a VM for vm.Run() + // set up a VM for vm.Run() origRunVM := setUpVMForPut(t, e, ctrDI.Contract, hasResult, startOffsetPutNumber, someNum, invalidKey) runerr := origRunVM.Run() t.Log("vm.Run() returned an error: ", covErr) - //check if errors are the same + // check if errors are the same require.Equal(t, runerr.Error(), covErr.Error()) - //check if the number of elements on the stack is the same + // check if the number of elements on the stack is the same require.Equal(t, origRunVM.Estack().Len(), covertestRunVM.Estack().Len()) }