Skip to content

Commit

Permalink
nns: fix expired TLD registration (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov committed Nov 10, 2023
2 parents 6342a16 + 9ae1bfe commit 76f2d44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nns/nns_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func saveCommitteeDomain(ctx storage.Context, name, email string, refresh, retry
}

tldKey := makeTLDKey(name)
if storage.Get(ctx, tldKey) != nil {
if storage.Get(ctx, tldKey) != nil && !parentExpired(ctx, 0, fragments) {
panic("TLD already exists")
}

Expand Down
9 changes: 9 additions & 0 deletions tests/nns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ func TestExpiration(t *testing.T) {
c := newNNSInvoker(t, true)

refresh, retry, expire, ttl := int64(101), int64(102), int64(msPerYear/1000*10), int64(104)
c.Invoke(t, stackitem.Null{}, "registerTLD",
"newtld", "myemail@nspcc.ru", refresh, retry, expire, ttl)
c.Invoke(t, true, "register",
"testdomain.com", c.CommitteeHash,
"myemail@nspcc.ru", refresh, retry, expire, ttl)
Expand Down Expand Up @@ -278,6 +280,13 @@ func TestExpiration(t *testing.T) {

c.InvokeFail(t, "name has expired", "getAllRecords", "testdomain.com")
c.InvokeFail(t, "name has expired", "ownerOf", "testdomain.com")

c.InvokeFail(t, "name has expired", "renew", "newtld")
c.Invoke(t, stackitem.Null{}, "registerTLD",
"newtld", "myemail@nspcc.ru", refresh, retry, expire, ttl)
c.Invoke(t, true, "register",
"testdomain.com", c.CommitteeHash,
"myemail@nspcc.ru", refresh, retry, expire, ttl)
}

func TestNNSSetAdmin(t *testing.T) {
Expand Down

0 comments on commit 76f2d44

Please sign in to comment.