From d7e893b8ca5e318355126edffd6963abcb0a2f9d Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 9 Sep 2022 19:39:34 +0300 Subject: [PATCH] [#266] nns: Return empty Array from `resolve` instead of Null In case if no records of the specified type found. Signed-off-by: Anna Shaleva --- nns/nns_contract.go | 3 ++- tests/container_test.go | 2 +- tests/nns_test.go | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nns/nns_contract.go b/nns/nns_contract.go index 2ad91157..ed2ea2a4 100644 --- a/nns/nns_contract.go +++ b/nns/nns_contract.go @@ -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. diff --git a/tests/container_test.go b/tests/container_test.go index 9a265e17..d26221c5 100644 --- a/tests/container_test.go +++ b/tests/container_test.go @@ -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 diff --git a/tests/nns_test.go b/tests/nns_test.go index 0e312437..91fc7ec5 100644 --- a/tests/nns_test.go +++ b/tests/nns_test.go @@ -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)) }