forked from TrueCloudLab/frostfs-contract
[#150] container: check domain owner in Put
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
16f3281198
commit
fef6a6cb36
2 changed files with 18 additions and 0 deletions
|
@ -263,6 +263,12 @@ func checkNiceNameAvailable(nnsContractAddr interop.Hash160, domain string) bool
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
owner := contract.Call(nnsContractAddr, "ownerOf",
|
||||||
|
contract.ReadStates|contract.AllowCall, domain).(string)
|
||||||
|
if string(owner) != string(common.CommitteeAddress()) {
|
||||||
|
panic("committee must own registered domain")
|
||||||
|
}
|
||||||
|
|
||||||
res := contract.Call(nnsContractAddr, "getRecords",
|
res := contract.Call(nnsContractAddr, "getRecords",
|
||||||
contract.ReadStates|contract.AllowCall, domain, 16 /* TXT */)
|
contract.ReadStates|contract.AllowCall, domain, 16 /* TXT */)
|
||||||
if res != nil {
|
if res != nil {
|
||||||
|
|
|
@ -113,6 +113,18 @@ func TestContainerPut(t *testing.T) {
|
||||||
c.value[len(c.value)-1] = 10
|
c.value[len(c.value)-1] = 10
|
||||||
c.id = sha256.Sum256(c.value)
|
c.id = sha256.Sum256(c.value)
|
||||||
|
|
||||||
|
t.Run("bad domain owner", func(t *testing.T) {
|
||||||
|
tx = PrepareInvoke(t, bc, acc, nnsHash, "register",
|
||||||
|
"baddomain.neofs", acc.Contract.ScriptHash(),
|
||||||
|
"whateveriwant@world.com", int64(0), int64(0), int64(0), int64(0))
|
||||||
|
AddBlockCheckHalt(t, bc, tx)
|
||||||
|
|
||||||
|
putArgs := []interface{}{container, dummySig, dummyPub, dummyToken, "baddomain", "neofs"}
|
||||||
|
tx = PrepareInvoke(t, bc, acc, h, "putNamed", putArgs...)
|
||||||
|
AddBlock(t, bc, tx)
|
||||||
|
CheckFault(t, bc, tx.Hash(), "committee must own registered domain")
|
||||||
|
})
|
||||||
|
|
||||||
tx = PrepareInvoke(t, bc, CommitteeAcc, nnsHash, "register",
|
tx = PrepareInvoke(t, bc, CommitteeAcc, nnsHash, "register",
|
||||||
"second.neofs", CommitteeAcc.Contract.ScriptHash(),
|
"second.neofs", CommitteeAcc.Contract.ScriptHash(),
|
||||||
"whateveriwant@world.com", int64(0), int64(0), int64(0), int64(0))
|
"whateveriwant@world.com", int64(0), int64(0), int64(0), int64(0))
|
||||||
|
|
Loading…
Reference in a new issue