Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/test/bufconn"

dnConfig "github.com/dfinance/dnode/cmd/config"
vmConfig "github.com/dfinance/dnode/cmd/config"
"github.com/dfinance/dnode/cmd/config/genesis/defaults"
"github.com/dfinance/dnode/cmd/config/restrictions"
"github.com/dfinance/dnode/helpers/tests"
"github.com/dfinance/dnode/x/currencies"
Expand Down Expand Up @@ -369,13 +369,13 @@ func GetGenesis(app *DnServiceApp, chainID, monikerID string, nodeAccPrivKey sec

stakingGenesis := staking.GenesisState{}
app.cdc.MustUnmarshalJSON(genesisState[staking.ModuleName], &stakingGenesis)
stakingGenesis.Params.BondDenom = dnConfig.MainDenom
stakingGenesis.Params.BondDenom = defaults.MainDenom
genesisState[staking.ModuleName] = codec.MustMarshalJSONIndent(app.cdc, stakingGenesis)

// update mint denom
mintGenesis := mint.GenesisState{}
app.cdc.MustUnmarshalJSON(genesisState[mint.ModuleName], &mintGenesis)
mintGenesis.Params.MintDenom = dnConfig.MainDenom
mintGenesis.Params.MintDenom = defaults.MainDenom
genesisState[mint.ModuleName] = codec.MustMarshalJSONIndent(app.cdc, mintGenesis)

oracleGenesis := oracle.GenesisState{
Expand Down Expand Up @@ -408,14 +408,14 @@ func GetGenesis(app *DnServiceApp, chainID, monikerID string, nodeAccPrivKey sec
msg := staking.NewMsgCreateValidator(
nodeAcc.Address.Bytes(),
nodeAcc.PubKey,
sdk.NewCoin(dnConfig.MainDenom, tokenAmount),
sdk.NewCoin(defaults.MainDenom, tokenAmount),
staking.NewDescription(monikerID, "", "", "", ""),
staking.NewCommissionRates(commissionRate, commissionMaxRate, commissionChangeRate),
minSelfDelegation,
)

txFee := auth.StdFee{
Amount: sdk.Coins{{Denom: dnConfig.MainDenom, Amount: sdk.NewInt(1)}},
Amount: sdk.Coins{{Denom: defaults.MainDenom, Amount: sdk.NewInt(1)}},
Gas: defGasAmount,
}
txMemo := "testmemo"
Expand Down Expand Up @@ -503,7 +503,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe
memo := "testmemotestmemo"

fee := auth.StdFee{
Amount: sdk.Coins{{Denom: dnConfig.MainDenom, Amount: sdk.NewInt(1)}},
Amount: sdk.Coins{{Denom: defaults.MainDenom, Amount: sdk.NewInt(1)}},
Gas: defGasAmount,
}

Expand All @@ -524,7 +524,7 @@ func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKe

// GenDefCoins returns Coins with xfi amount.
func GenDefCoins(t *testing.T) sdk.Coins {
coins, err := sdk.ParseCoins("1000000000000000000000" + dnConfig.MainDenom)
coins, err := sdk.ParseCoins("1000000000000000000000" + defaults.MainDenom)
if t != nil {
require.NoError(t, err)
}
Expand Down
4 changes: 2 additions & 2 deletions app/integ_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"

dnConfig "github.com/dfinance/dnode/cmd/config"
"github.com/dfinance/dnode/cmd/config/genesis/defaults"
"github.com/dfinance/dnode/x/common_vm"
"github.com/dfinance/dnode/x/vm"
"github.com/dfinance/dnode/x/vm/client/vm_client"
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestIntegApp_Crisis(t *testing.T) {
}

getXfiBtcAccCoins := func(addr sdk.AccAddress) (sdk.Coin, sdk.Coin) {
xfiCoin := sdk.NewCoin(dnConfig.MainDenom, sdk.ZeroInt())
xfiCoin := sdk.NewCoin(defaults.MainDenom, sdk.ZeroInt())
btcCoin := sdk.NewCoin("btc", sdk.ZeroInt())
acc := GetAccountCheckTx(app, addr)
for _, coin := range acc.GetCoins() {
Expand Down
26 changes: 13 additions & 13 deletions app/integ_gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/dfinance/glav"
"github.com/stretchr/testify/require"

"github.com/dfinance/dnode/cmd/config"
"github.com/dfinance/dnode/cmd/config/genesis/defaults"
"github.com/dfinance/dnode/helpers/tests"
cliTester "github.com/dfinance/dnode/helpers/tests/clitester"
"github.com/dfinance/dnode/x/common_vm"
Expand Down Expand Up @@ -136,30 +136,30 @@ func TestIntegGov_StdlibUpdate(t *testing.T) {
{
// invalid from
{
tx := ct.TxVmStdlibUpdateProposal("invalid_address", moduleV1BytecodePath, "http://ya.ru", "Desc", 50, config.GovMinDeposit)
tx := ct.TxVmStdlibUpdateProposal("invalid_address", moduleV1BytecodePath, "http://ya.ru", "Desc", 50, defaults.GovMinDepositCoin)
tx.CheckFailedWithErrorSubstring("keyring")
}

// invalid file path
{
tx := ct.TxVmStdlibUpdateProposal(senderAddr, "invalid_path", "http://ya.ru", "Desc", 50, config.GovMinDeposit)
tx := ct.TxVmStdlibUpdateProposal(senderAddr, "invalid_path", "http://ya.ru", "Desc", 50, defaults.GovMinDepositCoin)
tx.CheckFailedWithErrorSubstring("moveFile")
}

// invalid blockHeight
{
tx1 := ct.TxVmStdlibUpdateProposal(senderAddr, moduleV1BytecodePath, "http://ya.ru", "Desc", 0, config.GovMinDeposit)
tx1 := ct.TxVmStdlibUpdateProposal(senderAddr, moduleV1BytecodePath, "http://ya.ru", "Desc", 0, defaults.GovMinDepositCoin)
tx1.CheckFailedWithErrorSubstring("height")

tx2 := ct.TxVmStdlibUpdateProposal(senderAddr, moduleV1BytecodePath, "http://ya.ru", "Desc", 0, config.GovMinDeposit)
tx2 := ct.TxVmStdlibUpdateProposal(senderAddr, moduleV1BytecodePath, "http://ya.ru", "Desc", 0, defaults.GovMinDepositCoin)
tx2.ChangeCmdArg("0", "abc")
tx2.CheckFailedWithErrorSubstring("ParseInt")
}
}

// Add DVM stdlib update proposal for module version 1 (cover the min deposit)
{
tx := ct.TxVmStdlibUpdateProposal(senderAddr, moduleV1BytecodePath, "http://ya.ru", "Foo module V1 added", -1, config.GovMinDeposit)
tx := ct.TxVmStdlibUpdateProposal(senderAddr, moduleV1BytecodePath, "http://ya.ru", "Foo module V1 added", -1, defaults.GovMinDepositCoin)
ct.SubmitAndConfirmProposal(tx, true)
}

Expand All @@ -182,7 +182,7 @@ func TestIntegGov_StdlibUpdate(t *testing.T) {

// Add DVM stdlib update proposal for module version 2
{
tx := ct.TxVmStdlibUpdateProposal(senderAddr, moduleV2BytecodePath, "http://ya.ru", "Foo module V2 added", -1, config.GovMinDeposit)
tx := ct.TxVmStdlibUpdateProposal(senderAddr, moduleV2BytecodePath, "http://ya.ru", "Foo module V2 added", -1, defaults.GovMinDepositCoin)
ct.SubmitAndConfirmProposal(tx, true)
}

Expand Down Expand Up @@ -222,35 +222,35 @@ func TestIntegGov_RegisterCurrency(t *testing.T) {
{
// invalid from
{
tx := ct.TxCCAddCurrencyProposal("invalid_from", crDenom, crBalancePathHex, crInfoPathHex, crDecimals, config.GovMinDeposit)
tx := ct.TxCCAddCurrencyProposal("invalid_from", crDenom, crBalancePathHex, crInfoPathHex, crDecimals, defaults.GovMinDepositCoin)
tx.CheckFailedWithErrorSubstring("keyring")
}

// invalid denom
{
tx := ct.TxCCAddCurrencyProposal(senderAddr, "invalid1", crBalancePathHex, crInfoPathHex, crDecimals, config.GovMinDeposit)
tx := ct.TxCCAddCurrencyProposal(senderAddr, "invalid1", crBalancePathHex, crInfoPathHex, crDecimals, defaults.GovMinDepositCoin)
tx.CheckFailedWithErrorSubstring("denom")
}

// invalid path
{
tx1 := ct.TxCCAddCurrencyProposal(senderAddr, crDenom, "zzvv", crInfoPathHex, crDecimals, config.GovMinDeposit)
tx1 := ct.TxCCAddCurrencyProposal(senderAddr, crDenom, "zzvv", crInfoPathHex, crDecimals, defaults.GovMinDepositCoin)
tx1.CheckFailedWithErrorSubstring("vmBalancePathHex")
tx2 := ct.TxCCAddCurrencyProposal(senderAddr, crDenom, crBalancePathHex, "abc", crDecimals, config.GovMinDeposit)
tx2 := ct.TxCCAddCurrencyProposal(senderAddr, crDenom, crBalancePathHex, "abc", crDecimals, defaults.GovMinDepositCoin)
tx2.CheckFailedWithErrorSubstring("vmInfoPathHex")
}

// invalid decimals
{
tx := ct.TxCCAddCurrencyProposal(senderAddr, crDenom, crBalancePathHex, crInfoPathHex, crDecimals, config.GovMinDeposit)
tx := ct.TxCCAddCurrencyProposal(senderAddr, crDenom, crBalancePathHex, crInfoPathHex, crDecimals, defaults.GovMinDepositCoin)
tx.ChangeCmdArg("8", "abc")
tx.CheckFailedWithErrorSubstring("decimals")
}
}

// Add proposal
{
tx := ct.TxCCAddCurrencyProposal(senderAddr, crDenom, crBalancePathHex, crInfoPathHex, crDecimals, config.GovMinDeposit)
tx := ct.TxCCAddCurrencyProposal(senderAddr, crDenom, crBalancePathHex, crInfoPathHex, crDecimals, defaults.GovMinDepositCoin)
ct.SubmitAndConfirmProposal(tx, false)
}

Expand Down
4 changes: 2 additions & 2 deletions app/unit_distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/tendermint/tendermint/crypto/secp256k1"

"github.com/dfinance/dnode/cmd/config"
"github.com/dfinance/dnode/cmd/config/genesis/defaults"
)

// Check disabled distribution transactions.
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestDistribution_MessagesNotWorking(t *testing.T) {
// check fund community pool.
{
senderAcc, senderPrivKey := GetAccountCheckTx(app, nodeAddress), nodePrivKey
withdrawComissionMsg := distribution.NewMsgFundPublicTreasuryPool(sdk.NewCoins(sdk.NewCoin(config.MainDenom, sdk.NewInt(1))), nodeAddress)
withdrawComissionMsg := distribution.NewMsgFundPublicTreasuryPool(sdk.NewCoins(sdk.NewCoin(defaults.MainDenom, sdk.NewInt(1))), nodeAddress)
tx := GenTx([]sdk.Msg{withdrawComissionMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey)
CheckDeliverSpecificErrorTx(t, app, tx, errors.ErrUnknownRequest)
}
Expand Down
20 changes: 20 additions & 0 deletions cmd/config/bech_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package config

import sdk "github.com/cosmos/cosmos-sdk/types"

const (
MainPrefix = "wallet" // Main prefix for all addresses.
Bech32PrefixAccAddr = MainPrefix // Bech32 prefix for account addresses.
Bech32PrefixAccPub = MainPrefix + sdk.PrefixPublic // Bech32 prefix for accounts pub keys.
Bech32PrefixValAddr = MainPrefix + sdk.PrefixValidator + sdk.PrefixOperator // Bech32 prefix for validators addresses.
Bech32PrefixValPub = MainPrefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic // Bech32 prefix for validator pub keys.
Bech32PrefixConsAddr = MainPrefix + sdk.PrefixValidator + sdk.PrefixConsensus // Bech32 prefix for consensus addresses.
Bech32PrefixConsPub = MainPrefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic // Bech32 prefix for consensus pub keys.
)

// Initializing DN custom prefixes.
func InitBechPrefixes(config *sdk.Config) {
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
}
3 changes: 1 addition & 2 deletions cmd/config/cli_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import (
)

const (
flagGet = "get"
DefaultCompilerAddr = "tcp://127.0.0.1:50051"
flagGet = "get"
)

var configDefaults = map[string]string{
Expand Down
125 changes: 0 additions & 125 deletions cmd/config/config.go

This file was deleted.

Loading