[#27] Add public key as argument for container_contract.Delete() method

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2023-06-01 14:08:21 +03:00
parent b89c3fd584
commit 2da0ff5750
2 changed files with 8 additions and 8 deletions

View file

@ -310,7 +310,7 @@ func checkNiceNameAvailable(nnsContractAddr interop.Hash160, domain string) bool
// API. // API.
// //
// If the container doesn't exist, it panics with NotFoundError. // If the container doesn't exist, it panics with NotFoundError.
func Delete(containerID []byte, signature interop.Signature, token []byte) { func Delete(containerID []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
ctx := storage.GetContext() ctx := storage.GetContext()
ownerID := getOwnerByID(ctx, containerID) ownerID := getOwnerByID(ctx, containerID)

View file

@ -105,15 +105,15 @@ func TestContainerCount(t *testing.T) {
c.Invoke(t, stackitem.Null{}, "put", cnt3.value, cnt3.sig, cnt3.pub, cnt3.token) c.Invoke(t, stackitem.Null{}, "put", cnt3.value, cnt3.sig, cnt3.pub, cnt3.token)
checkContainerList(t, c, [][]byte{cnt1.id[:], cnt2.id[:], cnt3.id[:]}) checkContainerList(t, c, [][]byte{cnt1.id[:], cnt2.id[:], cnt3.id[:]})
c.Invoke(t, stackitem.Null{}, "delete", cnt1.id[:], cnt1.sig, cnt1.token) c.Invoke(t, stackitem.Null{}, "delete", cnt1.id[:], cnt1.sig, cnt1.pub, cnt1.token)
checkCount(t, 2) checkCount(t, 2)
checkContainerList(t, c, [][]byte{cnt2.id[:], cnt3.id[:]}) checkContainerList(t, c, [][]byte{cnt2.id[:], cnt3.id[:]})
c.Invoke(t, stackitem.Null{}, "delete", cnt2.id[:], cnt2.sig, cnt2.token) c.Invoke(t, stackitem.Null{}, "delete", cnt2.id[:], cnt2.sig, cnt2.pub, cnt2.token)
checkCount(t, 1) checkCount(t, 1)
checkContainerList(t, c, [][]byte{cnt3.id[:]}) checkContainerList(t, c, [][]byte{cnt3.id[:]})
c.Invoke(t, stackitem.Null{}, "delete", cnt3.id[:], cnt3.sig, cnt3.token) c.Invoke(t, stackitem.Null{}, "delete", cnt3.id[:], cnt3.sig, cnt3.pub, cnt3.token)
checkCount(t, 0) checkCount(t, 0)
checkContainerList(t, c, [][]byte{}) checkContainerList(t, c, [][]byte{})
} }
@ -201,7 +201,7 @@ func TestContainerPut(t *testing.T) {
c.InvokeFail(t, "name is already taken", "putNamed", putArgs...) c.InvokeFail(t, "name is already taken", "putNamed", putArgs...)
}) })
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token) c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
cNNS.Invoke(t, stackitem.Null{}, "resolve", "mycnt.frostfs", int64(nns.TXT)) cNNS.Invoke(t, stackitem.Null{}, "resolve", "mycnt.frostfs", int64(nns.TXT))
t.Run("register in advance", func(t *testing.T) { t.Run("register in advance", func(t *testing.T) {
@ -244,14 +244,14 @@ func TestContainerDelete(t *testing.T) {
acc, cnt := addContainer(t, c, cBal) acc, cnt := addContainer(t, c, cBal)
cAcc := c.WithSigners(acc) cAcc := c.WithSigners(acc)
cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "delete", cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "delete",
cnt.id[:], cnt.sig, cnt.token) cnt.id[:], cnt.sig, cnt.pub, cnt.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token) c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
t.Run("missing container", func(t *testing.T) { t.Run("missing container", func(t *testing.T) {
id := cnt.id id := cnt.id
id[0] ^= 0xFF id[0] ^= 0xFF
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token) c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
}) })
c.InvokeFail(t, container.NotFoundError, "get", cnt.id[:]) c.InvokeFail(t, container.NotFoundError, "get", cnt.id[:])