Skip to content

Commit

Permalink
tests: Add test for roots method of the NNS contract
Browse files Browse the repository at this point in the history
Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
  • Loading branch information
cthulhu-rider committed Jun 14, 2023
1 parent 6d44114 commit 7156e54
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/nns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,29 @@ func TestNNSTLD(t *testing.T) {
inv.InvokeFail(t, tldFailMsg, "transfer", util.Uint160{}, tld, nil)
inv.Invoke(t, stackitem.Null{}, "updateSOA", tld, "user@domain.org", 0, 1, 2, 3)
}

func TestNNSRoots(t *testing.T) {
tlds := []string{"hello", "world"}

inv := newNNSInvoker(t, false, tlds...)

stack, err := inv.TestInvoke(t, "roots")
require.NoError(t, err)
require.NotEmpty(t, stack)

it, ok := stack.Pop().Value().(*storage.Iterator)
require.True(t, ok)

var res []string

for it.Next() {
item := it.Value()

b, err := item.TryBytes()
require.NoError(t, err)

res = append(res, string(b))
}

require.ElementsMatch(t, tlds, res)
}

0 comments on commit 7156e54

Please sign in to comment.