forked from TrueCloudLab/frostfs-contract
[#156] container: fix domain owner check
Container contract owns all registered domains. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
b57f2ffe6b
commit
8c8e4a6d85
2 changed files with 9 additions and 3 deletions
|
@ -272,8 +272,8 @@ func checkNiceNameAvailable(nnsContractAddr interop.Hash160, domain string) bool
|
||||||
|
|
||||||
owner := contract.Call(nnsContractAddr, "ownerOf",
|
owner := contract.Call(nnsContractAddr, "ownerOf",
|
||||||
contract.ReadStates|contract.AllowCall, domain).(string)
|
contract.ReadStates|contract.AllowCall, domain).(string)
|
||||||
if string(owner) != string(common.CommitteeAddress()) {
|
if owner != string(common.CommitteeAddress()) && owner != string(runtime.GetExecutingScriptHash()) {
|
||||||
panic("committee must own registered domain")
|
panic("committee or container contract must own registered domain")
|
||||||
}
|
}
|
||||||
|
|
||||||
res := contract.Call(nnsContractAddr, "getRecords",
|
res := contract.Call(nnsContractAddr, "getRecords",
|
||||||
|
|
|
@ -117,6 +117,12 @@ func TestContainerPut(t *testing.T) {
|
||||||
stackitem.NewByteArray([]byte(base58.Encode(c.id[:]))),
|
stackitem.NewByteArray([]byte(base58.Encode(c.id[:]))),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
t.Run("name is already taken", func(t *testing.T) {
|
||||||
|
tx = PrepareInvoke(t, bc, CommitteeAcc, h, "putNamed", putArgs...)
|
||||||
|
AddBlock(t, bc, tx)
|
||||||
|
CheckFault(t, bc, tx.Hash(), "name is already taken")
|
||||||
|
})
|
||||||
|
|
||||||
tx = PrepareInvoke(t, bc, CommitteeAcc, h, "delete", c.id[:], c.sig, c.token)
|
tx = PrepareInvoke(t, bc, CommitteeAcc, h, "delete", c.id[:], c.sig, c.token)
|
||||||
AddBlockCheckHalt(t, bc, tx)
|
AddBlockCheckHalt(t, bc, tx)
|
||||||
|
|
||||||
|
@ -136,7 +142,7 @@ func TestContainerPut(t *testing.T) {
|
||||||
tx = PrepareInvoke(t, bc, acc, h, "putNamed",
|
tx = PrepareInvoke(t, bc, acc, h, "putNamed",
|
||||||
c.value, c.sig, c.pub, c.token, "baddomain", "neofs")
|
c.value, c.sig, c.pub, c.token, "baddomain", "neofs")
|
||||||
AddBlock(t, bc, tx)
|
AddBlock(t, bc, tx)
|
||||||
CheckFault(t, bc, tx.Hash(), "committee must own registered domain")
|
CheckFault(t, bc, tx.Hash(), "committee or container contract must own registered domain")
|
||||||
})
|
})
|
||||||
|
|
||||||
tx = PrepareInvoke(t, bc, CommitteeAcc, nnsHash, "register",
|
tx = PrepareInvoke(t, bc, CommitteeAcc, nnsHash, "register",
|
||||||
|
|
Loading…
Reference in a new issue