[#51] policy: Support Get and ListByPrefix methods #51
2 changed files with 2 additions and 20 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue