cli: add tests for Storage.Find invocations

It returns values of different types we better be sure that
compiler emits correct code.
This commit is contained in:
Evgeniy Stratonikov 2021-01-12 15:52:08 +03:00 committed by Roman Khimov
parent 9b1a7021ba
commit 50d515a3e5
2 changed files with 53 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"github.com/nspcc-dev/neo-go/cli/testdata/deploy/sub"
"github.com/nspcc-dev/neo-go/pkg/interop"
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
)
@ -46,3 +47,17 @@ func GetValue() string {
val2 := storage.Get(ctx, sub.Key)
return val1.(string) + "|" + val2.(string)
}
// TestFind finds items with the specified prefix.
func TestFind(f storage.FindFlags) []interface{} {
ctx := storage.GetContext()
storage.Put(ctx, "findkey1", "value1")
storage.Put(ctx, "findkey2", "value2")
var result []interface{}
iter := storage.Find(ctx, "findkey", f)
for iterator.Next(iter) {
result = append(result, iterator.Value(iter))
}
return result
}