diff --git a/nns/nns_contract.go b/nns/nns_contract.go index 9df2d18..816f56c 100644 --- a/nns/nns_contract.go +++ b/nns/nns_contract.go @@ -239,6 +239,9 @@ func IsAvailable(name string) bool { ctx := storage.GetReadOnlyContext() l := len(fragments) if storage.Get(ctx, append([]byte{prefixRoot}, []byte(fragments[l-1])...)) == nil { + if l != 1 { + panic("panic should not happen") + } return true } diff --git a/tests/nns_test.go b/tests/nns_test.go index f19a448..51450bb 100644 --- a/tests/nns_test.go +++ b/tests/nns_test.go @@ -588,6 +588,7 @@ func TestNNSIsAvailable(t *testing.T) { c := newNNSInvoker(t, false) c.Invoke(t, true, "isAvailable", "com") + c.InvokeFail(t, "panic should not happen", "isAvailable", "aa.domain.zk") refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104) c.Invoke(t, true, "register",