Skip to content

Commit

Permalink
[nspcc-dev#266] nns: Add admin to properties
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaShaleva committed Sep 13, 2022
1 parent 70ae2c9 commit 9e96dc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions nns/nns_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func Properties(tokenID []byte) map[string]interface{} {
return map[string]interface{}{
"name": ns.Name,
"expiration": ns.Expiration,
"admin": ns.Admin,
}
}

Expand Down
14 changes: 12 additions & 2 deletions tests/nns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ func TestExpiration(t *testing.T) {
checkProperties := func(t *testing.T, expiration uint64) {
expected := stackitem.NewMapWithValue([]stackitem.MapElement{
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
{Key: stackitem.Make("expiration"), Value: stackitem.Make(expiration)}})
{Key: stackitem.Make("expiration"), Value: stackitem.Make(expiration)},
{Key: stackitem.Make("admin"), Value: stackitem.Null{}}})
s, err := c.TestInvoke(t, "properties", "testdomain.com")
require.NoError(t, err)
require.Equal(t, expected.Value(), s.Top().Item().Value())
Expand Down Expand Up @@ -296,6 +297,7 @@ func TestNNSSetAdmin(t *testing.T) {
c.Invoke(t, true, "register",
"testdomain.com", c.CommitteeHash,
"[email protected]", refresh, retry, expire, ttl)
top := c.TopBlock(t)

acc := c.NewAccount(t)
cAcc := c.WithSigners(acc)
Expand All @@ -305,6 +307,13 @@ func TestNNSSetAdmin(t *testing.T) {
c1 := c.WithSigners(c.Committee, acc)
c1.Invoke(t, stackitem.Null{}, "setAdmin", "testdomain.com", acc.ScriptHash())

expiration := top.Timestamp + uint64(expire*1000)
expectedProps := stackitem.NewMapWithValue([]stackitem.MapElement{
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
{Key: stackitem.Make("expiration"), Value: stackitem.Make(expiration)},
{Key: stackitem.Make("admin"), Value: stackitem.Make(acc.ScriptHash().BytesBE())}})
cAcc.Invoke(t, expectedProps, "properties", "testdomain.com")

cAcc.Invoke(t, stackitem.Null{}, "addRecord",
"testdomain.com", int64(nns.TXT), "will be added")
}
Expand Down Expand Up @@ -351,7 +360,8 @@ func TestNNSRenew(t *testing.T) {
c1.Invoke(t, ts, "renew", "testdomain.com")
expected := stackitem.NewMapWithValue([]stackitem.MapElement{
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
{Key: stackitem.Make("expiration"), Value: stackitem.Make(ts)}})
{Key: stackitem.Make("expiration"), Value: stackitem.Make(ts)},
{Key: stackitem.Make("admin"), Value: stackitem.Null{}}})
cAcc.Invoke(t, expected, "properties", "testdomain.com")
}

Expand Down

0 comments on commit 9e96dc4

Please sign in to comment.