forked from TrueCloudLab/frostfs-contract
[#139] nns: require admin signature for registering subdomain
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
e0dbd07f21
commit
552def9322
3 changed files with 14 additions and 3 deletions
|
@ -303,6 +303,10 @@ func Register(name string, owner interop.Hash160, email string, refresh, retry,
|
||||||
if parentExpired(ctx, 1, fragments) {
|
if parentExpired(ctx, 1, fragments) {
|
||||||
panic("one of the parent domains has expired")
|
panic("one of the parent domains has expired")
|
||||||
}
|
}
|
||||||
|
parentKey := getTokenKey([]byte(fragments[1]))
|
||||||
|
nsBytes := storage.Get(ctx, append([]byte{prefixName}, parentKey...))
|
||||||
|
ns := std.Deserialize(nsBytes.([]byte)).(NameState)
|
||||||
|
ns.checkAdmin()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isValid(owner) {
|
if !isValid(owner) {
|
||||||
|
|
|
@ -136,7 +136,7 @@ func TestContainerPut(t *testing.T) {
|
||||||
c.id = sha256.Sum256(c.value)
|
c.id = sha256.Sum256(c.value)
|
||||||
|
|
||||||
t.Run("bad domain owner", func(t *testing.T) {
|
t.Run("bad domain owner", func(t *testing.T) {
|
||||||
tx = PrepareInvoke(t, bc, acc, nnsHash, "register",
|
tx = PrepareInvoke(t, bc, []*wallet.Account{acc, CommitteeAcc}, nnsHash, "register",
|
||||||
"baddomain.neofs", acc.Contract.ScriptHash(),
|
"baddomain.neofs", acc.Contract.ScriptHash(),
|
||||||
"whateveriwant@world.com", int64(0), int64(0), int64(0), int64(0))
|
"whateveriwant@world.com", int64(0), int64(0), int64(0), int64(0))
|
||||||
AddBlockCheckHalt(t, bc, tx)
|
AddBlockCheckHalt(t, bc, tx)
|
||||||
|
|
|
@ -65,9 +65,10 @@ func TestNNSRegister(t *testing.T) {
|
||||||
bc := NewChain(t)
|
bc := NewChain(t)
|
||||||
h := DeployContract(t, bc, nnsPath, nil)
|
h := DeployContract(t, bc, nnsPath, nil)
|
||||||
|
|
||||||
|
accTop := NewAccount(t, bc)
|
||||||
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
refresh, retry, expire, ttl := int64(101), int64(102), int64(103), int64(104)
|
||||||
tx := PrepareInvoke(t, bc, CommitteeAcc, h, "register",
|
tx := PrepareInvoke(t, bc, []*wallet.Account{CommitteeAcc, accTop}, h, "register",
|
||||||
"com", CommitteeAcc.Contract.ScriptHash(),
|
"com", accTop.Contract.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
||||||
AddBlockCheckHalt(t, bc, tx)
|
AddBlockCheckHalt(t, bc, tx)
|
||||||
|
|
||||||
|
@ -75,6 +76,12 @@ func TestNNSRegister(t *testing.T) {
|
||||||
tx = PrepareInvoke(t, bc, []*wallet.Account{CommitteeAcc, acc}, h, "register",
|
tx = PrepareInvoke(t, bc, []*wallet.Account{CommitteeAcc, acc}, h, "register",
|
||||||
"testdomain.com", acc.Contract.ScriptHash(),
|
"testdomain.com", acc.Contract.ScriptHash(),
|
||||||
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
||||||
|
AddBlock(t, bc, tx)
|
||||||
|
CheckFault(t, bc, tx.Hash(), "not witnessed by admin")
|
||||||
|
|
||||||
|
tx = PrepareInvoke(t, bc, []*wallet.Account{accTop, acc}, h, "register",
|
||||||
|
"testdomain.com", acc.Contract.ScriptHash(),
|
||||||
|
"myemail@nspcc.ru", refresh, retry, expire, ttl)
|
||||||
b := AddBlockCheckHalt(t, bc, tx)
|
b := AddBlockCheckHalt(t, bc, tx)
|
||||||
|
|
||||||
tx = PrepareInvoke(t, bc, acc, h, "getRecords", "testdomain.com", int64(nns.SOA))
|
tx = PrepareInvoke(t, bc, acc, h, "getRecords", "testdomain.com", int64(nns.SOA))
|
||||||
|
|
Loading…
Reference in a new issue