[#259] nns: Check admin in `Renew`

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
support/v0.16
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
- 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
### Updated

View File

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

View File

@ -347,7 +347,8 @@ func TestNNSRenew(t *testing.T) {
ts := b.Timestamp + uint64(expire*1000) + uint64(msPerYear)
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{
{Key: stackitem.Make("name"), Value: stackitem.Make("testdomain.com")},
{Key: stackitem.Make("expiration"), Value: stackitem.Make(ts)}})