Merge PR #3621: module inter-dependency cleanup
This commit is contained in:
committed by
Jack Zampolin
parent
dafe0acf4f
commit
d66db6a772
+35
-35
@@ -40,7 +40,7 @@ const (
|
||||
altPw = "12345678901"
|
||||
)
|
||||
|
||||
var fees = sdk.Coins{sdk.NewInt64Coin(staking.DefaultBondDenom, 5)}
|
||||
var fees = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)}
|
||||
|
||||
func init() {
|
||||
mintkey.BcryptSecurityParameter = 1
|
||||
@@ -243,14 +243,14 @@ func TestCoinSend(t *testing.T) {
|
||||
coins := acc.GetCoins()
|
||||
expectedBalance := initialBalance[0].Minus(fees[0])
|
||||
|
||||
require.Equal(t, staking.DefaultBondDenom, coins[0].Denom)
|
||||
require.Equal(t, sdk.DefaultBondDenom, coins[0].Denom)
|
||||
require.Equal(t, expectedBalance.Amount.SubRaw(1), coins[0].Amount)
|
||||
expectedBalance = coins[0]
|
||||
|
||||
// query receiver
|
||||
acc2 := getAccount(t, port, receiveAddr)
|
||||
coins2 := acc2.GetCoins()
|
||||
require.Equal(t, staking.DefaultBondDenom, coins2[0].Denom)
|
||||
require.Equal(t, sdk.DefaultBondDenom, coins2[0].Denom)
|
||||
require.Equal(t, int64(1), coins2[0].Amount.Int64())
|
||||
|
||||
// test failure with too little gas
|
||||
@@ -286,7 +286,7 @@ func TestCoinSend(t *testing.T) {
|
||||
require.NotZero(t, gasEstResp.GasEstimate)
|
||||
|
||||
acc = getAccount(t, port, addr)
|
||||
require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
|
||||
|
||||
// run successful tx
|
||||
gas := fmt.Sprintf("%d", gasEstResp.GasEstimate)
|
||||
@@ -301,7 +301,7 @@ func TestCoinSend(t *testing.T) {
|
||||
|
||||
acc = getAccount(t, port, addr)
|
||||
expectedBalance = expectedBalance.Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount.SubRaw(1), acc.GetCoins().AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount.SubRaw(1), acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
|
||||
}
|
||||
|
||||
func TestCoinSendAccAuto(t *testing.T) {
|
||||
@@ -323,7 +323,7 @@ func TestCoinSendAccAuto(t *testing.T) {
|
||||
coins := acc.GetCoins()
|
||||
expectedBalance := initialBalance[0].Minus(fees[0])
|
||||
|
||||
require.Equal(t, staking.DefaultBondDenom, coins[0].Denom)
|
||||
require.Equal(t, sdk.DefaultBondDenom, coins[0].Denom)
|
||||
require.Equal(t, expectedBalance.Amount.SubRaw(1), coins[0].Amount)
|
||||
}
|
||||
|
||||
@@ -520,11 +520,11 @@ func TestPoolParamsQuery(t *testing.T) {
|
||||
pool := getStakingPool(t, port)
|
||||
|
||||
initialPool := staking.InitialPool()
|
||||
tokens := staking.TokensFromTendermintPower(100)
|
||||
freeFermions := staking.TokensFromTendermintPower(50)
|
||||
tokens := sdk.TokensFromTendermintPower(100)
|
||||
freeTokens := sdk.TokensFromTendermintPower(50)
|
||||
initialPool.NotBondedTokens = initialPool.NotBondedTokens.Add(tokens)
|
||||
initialPool.BondedTokens = initialPool.BondedTokens.Add(tokens) // Delegate tx on GaiaAppGenState
|
||||
initialPool.NotBondedTokens = initialPool.NotBondedTokens.Add(freeFermions) // freeFermionsAcc = 50 on GaiaAppGenState
|
||||
initialPool.BondedTokens = initialPool.BondedTokens.Add(tokens) // Delegate tx on GaiaAppGenState
|
||||
initialPool.NotBondedTokens = initialPool.NotBondedTokens.Add(freeTokens) // freeTokensPerAcc = 50 on GaiaAppGenState
|
||||
|
||||
require.Equal(t, initialPool.BondedTokens, pool.BondedTokens)
|
||||
|
||||
@@ -575,7 +575,7 @@ func TestBonding(t *testing.T) {
|
||||
require.Equal(t, 2, len(valPubKeys))
|
||||
require.Equal(t, 2, len(operAddrs))
|
||||
|
||||
amt := staking.TokensFromTendermintPower(60)
|
||||
amt := sdk.TokensFromTendermintPower(60)
|
||||
amtDec := sdk.NewDecFromInt(amt)
|
||||
validator := getValidator(t, port, operAddrs[0])
|
||||
|
||||
@@ -583,7 +583,7 @@ func TestBonding(t *testing.T) {
|
||||
initialBalance := acc.GetCoins()
|
||||
|
||||
// create bond TX
|
||||
delTokens := staking.TokensFromTendermintPower(60)
|
||||
delTokens := sdk.TokensFromTendermintPower(60)
|
||||
resultTx := doDelegate(t, port, name1, pw, addr, operAddrs[0], delTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
@@ -601,7 +601,7 @@ func TestBonding(t *testing.T) {
|
||||
acc = getAccount(t, port, addr)
|
||||
coins := acc.GetCoins()
|
||||
expectedBalance := initialBalance[0].Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount.Sub(delTokens), coins.AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount.Sub(delTokens), coins.AmountOf(sdk.DefaultBondDenom))
|
||||
expectedBalance = coins[0]
|
||||
|
||||
// query delegation
|
||||
@@ -625,7 +625,7 @@ func TestBonding(t *testing.T) {
|
||||
require.Equal(t, operAddrs[0], bondedValidator.OperatorAddr)
|
||||
|
||||
// testing unbonding
|
||||
unbondingTokens := staking.TokensFromTendermintPower(30)
|
||||
unbondingTokens := sdk.TokensFromTendermintPower(30)
|
||||
resultTx = doUndelegate(t, port, name1, pw, addr, operAddrs[0], unbondingTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
@@ -636,8 +636,8 @@ func TestBonding(t *testing.T) {
|
||||
coins = acc.GetCoins()
|
||||
expectedBalance = expectedBalance.Minus(fees[0])
|
||||
require.True(t,
|
||||
expectedBalance.Amount.LT(coins.AmountOf(staking.DefaultBondDenom)) ||
|
||||
expectedBalance.Amount.Equal(coins.AmountOf(staking.DefaultBondDenom)),
|
||||
expectedBalance.Amount.LT(coins.AmountOf(sdk.DefaultBondDenom)) ||
|
||||
expectedBalance.Amount.Equal(coins.AmountOf(sdk.DefaultBondDenom)),
|
||||
"should get tokens back from automatic withdrawal after an unbonding delegation",
|
||||
)
|
||||
expectedBalance = coins[0]
|
||||
@@ -655,7 +655,7 @@ func TestBonding(t *testing.T) {
|
||||
require.Equal(t, delTokens.DivRaw(2), ubd.Entries[0].Balance)
|
||||
|
||||
// test redelegation
|
||||
rdTokens := staking.TokensFromTendermintPower(30)
|
||||
rdTokens := sdk.TokensFromTendermintPower(30)
|
||||
resultTx = doBeginRedelegation(t, port, name1, pw, addr, operAddrs[0], operAddrs[1], rdTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
@@ -665,8 +665,8 @@ func TestBonding(t *testing.T) {
|
||||
acc = getAccount(t, port, addr)
|
||||
expectedBalance = expectedBalance.Minus(fees[0])
|
||||
require.True(t,
|
||||
expectedBalance.Amount.LT(coins.AmountOf(staking.DefaultBondDenom)) ||
|
||||
expectedBalance.Amount.Equal(coins.AmountOf(staking.DefaultBondDenom)),
|
||||
expectedBalance.Amount.LT(coins.AmountOf(sdk.DefaultBondDenom)) ||
|
||||
expectedBalance.Amount.Equal(coins.AmountOf(sdk.DefaultBondDenom)),
|
||||
"should get tokens back from automatic withdrawal after an unbonding delegation",
|
||||
)
|
||||
|
||||
@@ -735,7 +735,7 @@ func TestSubmitProposal(t *testing.T) {
|
||||
initialBalance := acc.GetCoins()
|
||||
|
||||
// create SubmitProposal TX
|
||||
proposalTokens := staking.TokensFromTendermintPower(5)
|
||||
proposalTokens := sdk.TokensFromTendermintPower(5)
|
||||
resultTx := doSubmitProposal(t, port, seed, name1, pw, addr, proposalTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
@@ -748,7 +748,7 @@ func TestSubmitProposal(t *testing.T) {
|
||||
// verify balance
|
||||
acc = getAccount(t, port, addr)
|
||||
expectedBalance := initialBalance[0].Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), acc.GetCoins().AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
|
||||
|
||||
// query proposal
|
||||
proposal := getProposal(t, port, proposalID)
|
||||
@@ -770,7 +770,7 @@ func TestDeposit(t *testing.T) {
|
||||
initialBalance := acc.GetCoins()
|
||||
|
||||
// create SubmitProposal TX
|
||||
proposalTokens := staking.TokensFromTendermintPower(5)
|
||||
proposalTokens := sdk.TokensFromTendermintPower(5)
|
||||
resultTx := doSubmitProposal(t, port, seed, name1, pw, addr, proposalTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
@@ -784,7 +784,7 @@ func TestDeposit(t *testing.T) {
|
||||
acc = getAccount(t, port, addr)
|
||||
coins := acc.GetCoins()
|
||||
expectedBalance := initialBalance[0].Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), coins.AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), coins.AmountOf(sdk.DefaultBondDenom))
|
||||
expectedBalance = coins[0]
|
||||
|
||||
// query proposal
|
||||
@@ -792,14 +792,14 @@ func TestDeposit(t *testing.T) {
|
||||
require.Equal(t, "Test", proposal.GetTitle())
|
||||
|
||||
// create SubmitProposal TX
|
||||
depositTokens := staking.TokensFromTendermintPower(5)
|
||||
depositTokens := sdk.TokensFromTendermintPower(5)
|
||||
resultTx = doDeposit(t, port, seed, name1, pw, addr, proposalID, depositTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// verify balance after deposit and fee
|
||||
acc = getAccount(t, port, addr)
|
||||
expectedBalance = expectedBalance.Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount.Sub(depositTokens), acc.GetCoins().AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount.Sub(depositTokens), acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
|
||||
|
||||
// query tx
|
||||
txs := getTransactions(t, port, fmt.Sprintf("action=deposit&depositor=%s", addr))
|
||||
@@ -807,7 +807,7 @@ func TestDeposit(t *testing.T) {
|
||||
require.Equal(t, resultTx.Height, txs[0].Height)
|
||||
|
||||
// query proposal
|
||||
totalCoins := sdk.Coins{sdk.NewCoin(staking.DefaultBondDenom, staking.TokensFromTendermintPower(10))}
|
||||
totalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(10))}
|
||||
proposal = getProposal(t, port, proposalID)
|
||||
require.True(t, proposal.GetTotalDeposit().IsEqual(totalCoins))
|
||||
|
||||
@@ -827,7 +827,7 @@ func TestVote(t *testing.T) {
|
||||
initialBalance := acc.GetCoins()
|
||||
|
||||
// create SubmitProposal TX
|
||||
proposalTokens := staking.TokensFromTendermintPower(10)
|
||||
proposalTokens := sdk.TokensFromTendermintPower(10)
|
||||
resultTx := doSubmitProposal(t, port, seed, name1, pw, addr, proposalTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
@@ -841,7 +841,7 @@ func TestVote(t *testing.T) {
|
||||
acc = getAccount(t, port, addr)
|
||||
coins := acc.GetCoins()
|
||||
expectedBalance := initialBalance[0].Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), coins.AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount.Sub(proposalTokens), coins.AmountOf(sdk.DefaultBondDenom))
|
||||
expectedBalance = coins[0]
|
||||
|
||||
// query proposal
|
||||
@@ -857,7 +857,7 @@ func TestVote(t *testing.T) {
|
||||
acc = getAccount(t, port, addr)
|
||||
coins = acc.GetCoins()
|
||||
expectedBalance = expectedBalance.Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount, coins.AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount, coins.AmountOf(sdk.DefaultBondDenom))
|
||||
expectedBalance = coins[0]
|
||||
|
||||
// query tx
|
||||
@@ -873,7 +873,7 @@ func TestVote(t *testing.T) {
|
||||
require.Equal(t, sdk.ZeroInt(), tally.Yes, "tally should be 0 as the address is not bonded")
|
||||
|
||||
// create bond TX
|
||||
delTokens := staking.TokensFromTendermintPower(60)
|
||||
delTokens := sdk.TokensFromTendermintPower(60)
|
||||
resultTx = doDelegate(t, port, name1, pw, addr, operAddrs[0], delTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
@@ -881,7 +881,7 @@ func TestVote(t *testing.T) {
|
||||
acc = getAccount(t, port, addr)
|
||||
coins = acc.GetCoins()
|
||||
expectedBalance = expectedBalance.Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount.Sub(delTokens), coins.AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount.Sub(delTokens), coins.AmountOf(sdk.DefaultBondDenom))
|
||||
expectedBalance = coins[0]
|
||||
|
||||
tally = getTally(t, port, proposalID)
|
||||
@@ -894,7 +894,7 @@ func TestVote(t *testing.T) {
|
||||
// verify balance
|
||||
acc = getAccount(t, port, addr)
|
||||
expectedBalance = expectedBalance.Minus(fees[0])
|
||||
require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(staking.DefaultBondDenom))
|
||||
require.Equal(t, expectedBalance.Amount, acc.GetCoins().AmountOf(sdk.DefaultBondDenom))
|
||||
|
||||
tally = getTally(t, port, proposalID)
|
||||
require.Equal(t, sdk.ZeroInt(), tally.Yes, "tally should be 0 the user changed the option")
|
||||
@@ -927,7 +927,7 @@ func TestProposalsQuery(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
depositParam := getDepositParam(t, port)
|
||||
halfMinDeposit := depositParam.MinDeposit.AmountOf(staking.DefaultBondDenom).DivRaw(2)
|
||||
halfMinDeposit := depositParam.MinDeposit.AmountOf(sdk.DefaultBondDenom).DivRaw(2)
|
||||
getVotingParam(t, port)
|
||||
getTallyingParam(t, port)
|
||||
|
||||
@@ -974,7 +974,7 @@ func TestProposalsQuery(t *testing.T) {
|
||||
require.Equal(t, deposit, deposits[0])
|
||||
|
||||
// increasing the amount of the deposit should update the existing one
|
||||
depositTokens := staking.TokensFromTendermintPower(1)
|
||||
depositTokens := sdk.TokensFromTendermintPower(1)
|
||||
resultTx = doDeposit(t, port, seeds[0], names[0], passwords[0], addrs[0], proposalID1, depositTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
@@ -1085,7 +1085,7 @@ func TestDistributionFlow(t *testing.T) {
|
||||
require.Equal(t, valDistInfo.OperatorAddress.String(), sdk.AccAddress(valAddr).String())
|
||||
|
||||
// Delegate some coins
|
||||
delTokens := staking.TokensFromTendermintPower(60)
|
||||
delTokens := sdk.TokensFromTendermintPower(60)
|
||||
resultTx := doDelegate(t, port, name1, pw, addr, valAddr, delTokens, fees)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
require.Equal(t, uint32(0), resultTx.Code)
|
||||
|
||||
+11
-11
@@ -230,12 +230,12 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress
|
||||
pubKey = ed25519.GenPrivKey().PubKey()
|
||||
power = 1
|
||||
}
|
||||
startTokens := staking.TokensFromTendermintPower(power)
|
||||
startTokens := sdk.TokensFromTendermintPower(power)
|
||||
|
||||
msg := staking.NewMsgCreateValidator(
|
||||
sdk.ValAddress(operAddr),
|
||||
pubKey,
|
||||
sdk.NewCoin(staking.DefaultBondDenom, startTokens),
|
||||
sdk.NewCoin(sdk.DefaultBondDenom, startTokens),
|
||||
staking.NewDescription(fmt.Sprintf("validator-%d", i+1), "", "", ""),
|
||||
staking.NewCommissionMsg(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
|
||||
sdk.OneInt(),
|
||||
@@ -255,8 +255,8 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress
|
||||
valOperAddrs = append(valOperAddrs, sdk.ValAddress(operAddr))
|
||||
|
||||
accAuth := auth.NewBaseAccountWithAddress(sdk.AccAddress(operAddr))
|
||||
accTokens := staking.TokensFromTendermintPower(150)
|
||||
accAuth.Coins = sdk.Coins{sdk.NewCoin(staking.DefaultBondDenom, accTokens)}
|
||||
accTokens := sdk.TokensFromTendermintPower(150)
|
||||
accAuth.Coins = sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, accTokens)}
|
||||
accs = append(accs, gapp.NewGenesisAccount(&accAuth))
|
||||
}
|
||||
|
||||
@@ -270,8 +270,8 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress
|
||||
// add some tokens to init accounts
|
||||
for _, addr := range initAddrs {
|
||||
accAuth := auth.NewBaseAccountWithAddress(addr)
|
||||
accTokens := staking.TokensFromTendermintPower(100)
|
||||
accAuth.Coins = sdk.Coins{sdk.NewCoin(staking.DefaultBondDenom, accTokens)}
|
||||
accTokens := sdk.TokensFromTendermintPower(100)
|
||||
accAuth.Coins = sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, accTokens)}
|
||||
acc := gapp.NewGenesisAccount(&accAuth)
|
||||
genesisState.Accounts = append(genesisState.Accounts, acc)
|
||||
genesisState.StakingData.Pool.NotBondedTokens = genesisState.StakingData.Pool.NotBondedTokens.Add(accTokens)
|
||||
@@ -707,7 +707,7 @@ func doTransferWithGas(
|
||||
)
|
||||
|
||||
sr := rest.SendReq{
|
||||
Amount: sdk.Coins{sdk.NewInt64Coin(staking.DefaultBondDenom, 1)},
|
||||
Amount: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)},
|
||||
BaseReq: baseReq,
|
||||
}
|
||||
|
||||
@@ -740,7 +740,7 @@ func doTransferWithGasAccAuto(
|
||||
)
|
||||
|
||||
sr := rest.SendReq{
|
||||
Amount: sdk.Coins{sdk.NewInt64Coin(staking.DefaultBondDenom, 1)},
|
||||
Amount: sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)},
|
||||
BaseReq: baseReq,
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ func doDelegate(t *testing.T, port, name, password string,
|
||||
BaseReq: baseReq,
|
||||
DelegatorAddr: delAddr,
|
||||
ValidatorAddr: valAddr,
|
||||
Delegation: sdk.NewCoin(staking.DefaultBondDenom, amount),
|
||||
Delegation: sdk.NewCoin(sdk.DefaultBondDenom, amount),
|
||||
}
|
||||
req, err := cdc.MarshalJSON(msg)
|
||||
require.NoError(t, err)
|
||||
@@ -1079,7 +1079,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA
|
||||
Description: "test",
|
||||
ProposalType: "Text",
|
||||
Proposer: proposerAddr,
|
||||
InitialDeposit: sdk.Coins{sdk.NewCoin(staking.DefaultBondDenom, amount)},
|
||||
InitialDeposit: sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, amount)},
|
||||
BaseReq: baseReq,
|
||||
}
|
||||
|
||||
@@ -1173,7 +1173,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk
|
||||
|
||||
dr := rest.DepositReq{
|
||||
Depositor: proposerAddr,
|
||||
Amount: sdk.Coins{sdk.NewCoin(staking.DefaultBondDenom, amount)},
|
||||
Amount: sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, amount)},
|
||||
BaseReq: baseReq,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user