tests: Move owner ID calculation to a separate function

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-08-08 11:03:20 +03:00 committed by Evgenii Stratonikov
parent 6e8ae742ae
commit 2b1fa53b67
2 changed files with 7 additions and 5 deletions

View file

@ -58,8 +58,12 @@ func newContainerInvoker(t *testing.T) (*neotest.ContractInvoker, *neotest.Contr
} }
func setContainerOwner(c []byte, acc neotest.Signer) { 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())) owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash()))
copy(c[6:], owner) return owner
} }
type testContainer struct { type testContainer struct {
@ -268,7 +272,7 @@ func TestContainerOwner(t *testing.T) {
c.InvokeFail(t, container.NotFoundError, "owner", id[:]) 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[:]) c.Invoke(t, stackitem.NewBuffer(owner), "owner", cnt.id[:])
} }

View file

@ -7,9 +7,7 @@ import (
"testing" "testing"
"git.frostfs.info/TrueCloudLab/frostfs-contract/container" "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/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/neotest"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
@ -57,7 +55,7 @@ func TestFrostFSID_AddKey(t *testing.T) {
pubs[i] = p.PublicKey().Bytes() pubs[i] = p.PublicKey().Bytes()
} }
acc := e.NewAccount(t) acc := e.NewAccount(t)
owner, _ := base58.Decode(address.Uint160ToString(acc.ScriptHash())) owner := signerToOwner(acc)
e.Invoke(t, stackitem.Null{}, "addKey", owner, e.Invoke(t, stackitem.Null{}, "addKey", owner,
[]interface{}{pubs[0], pubs[1]}) []interface{}{pubs[0], pubs[1]})