From e5c5cc30c0a1777ccfef9655bd2e3823feeff3b7 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 18 Oct 2021 14:44:06 +0300 Subject: [PATCH] [#150] container: make config key public Signed-off-by: Evgenii Stratonikov --- container/container_contract.go | 5 +++-- tests/container_test.go | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/container/container_contract.go b/container/container_contract.go index 820145e..4ce5776 100644 --- a/container/container_contract.go +++ b/container/container_contract.go @@ -51,7 +51,8 @@ const ( nnsHasAliasKey = "nnsHasAlias" notaryDisabledKey = "notary" - containerFeeKey = "ContainerFee" + // RegistrationFeeKey is a key in netmap config which contains fee for container registration. + RegistrationFeeKey = "ContainerFee" containerIDSize = 32 // SHA256 size @@ -177,7 +178,7 @@ func PutNamed(container []byte, signature interop.Signature, from := common.WalletToScriptHash(ownerID) netmapContractAddr := storage.Get(ctx, netmapContractKey).(interop.Hash160) balanceContractAddr := storage.Get(ctx, balanceContractKey).(interop.Hash160) - containerFee := contract.Call(netmapContractAddr, "config", contract.ReadOnly, containerFeeKey).(int) + containerFee := contract.Call(netmapContractAddr, "config", contract.ReadOnly, RegistrationFeeKey).(int) balance := contract.Call(balanceContractAddr, "balanceOf", contract.ReadOnly, from).(int) if balance < containerFee*len(alphabet) { diff --git a/tests/container_test.go b/tests/container_test.go index 2c5b58e..dcce848 100644 --- a/tests/container_test.go +++ b/tests/container_test.go @@ -9,6 +9,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/wallet" + "github.com/nspcc-dev/neofs-contract/container" "github.com/nspcc-dev/neofs-contract/nns" "github.com/stretchr/testify/require" ) @@ -40,7 +41,7 @@ func prepareContainerContract(t *testing.T, bc *core.Blockchain) (util.Uint160, ctrContainer, err := ContractInfo(CommitteeAcc.Contract.ScriptHash(), containerPath) require.NoError(t, err) - deployNetmapContract(t, bc, ctrBalance.Hash, ctrContainer.Hash, "ContainerFee", int64(containerFee)) + deployNetmapContract(t, bc, ctrBalance.Hash, ctrContainer.Hash, container.RegistrationFeeKey, int64(containerFee)) balHash := deployBalanceContract(t, bc, ctrNetmap.Hash, ctrContainer.Hash) return deployContainerContract(t, bc, ctrNetmap.Hash, ctrBalance.Hash, addrNNS), balHash } @@ -119,8 +120,8 @@ func TestContainerPut(t *testing.T) { "whateveriwant@world.com", int64(0), int64(0), int64(0), int64(0)) AddBlockCheckHalt(t, bc, tx) - putArgs := []interface{}{container, dummySig, dummyPub, dummyToken, "baddomain", "neofs"} - tx = PrepareInvoke(t, bc, acc, h, "putNamed", putArgs...) + tx = PrepareInvoke(t, bc, acc, h, "putNamed", + c.value, c.sig, c.pub, c.token, "baddomain", "neofs") AddBlock(t, bc, tx) CheckFault(t, bc, tx.Hash(), "committee must own registered domain") })