Skip to content

Commit bd37220

Browse files
committed
nns: adjust maxDomainNameFragmentLength
Port nspcc-dev/neofs-contract#238.
1 parent 20224cb commit bd37220

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

examples/nft-nd-nns/nns.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const (
4747
maxRegisterPrice = 1_0000_0000_0000
4848
// maxRootLength is the maximum domain root length.
4949
maxRootLength = 16
50-
// maxDomainNameFragmentLength is the maximum length of the domain name fragment.
51-
maxDomainNameFragmentLength = 62
50+
// maxDomainNameFragmentLength is the maximum length of the domain name fragment
51+
maxDomainNameFragmentLength = 63
5252
// minDomainNameLength is minimum domain length.
5353
minDomainNameLength = 3
5454
// maxDomainNameLength is maximum domain length.

examples/nft-nd-nns/nns_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ func TestExpiration(t *testing.T) {
137137
cAcc.Invoke(t, stackitem.Null{}, "resolve", "first.com", int64(nns.TXT))
138138
}
139139

140-
const millisecondsInYear = 365 * 24 * 3600 * 1000
140+
const (
141+
millisecondsInYear = 365 * 24 * 3600 * 1000
142+
maxDomainNameFragmentLength = 63
143+
)
141144

142145
func TestRegisterAndRenew(t *testing.T) {
143146
c := newNSClient(t)
@@ -154,9 +157,16 @@ func TestRegisterAndRenew(t *testing.T) {
154157
c.InvokeFail(t, "invalid domain name format", "register", "neo.com\n", e.CommitteeHash)
155158
c.InvokeWithFeeFail(t, "GAS limit exceeded", defaultNameServiceSysfee, "register", "neo.org", e.CommitteeHash)
156159
c.InvokeWithFeeFail(t, "GAS limit exceeded", defaultNameServiceDomainPrice, "register", "neo.com", e.CommitteeHash)
160+
var maxLenFragment string
161+
for i := 0; i < maxDomainNameFragmentLength; i++ {
162+
maxLenFragment += "q"
163+
}
164+
c.Invoke(t, true, "isAvailable", maxLenFragment+".com")
165+
c.Invoke(t, true, "register", maxLenFragment+".com", e.CommitteeHash)
166+
c.InvokeFail(t, "invalid domain name format", "register", maxLenFragment+"q.com", e.CommitteeHash)
157167

158168
c.Invoke(t, true, "isAvailable", "neo.com")
159-
c.Invoke(t, 0, "balanceOf", e.CommitteeHash)
169+
c.Invoke(t, 1, "balanceOf", e.CommitteeHash)
160170
c.Invoke(t, true, "register", "neo.com", e.CommitteeHash)
161171
topBlock := e.TopBlock(t)
162172
expectedExpiration := topBlock.Timestamp + millisecondsInYear
@@ -167,7 +177,7 @@ func TestRegisterAndRenew(t *testing.T) {
167177
props.Add(stackitem.Make("name"), stackitem.Make("neo.com"))
168178
props.Add(stackitem.Make("expiration"), stackitem.Make(expectedExpiration))
169179
c.Invoke(t, props, "properties", "neo.com")
170-
c.Invoke(t, 1, "balanceOf", e.CommitteeHash)
180+
c.Invoke(t, 2, "balanceOf", e.CommitteeHash)
171181
c.Invoke(t, e.CommitteeHash.BytesBE(), "ownerOf", []byte("neo.com"))
172182

173183
t.Run("invalid token ID", func(t *testing.T) {

0 commit comments

Comments
 (0)