vm: move InteropNameToID to a separate package
This commit is contained in:
parent
9cc6e22365
commit
f3650e20b0
14 changed files with 60 additions and 52 deletions
|
@ -6,8 +6,8 @@ import (
|
|||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -56,7 +56,7 @@ func getPanicSource(need bool, message string) string {
|
|||
}
|
||||
|
||||
func getLogHandler(logs *[]string) vm.SyscallHandler {
|
||||
logID := emit.InteropNameToID([]byte("System.Runtime.Log"))
|
||||
logID := interopnames.ToID([]byte("System.Runtime.Log"))
|
||||
return func(v *vm.VM, id uint32) error {
|
||||
if id != logID {
|
||||
return errors.New("syscall not found")
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -19,7 +19,7 @@ func TestVerifyGood(t *testing.T) {
|
|||
src := getVerifyProg(pub, sig, msg)
|
||||
|
||||
v, p := vmAndCompileInterop(t, src)
|
||||
p.interops[emit.InteropNameToID([]byte("Neo.Crypto.VerifyWithECDsaSecp256r1"))] = func(v *vm.VM) error {
|
||||
p.interops[interopnames.ToID([]byte("Neo.Crypto.VerifyWithECDsaSecp256r1"))] = func(v *vm.VM) error {
|
||||
assert.Equal(t, msg, v.Estack().Pop().Bytes())
|
||||
assert.Equal(t, pub, v.Estack().Pop().Bytes())
|
||||
assert.Equal(t, sig, v.Estack().Pop().Bytes())
|
||||
|
|
|
@ -7,11 +7,11 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/compiler"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -109,10 +109,10 @@ func newStoragePlugin() *storagePlugin {
|
|||
mem: make(map[string][]byte),
|
||||
interops: make(map[uint32]func(v *vm.VM) error),
|
||||
}
|
||||
s.interops[emit.InteropNameToID([]byte("System.Storage.Get"))] = s.Get
|
||||
s.interops[emit.InteropNameToID([]byte("System.Storage.Put"))] = s.Put
|
||||
s.interops[emit.InteropNameToID([]byte("System.Storage.GetContext"))] = s.GetContext
|
||||
s.interops[emit.InteropNameToID([]byte("System.Runtime.Notify"))] = s.Notify
|
||||
s.interops[interopnames.ToID([]byte("System.Storage.Get"))] = s.Get
|
||||
s.interops[interopnames.ToID([]byte("System.Storage.Put"))] = s.Put
|
||||
s.interops[interopnames.ToID([]byte("System.Storage.GetContext"))] = s.GetContext
|
||||
s.interops[interopnames.ToID([]byte("System.Runtime.Notify"))] = s.Notify
|
||||
return s
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue