From 2b1fa53b677d3cbe71057fb707688bd8872b72e7 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 8 Aug 2023 11:03:20 +0300 Subject: [PATCH] tests: Move owner ID calculation to a separate function Signed-off-by: Evgenii Stratonikov --- tests/container_test.go | 8 ++++++-- tests/frostfsid_test.go | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/container_test.go b/tests/container_test.go index 9fe8431..70c6bdc 100644 --- a/tests/container_test.go +++ b/tests/container_test.go @@ -58,8 +58,12 @@ func newContainerInvoker(t *testing.T) (*neotest.ContractInvoker, *neotest.Contr } func setContainerOwner(c []byte, acc neotest.Signer) { + copy(c[6:], signerToOwner(acc)) +} + +func signerToOwner(acc neotest.Signer) []byte { owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash())) - copy(c[6:], owner) + return owner } type testContainer struct { @@ -268,7 +272,7 @@ func TestContainerOwner(t *testing.T) { c.InvokeFail(t, container.NotFoundError, "owner", id[:]) }) - owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash())) + owner := signerToOwner(acc) c.Invoke(t, stackitem.NewBuffer(owner), "owner", cnt.id[:]) } diff --git a/tests/frostfsid_test.go b/tests/frostfsid_test.go index 4089b9b..2e25e58 100644 --- a/tests/frostfsid_test.go +++ b/tests/frostfsid_test.go @@ -7,9 +7,7 @@ import ( "testing" "git.frostfs.info/TrueCloudLab/frostfs-contract/container" - "github.com/mr-tron/base58" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" - "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/neotest" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" @@ -57,7 +55,7 @@ func TestFrostFSID_AddKey(t *testing.T) { pubs[i] = p.PublicKey().Bytes() } acc := e.NewAccount(t) - owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash())) + owner := signerToOwner(acc) e.Invoke(t, stackitem.Null{}, "addKey", owner, []interface{}{pubs[0], pubs[1]})