From 2cb10edfd21eeeb98f0fe3cda4c5cd020d0a8d7c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 25 Oct 2021 15:43:57 +0300 Subject: [PATCH] [#142] container: do not fail when deleting missing container Signed-off-by: Evgenii Stratonikov --- container/container_contract.go | 2 +- tests/container_test.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/container/container_contract.go b/container/container_contract.go index 3cff17c..9c405f1 100644 --- a/container/container_contract.go +++ b/container/container_contract.go @@ -303,7 +303,7 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) { ownerID := getOwnerByID(ctx, containerID) if ownerID == nil { - panic(NotFoundError) + return } if notaryDisabled { diff --git a/tests/container_test.go b/tests/container_test.go index f0f94e4..4dcd5e5 100644 --- a/tests/container_test.go +++ b/tests/container_test.go @@ -185,6 +185,13 @@ func TestContainerDelete(t *testing.T) { tx = PrepareInvoke(t, bc, CommitteeAcc, h, "delete", c.id[:], c.sig, c.token) AddBlockCheckHalt(t, bc, tx) + t.Run("missing container", func(t *testing.T) { + id := c.id + id[0] ^= 0xFF + tx = PrepareInvoke(t, bc, CommitteeAcc, h, "delete", id[:], c.sig, c.token) + AddBlockCheckHalt(t, bc, tx) + }) + tx = PrepareInvoke(t, bc, acc, h, "get", c.id[:]) _, err := TestInvoke(bc, tx) require.Error(t, err)