[#51] policy: Fix tests
All checks were successful
DCO action / DCO (pull_request) Successful in 1m11s
Tests / Tests (1.19) (pull_request) Successful in 1m30s
Tests / Tests (1.20) (pull_request) Successful in 1m31s

We don't want to return Null from contract when list is empty
because generated policy client cannot parse this.

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2023-11-17 15:02:13 +03:00
parent 5cc34f98e9
commit 20f86e96b2
2 changed files with 2 additions and 20 deletions

View file

@ -68,22 +68,10 @@ func RemoveChainsByPrefix(entity Kind, entityName string, name string) {
// ListChains lists all chains for the namespace by prefix.
// container may be empty.
func ListChains(namespace, container, name string) [][]byte {
ctx := storage.GetReadOnlyContext()
var result [][]byte
prefixNs := storageKey(Namespace, namespace, name)
it := storage.Find(ctx, prefixNs, storage.ValuesOnly)
for iterator.Next(it) {
result = append(result, iterator.Value(it).([]byte))
}
result := ListChainsByPrefix(Namespace, namespace, name)
if container != "" {
prefixCnr := storageKey(Container, container, name)
it = storage.Find(ctx, prefixCnr, storage.ValuesOnly)
for iterator.Next(it) {
result = append(result, iterator.Value(it).([]byte))
}
result = append(result, ListChainsByPrefix(Container, container, name)...)
}
return result

View file

@ -89,12 +89,6 @@ func checkChainsByPrefix(t *testing.T, e *neotest.ContractInvoker, kind byte, en
func checksChainsOnStack(t *testing.T, s *vm.Stack, expected [][]byte) {
require.Equal(t, 1, s.Len())
if len(expected) == 0 {
_, ok := s.Pop().Item().(stackitem.Null)
require.True(t, ok)
return
}
var actual [][]byte
arr := s.Pop().Array()
for i := range arr {