forked from nspcc-dev/neofs-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nspcc-dev#266] nns: Restrict the maximum number of records with the …
…same type Signed-off-by: Anna Shaleva <[email protected]>
- Loading branch information
1 parent
419b7d7
commit 0606349
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"fmt" | ||
"math/big" | ||
"path" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
@@ -17,7 +18,10 @@ import ( | |
|
||
const nnsPath = "../nns" | ||
|
||
const msPerYear = 365 * 24 * time.Hour / time.Millisecond | ||
const ( | ||
msPerYear = 365 * 24 * time.Hour / time.Millisecond | ||
maxRecordID = 255 // value from the contract. | ||
) | ||
|
||
func newNNSInvoker(t *testing.T, addRoot bool) *neotest.ContractInvoker { | ||
e := newExecutor(t) | ||
|
@@ -400,3 +404,19 @@ func TestNNSResolve(t *testing.T) { | |
// Empty result. | ||
c.Invoke(t, stackitem.NewArray([]stackitem.Item{}), "resolve", "test.com", int64(nns.CNAME)) | ||
} | ||
|
||
func TestNNSAddRecord(t *testing.T) { | ||
c := newNNSInvoker(t, true) | ||
|
||
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104) | ||
c.Invoke(t, true, "register", | ||
"testdomain.com", c.CommitteeHash, | ||
"[email protected]", refresh, retry, expire, ttl) | ||
for i := 0; i <= maxRecordID+1; i++ { | ||
if i == maxRecordID+1 { | ||
c.InvokeFail(t, "maximum number of records reached", "addRecord", "testdomain.com", int64(nns.TXT), strconv.Itoa(i)) | ||
} else { | ||
c.Invoke(t, stackitem.Null{}, "addRecord", "testdomain.com", int64(nns.TXT), strconv.Itoa(i)) | ||
} | ||
} | ||
} |