Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nns: fix expired TLD registration #366

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow so many tests inside a singe Test* without any t.Run

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
Loading