Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekwon committed Feb 22, 2019
1 parent b7d1d69 commit 2f9a0da
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ test_ledger:
@go test -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger'

test_unit:
@VERSION=$(VERSION) go test $(PACKAGES_NOSIMULATION) -tags='ledger test_ledger_mock'
@VERSION=$(VERSION) GOCACHE=off go test $(PACKAGES_NOSIMULATION) -tags='ledger test_ledger_mock'

test_race:
@VERSION=$(VERSION) go test -race $(PACKAGES_NOSIMULATION)
Expand Down
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
28 changes: 14 additions & 14 deletions x/staking/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestDelegation(t *testing.T) {

// tests Get/Set/Remove UnbondingDelegation
func TestUnbondingDelegation(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)

ubd := types.NewUnbondingDelegation(addrDels[0], addrVals[0], 0,
time.Unix(0, 0), sdk.NewInt(5))
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestUnbondingDelegation(t *testing.T) {
}

func TestUnbondDelegation(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 @@ -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 @@ -254,7 +254,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) {
// shift it from the bonded to unbonding state and jailed
func TestUndelegateSelfDelegationBelowMinSelfDelegation(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 Expand Up @@ -300,7 +300,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) {
}

func TestUndelegateFromUnbondingValidator(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 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 Expand Up @@ -447,7 +447,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) {
}

func TestUnbondingAllDelegationFromValidator(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 Expand Up @@ -507,7 +507,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) {

// Make sure that that the retrieving the delegations doesn't affect the state
func TestGetRedelegationsFromValidator(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)

rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0,
time.Unix(0, 0), sdk.NewInt(5),
Expand All @@ -531,7 +531,7 @@ func TestGetRedelegationsFromValidator(t *testing.T) {

// tests Get/Set/Remove/Has UnbondingDelegation
func TestRedelegation(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)

rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 0,
time.Unix(0, 0), sdk.NewInt(5),
Expand Down Expand Up @@ -591,7 +591,7 @@ func TestRedelegation(t *testing.T) {
}

func TestRedelegateToSameValidator(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)
pool := keeper.GetPool(ctx)
startTokens := sdk.TokensFromTendermintPower(30)
pool.NotBondedTokens = startTokens
Expand All @@ -614,7 +614,7 @@ func TestRedelegateToSameValidator(t *testing.T) {
}

func TestRedelegationMaxEntries(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 Expand Up @@ -665,7 +665,7 @@ func TestRedelegationMaxEntries(t *testing.T) {
}

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

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

func TestRedelegateFromUnbondedValidator(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)
pool := keeper.GetPool(ctx)
startTokens := sdk.TokensFromTendermintPower(30)
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 @@ -10,7 +10,7 @@ import (
)

func TestParams(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)
expParams := types.DefaultParams()

//check that the empty keeper loads the default
Expand All @@ -25,7 +25,7 @@ func TestParams(t *testing.T) {
}

func TestPool(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)
expPool := types.InitialPool()

//check that the empty keeper loads the default
Expand Down
4 changes: 2 additions & 2 deletions x/staking/keeper/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestSetValidator(t *testing.T) {
}

func TestUpdateValidatorByPowerIndex(t *testing.T) {
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)
pool := keeper.GetPool(ctx)

// create a random pool
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) {
maxVals := 5

// create context, keeper, and pool for tests
ctx, _, keeper := CreateTestInput(t, false, 0)
ctx, _, keeper := CreateTestInput(t, false, 1)
pool := keeper.GetPool(ctx)

// create keeper parameters
Expand Down

0 comments on commit 2f9a0da

Please sign in to comment.