Skip to content

Commit 2f9a0da

Browse files
committed
Fix tests
1 parent b7d1d69 commit 2f9a0da

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ test_ledger:
152152
@go test -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger'
153153

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

157157
test_race:
158158
@VERSION=$(VERSION) go test -race $(PACKAGES_NOSIMULATION)

x/bank/msgs.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ func (msg MsgSend) ValidateBasic() sdk.Error {
3636
return sdk.ErrInvalidAddress("missing recipient address")
3737
}
3838
if !msg.Amount.IsValid() {
39-
return sdk.ErrInvalidCoins(msg.Amount.String())
39+
return sdk.ErrInvalidCoins("send amount is invalid: " + msg.Amount.String())
40+
}
41+
if !msg.Amount.IsAllPositive() {
42+
return sdk.ErrInsufficientCoins("send amount must be positive")
4043
}
4144
return nil
4245
}
@@ -112,7 +115,7 @@ func (in Input) ValidateBasic() sdk.Error {
112115
if !in.Coins.IsValid() {
113116
return sdk.ErrInvalidCoins(in.Coins.String())
114117
}
115-
if !in.Coins.IsValid() {
118+
if !in.Coins.IsAllPositive() {
116119
return sdk.ErrInvalidCoins(in.Coins.String())
117120
}
118121
return nil
@@ -140,7 +143,7 @@ func (out Output) ValidateBasic() sdk.Error {
140143
if !out.Coins.IsValid() {
141144
return sdk.ErrInvalidCoins(out.Coins.String())
142145
}
143-
if !out.Coins.IsValid() {
146+
if !out.Coins.IsAllPositive() {
144147
return sdk.ErrInvalidCoins(out.Coins.String())
145148
}
146149
return nil

x/staking/keeper/delegation_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestDelegation(t *testing.T) {
130130

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

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

171171
func TestUnbondDelegation(t *testing.T) {
172-
ctx, _, keeper := CreateTestInput(t, false, 0)
172+
ctx, _, keeper := CreateTestInput(t, false, 1)
173173
pool := keeper.GetPool(ctx)
174174
startTokens := sdk.TokensFromTendermintPower(10)
175175
pool.NotBondedTokens = startTokens
@@ -207,7 +207,7 @@ func TestUnbondDelegation(t *testing.T) {
207207
}
208208

209209
func TestUnbondingDelegationsMaxEntries(t *testing.T) {
210-
ctx, _, keeper := CreateTestInput(t, false, 0)
210+
ctx, _, keeper := CreateTestInput(t, false, 1)
211211
pool := keeper.GetPool(ctx)
212212
startTokens := sdk.TokensFromTendermintPower(10)
213213
pool.NotBondedTokens = startTokens
@@ -254,7 +254,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) {
254254
// shift it from the bonded to unbonding state and jailed
255255
func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) {
256256

257-
ctx, _, keeper := CreateTestInput(t, false, 0)
257+
ctx, _, keeper := CreateTestInput(t, false, 1)
258258
pool := keeper.GetPool(ctx)
259259
startTokens := sdk.TokensFromTendermintPower(20)
260260
pool.NotBondedTokens = startTokens
@@ -300,7 +300,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) {
300300
}
301301

302302
func TestUndelegateFromUnbondingValidator(t *testing.T) {
303-
ctx, _, keeper := CreateTestInput(t, false, 0)
303+
ctx, _, keeper := CreateTestInput(t, false, 1)
304304
pool := keeper.GetPool(ctx)
305305
startTokens := sdk.TokensFromTendermintPower(20)
306306
pool.NotBondedTokens = startTokens
@@ -372,7 +372,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) {
372372
}
373373

374374
func TestUndelegateFromUnbondedValidator(t *testing.T) {
375-
ctx, _, keeper := CreateTestInput(t, false, 0)
375+
ctx, _, keeper := CreateTestInput(t, false, 1)
376376
pool := keeper.GetPool(ctx)
377377
startTokens := sdk.TokensFromTendermintPower(20)
378378
pool.NotBondedTokens = startTokens
@@ -447,7 +447,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) {
447447
}
448448

449449
func TestUnbondingAllDelegationFromValidator(t *testing.T) {
450-
ctx, _, keeper := CreateTestInput(t, false, 0)
450+
ctx, _, keeper := CreateTestInput(t, false, 1)
451451
pool := keeper.GetPool(ctx)
452452
startTokens := sdk.TokensFromTendermintPower(20)
453453
pool.NotBondedTokens = startTokens
@@ -507,7 +507,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) {
507507

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

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

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

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

593593
func TestRedelegateToSameValidator(t *testing.T) {
594-
ctx, _, keeper := CreateTestInput(t, false, 0)
594+
ctx, _, keeper := CreateTestInput(t, false, 1)
595595
pool := keeper.GetPool(ctx)
596596
startTokens := sdk.TokensFromTendermintPower(30)
597597
pool.NotBondedTokens = startTokens
@@ -614,7 +614,7 @@ func TestRedelegateToSameValidator(t *testing.T) {
614614
}
615615

616616
func TestRedelegationMaxEntries(t *testing.T) {
617-
ctx, _, keeper := CreateTestInput(t, false, 0)
617+
ctx, _, keeper := CreateTestInput(t, false, 1)
618618
pool := keeper.GetPool(ctx)
619619
startTokens := sdk.TokensFromTendermintPower(20)
620620
pool.NotBondedTokens = startTokens
@@ -665,7 +665,7 @@ func TestRedelegationMaxEntries(t *testing.T) {
665665
}
666666

667667
func TestRedelegateSelfDelegation(t *testing.T) {
668-
ctx, _, keeper := CreateTestInput(t, false, 0)
668+
ctx, _, keeper := CreateTestInput(t, false, 1)
669669
pool := keeper.GetPool(ctx)
670670
startTokens := sdk.TokensFromTendermintPower(30)
671671
pool.NotBondedTokens = startTokens
@@ -716,7 +716,7 @@ func TestRedelegateSelfDelegation(t *testing.T) {
716716
}
717717

718718
func TestRedelegateFromUnbondingValidator(t *testing.T) {
719-
ctx, _, keeper := CreateTestInput(t, false, 0)
719+
ctx, _, keeper := CreateTestInput(t, false, 1)
720720
pool := keeper.GetPool(ctx)
721721
startTokens := sdk.TokensFromTendermintPower(30)
722722
pool.NotBondedTokens = startTokens
@@ -795,7 +795,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) {
795795
}
796796

797797
func TestRedelegateFromUnbondedValidator(t *testing.T) {
798-
ctx, _, keeper := CreateTestInput(t, false, 0)
798+
ctx, _, keeper := CreateTestInput(t, false, 1)
799799
pool := keeper.GetPool(ctx)
800800
startTokens := sdk.TokensFromTendermintPower(30)
801801
pool.NotBondedTokens = startTokens

x/staking/keeper/keeper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func TestParams(t *testing.T) {
13-
ctx, _, keeper := CreateTestInput(t, false, 0)
13+
ctx, _, keeper := CreateTestInput(t, false, 1)
1414
expParams := types.DefaultParams()
1515

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

2727
func TestPool(t *testing.T) {
28-
ctx, _, keeper := CreateTestInput(t, false, 0)
28+
ctx, _, keeper := CreateTestInput(t, false, 1)
2929
expPool := types.InitialPool()
3030

3131
//check that the empty keeper loads the default

x/staking/keeper/validator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestSetValidator(t *testing.T) {
7272
}
7373

7474
func TestUpdateValidatorByPowerIndex(t *testing.T) {
75-
ctx, _, keeper := CreateTestInput(t, false, 0)
75+
ctx, _, keeper := CreateTestInput(t, false, 1)
7676
pool := keeper.GetPool(ctx)
7777

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

117117
// create context, keeper, and pool for tests
118-
ctx, _, keeper := CreateTestInput(t, false, 0)
118+
ctx, _, keeper := CreateTestInput(t, false, 1)
119119
pool := keeper.GetPool(ctx)
120120

121121
// create keeper parameters

0 commit comments

Comments
 (0)