diff --git a/container/container_contract.go b/container/container_contract.go index f477fe7..03799ee 100644 --- a/container/container_contract.go +++ b/container/container_contract.go @@ -272,8 +272,8 @@ func checkNiceNameAvailable(nnsContractAddr interop.Hash160, domain string) bool owner := contract.Call(nnsContractAddr, "ownerOf", contract.ReadStates|contract.AllowCall, domain).(string) - if string(owner) != string(common.CommitteeAddress()) { - panic("committee must own registered domain") + if owner != string(common.CommitteeAddress()) && owner != string(runtime.GetExecutingScriptHash()) { + panic("committee or container contract must own registered domain") } res := contract.Call(nnsContractAddr, "getRecords", diff --git a/tests/container_test.go b/tests/container_test.go index 605a8d9..f0c3e37 100644 --- a/tests/container_test.go +++ b/tests/container_test.go @@ -117,6 +117,12 @@ func TestContainerPut(t *testing.T) { 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) AddBlockCheckHalt(t, bc, tx) @@ -136,7 +142,7 @@ func TestContainerPut(t *testing.T) { tx = PrepareInvoke(t, bc, acc, h, "putNamed", c.value, c.sig, c.pub, c.token, "baddomain", "neofs") 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",