Skip to content

Commit

Permalink
[nspcc-dev#266] nns: Return empty Array from resolve instead of Null
Browse files Browse the repository at this point in the history
In case if no records of the specified type found.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Sep 13, 2022
1 parent 9e96dc4 commit 5ab096a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion nns/nns_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ func DeleteRecords(name string, typ RecordType) {
// Resolve resolves given name (not more then three redirects are allowed).
func Resolve(name string, typ RecordType) []string {
ctx := storage.GetReadOnlyContext()
return resolve(ctx, nil, name, typ, 2)
res := []string{}
return resolve(ctx, res, name, typ, 2)
}

// GetAllRecords returns an Iterator with RecordState items for the given name.
Expand Down
2 changes: 1 addition & 1 deletion tests/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestContainerPut(t *testing.T) {
})

c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)
cNNS.Invoke(t, stackitem.Null{}, "resolve", "mycnt.neofs", int64(nns.TXT))
cNNS.Invoke(t, stackitem.NewArray([]stackitem.Item{}), "resolve", "mycnt.neofs", int64(nns.TXT))

t.Run("register in advance", func(t *testing.T) {
cnt.value[len(cnt.value)-1] = 10
Expand Down
2 changes: 2 additions & 0 deletions tests/nns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,6 @@ func TestNNSResolve(t *testing.T) {
c.Invoke(t, records, "resolve", "test.com", int64(nns.TXT))
c.Invoke(t, records, "resolve", "test.com.", int64(nns.TXT))
c.InvokeFail(t, "invalid domain name format", "resolve", "test.com..", int64(nns.TXT))
// Empty result.
c.Invoke(t, stackitem.NewArray([]stackitem.Item{}), "resolve", "test.com", int64(nns.CNAME))
}

0 comments on commit 5ab096a

Please sign in to comment.