[#51] policy: Support Get and ListByPrefix methods #51

Merged
dkirillov merged 2 commits from dkirillov/frostfs-contract:feature/support_iam_operations into master 2024-09-04 19:51:17 +00:00
2 changed files with 2 additions and 20 deletions
Showing only changes of commit 20f86e96b2 - Show all commits

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 {