Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: launch rc jae #3736

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
jaekwon committed Feb 22, 2019
commit 066e11f190b3a0a4677d24b8faee2a9b2713caaf
9 changes: 6 additions & 3 deletions x/bank/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ func (msg MsgSend) ValidateBasic() sdk.Error {
return sdk.ErrInvalidAddress("missing recipient address")
}
if !msg.Amount.IsValid() {
return sdk.ErrInvalidCoins(msg.Amount.String())
return sdk.ErrInvalidCoins("send amount is invalid: " + msg.Amount.String())
}
if !msg.Amount.IsAllPositive() {
return sdk.ErrInsufficientCoins("send amount must be positive")
}
return nil
}
Expand Down Expand Up @@ -112,7 +115,7 @@ func (in Input) ValidateBasic() sdk.Error {
if !in.Coins.IsValid() {
return sdk.ErrInvalidCoins(in.Coins.String())
}
if !in.Coins.IsValid() {
if !in.Coins.IsAllPositive() {
return sdk.ErrInvalidCoins(in.Coins.String())
}
return nil
Expand Down Expand Up @@ -140,7 +143,7 @@ func (out Output) ValidateBasic() sdk.Error {
if !out.Coins.IsValid() {
return sdk.ErrInvalidCoins(out.Coins.String())
}
if !out.Coins.IsValid() {
if !out.Coins.IsAllPositive() {
return sdk.ErrInvalidCoins(out.Coins.String())
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions x/staking/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func TestUnbondDelegation(t *testing.T) {
}

func TestUnbondingDelegationsMaxEntries(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)
pool := keeper.GetPool(ctx)
startTokens := sdk.TokensFromTendermintPower(10)
pool.NotBondedTokens = startTokens
Expand Down Expand Up @@ -372,7 +372,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) {
}

func TestUndelegateFromUnbondedValidator(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)
pool := keeper.GetPool(ctx)
startTokens := sdk.TokensFromTendermintPower(20)
pool.NotBondedTokens = startTokens
Expand Down
4 changes: 2 additions & 2 deletions x/staking/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func TestPool(t *testing.T) {

//check that the empty keeper loads the default
resPool := keeper.GetPool(ctx)
require.True(t, expPool.Equal(resPool))
require.Equal(t, expPool, resPool)

//modify a params, save, and retrieve
expPool.BondedTokens = sdk.NewInt(777)
keeper.SetPool(ctx, expPool)
resPool = keeper.GetPool(ctx)
require.True(t, expPool.Equal(resPool))
require.Equal(t, expPool, resPool)
}
9 changes: 6 additions & 3 deletions x/staking/keeper/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context
// fill all the addresses with some coins, set the loose pool tokens simultaneously
for _, addr := range Addrs {
pool := keeper.GetPool(ctx)
_, _, err := ck.AddCoins(ctx, addr, sdk.Coins{
{keeper.BondDenom(ctx), initCoins},
})
err := error(nil)
if !initCoins.IsZero() {
_, _, err = ck.AddCoins(ctx, addr, sdk.Coins{
{keeper.BondDenom(ctx), initCoins},
})
}
require.Nil(t, err)
pool.NotBondedTokens = pool.NotBondedTokens.Add(initCoins)
keeper.SetPool(ctx, pool)
Expand Down