[#2] Fix comments

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
master
Ekaterina Lebedeva 2023-08-07 11:56:12 +03:00
parent 9e3ac59aa8
commit 401d54dda4
2 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate" "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 { type InstrHash struct {
Offset int Offset int
Instruction opcode.Opcode Instruction opcode.Opcode
@ -17,9 +17,9 @@ type InstrHash struct {
} }
// Run starts execution of the loaded program and accumulates all seen opcodes // 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) { func Run(v *vm.VM) ([]InstrHash, error) {
if !v.Ready() { if !v.Ready() {
return nil, errors.New("no program loaded") return nil, errors.New("no program loaded")
} }

View File

@ -20,7 +20,7 @@ import (
const ctrPath = "../impulse" const ctrPath = "../impulse"
// Key for tests // keys for tests
var ( var (
validKey = []byte{1, 2, 3, 4, 5} validKey = []byte{1, 2, 3, 4, 5}
invalidKey = []byte{1, 2, 3} invalidKey = []byte{1, 2, 3}
@ -63,22 +63,22 @@ func TestRun(t *testing.T) {
someNum := getNumToPut() 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) covertestRunVM := setUpVMForPut(t, e, ctrDI.Contract, hasResult, startOffsetPutNumber, someNum, invalidKey)
res, covErr := covertest.Run(covertestRunVM) res, covErr := covertest.Run(covertestRunVM)
t.Log("Printing collected instructions:") t.Log("Printing collected instructions:")
spew.Dump(res) spew.Dump(res)
t.Log("covertest.Run() returned an error: ", covErr) 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) origRunVM := setUpVMForPut(t, e, ctrDI.Contract, hasResult, startOffsetPutNumber, someNum, invalidKey)
runerr := origRunVM.Run() runerr := origRunVM.Run()
t.Log("vm.Run() returned an error: ", covErr) 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()) 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()) require.Equal(t, origRunVM.Estack().Len(), covertestRunVM.Estack().Len())
} }