From 53f102344fd2bd3f72f88b727c9a784224990a5e Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 17 Jan 2022 12:47:56 +0300 Subject: [PATCH] [#215] container/tests: add helper for dummy container creation Signed-off-by: Evgenii Stratonikov --- tests/container_test.go | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/tests/container_test.go b/tests/container_test.go index 8f18820..5628800 100644 --- a/tests/container_test.go +++ b/tests/container_test.go @@ -145,15 +145,19 @@ func TestContainerPut(t *testing.T) { }) } -func TestContainerDelete(t *testing.T) { - c, cBal := newContainerInvoker(t) - +func addContainer(t *testing.T, c, cBal *neotest.ContractInvoker) (neotest.Signer, testContainer) { acc := c.NewAccount(t) cnt := dummyContainer(acc) balanceMint(t, cBal, acc, containerFee*1, []byte{}) c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token) + return acc, cnt +} +func TestContainerDelete(t *testing.T) { + c, cBal := newContainerInvoker(t) + + acc, cnt := addContainer(t, c, cBal) cAcc := c.WithSigners(acc) cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "delete", cnt.id[:], cnt.sig, cnt.token) @@ -172,11 +176,7 @@ func TestContainerDelete(t *testing.T) { func TestContainerOwner(t *testing.T) { c, cBal := newContainerInvoker(t) - acc := c.NewAccount(t) - cnt := dummyContainer(acc) - - balanceMint(t, cBal, acc, containerFee*1, []byte{}) - c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token) + acc, cnt := addContainer(t, c, cBal) t.Run("missing container", func(t *testing.T) { id := cnt.id @@ -191,12 +191,7 @@ func TestContainerOwner(t *testing.T) { func TestContainerGet(t *testing.T) { c, cBal := newContainerInvoker(t) - acc := c.NewAccount(t) - cnt := dummyContainer(acc) - - balanceMint(t, cBal, acc, containerFee*1, []byte{}) - - c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token) + _, cnt := addContainer(t, c, cBal) t.Run("missing container", func(t *testing.T) { id := cnt.id @@ -234,11 +229,7 @@ func dummyEACL(containerID [32]byte) eacl { func TestContainerSetEACL(t *testing.T) { c, cBal := newContainerInvoker(t) - acc := c.NewAccount(t) - cnt := dummyContainer(acc) - balanceMint(t, cBal, acc, containerFee*1, []byte{}) - - c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token) + acc, cnt := addContainer(t, c, cBal) t.Run("missing container", func(t *testing.T) { id := cnt.id