2022-06-08 16:31:49 +00:00
|
|
|
package storage_test
|
2019-12-23 13:08:58 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
|
|
|
"testing"
|
|
|
|
|
2020-04-08 10:35:39 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
2022-06-08 16:31:49 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
|
2019-12-23 13:08:58 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUnexpectedNonInterops(t *testing.T) {
|
|
|
|
vals := map[string]interface{}{
|
|
|
|
"int": 1,
|
|
|
|
"bool": false,
|
|
|
|
"string": "smth",
|
|
|
|
"array": []int{1, 2, 3},
|
|
|
|
}
|
|
|
|
|
|
|
|
// All of these functions expect an interop item on the stack.
|
2020-08-07 11:37:49 +00:00
|
|
|
funcs := []func(*interop.Context) error{
|
2022-06-08 16:31:49 +00:00
|
|
|
storage.ContextAsReadOnly,
|
|
|
|
storage.Delete,
|
|
|
|
storage.Find,
|
|
|
|
storage.Get,
|
|
|
|
storage.Put,
|
2019-12-23 13:08:58 +00:00
|
|
|
}
|
|
|
|
for _, f := range funcs {
|
|
|
|
for k, v := range vals {
|
|
|
|
fname := runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name()
|
|
|
|
t.Run(k+"/"+fname, func(t *testing.T) {
|
2022-06-08 16:31:49 +00:00
|
|
|
vm, ic, _ := createVM(t)
|
|
|
|
vm.Estack().PushVal(v)
|
|
|
|
require.Error(t, f(ic))
|
2019-12-23 13:08:58 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|