[#259] nns: Check admin in Renew

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-08-23 12:06:05 +03:00 committed by fyrchik
parent 5b5ff8cb33
commit b4fdd854b7
3 changed files with 6 additions and 1 deletions

View file

@ -6,6 +6,9 @@ Changelog for NeoFS Contract
### Updated ### Updated
- NNS contract now sets domain expiration based on `register` arguments (#262) - NNS contract now sets domain expiration based on `register` arguments (#262)
### Fixed
- NNS `renew` now can only be done by the domain owner
## [0.15.5] - 2022-08-23 ## [0.15.5] - 2022-08-23
### Updated ### Updated

View file

@ -339,6 +339,7 @@ func Renew(name string) int64 {
runtime.BurnGas(GetPrice()) runtime.BurnGas(GetPrice())
ctx := storage.GetContext() ctx := storage.GetContext()
ns := getNameState(ctx, []byte(name)) ns := getNameState(ctx, []byte(name))
ns.checkAdmin()
ns.Expiration += millisecondsInYear ns.Expiration += millisecondsInYear
putNameState(ctx, ns) putNameState(ctx, ns)
return ns.Expiration return ns.Expiration

View file

@ -347,7 +347,8 @@ func TestNNSRenew(t *testing.T) {
ts := b.Timestamp + uint64(expire*1000) + uint64(msPerYear) ts := b.Timestamp + uint64(expire*1000) + uint64(msPerYear)
cAcc := c.WithSigners(acc) cAcc := c.WithSigners(acc)
cAcc.Invoke(t, ts, "renew", "testdomain.com") cAcc.InvokeFail(t, "not witnessed by admin", "renew", "testdomain.com")
c1.Invoke(t, ts, "renew", "testdomain.com")
expected := stackitem.NewMapWithValue([]stackitem.MapElement{ expected := stackitem.NewMapWithValue([]stackitem.MapElement{
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")}, {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)}})