[#150] container: make config key public

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-10-18 14:44:06 +03:00 committed by Alex Vanin
parent fef6a6cb36
commit e5c5cc30c0
2 changed files with 7 additions and 5 deletions

View file

@ -51,7 +51,8 @@ const (
nnsHasAliasKey = "nnsHasAlias" nnsHasAliasKey = "nnsHasAlias"
notaryDisabledKey = "notary" notaryDisabledKey = "notary"
containerFeeKey = "ContainerFee" // RegistrationFeeKey is a key in netmap config which contains fee for container registration.
RegistrationFeeKey = "ContainerFee"
containerIDSize = 32 // SHA256 size containerIDSize = 32 // SHA256 size
@ -177,7 +178,7 @@ func PutNamed(container []byte, signature interop.Signature,
from := common.WalletToScriptHash(ownerID) from := common.WalletToScriptHash(ownerID)
netmapContractAddr := storage.Get(ctx, netmapContractKey).(interop.Hash160) netmapContractAddr := storage.Get(ctx, netmapContractKey).(interop.Hash160)
balanceContractAddr := storage.Get(ctx, balanceContractKey).(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) balance := contract.Call(balanceContractAddr, "balanceOf", contract.ReadOnly, from).(int)
if balance < containerFee*len(alphabet) { if balance < containerFee*len(alphabet) {

View file

@ -9,6 +9,7 @@ import (
"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"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/nspcc-dev/neofs-contract/container"
"github.com/nspcc-dev/neofs-contract/nns" "github.com/nspcc-dev/neofs-contract/nns"
"github.com/stretchr/testify/require" "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) ctrContainer, err := ContractInfo(CommitteeAcc.Contract.ScriptHash(), containerPath)
require.NoError(t, err) 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) balHash := deployBalanceContract(t, bc, ctrNetmap.Hash, ctrContainer.Hash)
return deployContainerContract(t, bc, ctrNetmap.Hash, ctrBalance.Hash, addrNNS), balHash 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)) "whateveriwant@world.com", int64(0), int64(0), int64(0), int64(0))
AddBlockCheckHalt(t, bc, tx) AddBlockCheckHalt(t, bc, tx)
putArgs := []interface{}{container, dummySig, dummyPub, dummyToken, "baddomain", "neofs"} tx = PrepareInvoke(t, bc, acc, h, "putNamed",
tx = PrepareInvoke(t, bc, acc, h, "putNamed", putArgs...) c.value, c.sig, c.pub, c.token, "baddomain", "neofs")
AddBlock(t, bc, tx) AddBlock(t, bc, tx)
CheckFault(t, bc, tx.Hash(), "committee must own registered domain") CheckFault(t, bc, tx.Hash(), "committee must own registered domain")
}) })