Skip to content

Commit

Permalink
init balance as coins, not string
Browse files Browse the repository at this point in the history
  • Loading branch information
toteki committed Oct 9, 2023
1 parent 4acd3d0 commit bdc0d24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
7 changes: 1 addition & 6 deletions tests/e2e/setup/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ func getGenDoc(path string) (*tmtypes.GenesisDoc, error) {
// In practice, this function is used during setup when modifying the genesis file stored in the first
// validator's path, before the completed genesis file is copied to all validators. Note that path and
// moniker refer to the first validator - they do not relate to the account being added.
func addGenesisAccount(cdc codec.Codec, path, moniker, amountStr string, accAddr sdk.AccAddress) error {
func addGenesisAccount(cdc codec.Codec, path, moniker string, coins sdk.Coins, accAddr sdk.AccAddress) error {
serverCtx := server.NewDefaultContext()
config := serverCtx.Config

config.SetRoot(path)
config.Moniker = moniker

coins, err := sdk.ParseCoinsNormalized(amountStr)
if err != nil {
return fmt.Errorf("failed to parse coins: %w", err)
}

balances := banktypes.Balance{Address: accAddr.String(), Coins: coins.Sort()}
genAccount := authtypes.NewBaseAccount(accAddr, nil, 0, 0)

Expand Down
11 changes: 8 additions & 3 deletions tests/e2e/setup/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/cosmos/go-bip39"

appparams "github.com/umee-network/umee/v6/app/params"
"github.com/umee-network/umee/v6/util/coin"
"github.com/umee-network/umee/v6/x/metoken/mocks"
)

Expand All @@ -17,13 +18,17 @@ const (
ATOMExponent = 6
PhotonDenom = "photon"

// TODO: validator initial balances can be only uumee. Non-validaotr accounts get other tokens for testing.
InitBalanceStr = "510000000000" + appparams.BondDenom + ",100000000000" + PhotonDenom + ",100000000000" + mocks.USDTBaseDenom

GaiaChainID = "test-gaia-chain"
)

var (
// Initial coins to give to validators
valCoins = sdk.NewCoins(
coin.New(appparams.BondDenom, 1_000000_000000),
coin.New(PhotonDenom, 1_000000_000000),
coin.New(mocks.USDTBaseDenom, 1_000000_000000),
)

minGasPrice = appparams.ProtocolMinGasPrice.String()

// TODO: stake less on the validators, and instead delegate from a non-validator account
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *E2ETestSuite) initNodes() {
valAddr, err := val.KeyInfo.GetAddress()
s.Require().NoError(err)
s.Require().NoError(
addGenesisAccount(s.cdc, val0ConfigDir, "", InitBalanceStr, valAddr),
addGenesisAccount(s.cdc, val0ConfigDir, "", valCoins, valAddr),
)
}

Expand Down

0 comments on commit bdc0d24

Please sign in to comment.