Skip to content

Commit

Permalink
get the tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jtremback committed Nov 5, 2021
1 parent 5781564 commit afe3c95
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
7 changes: 7 additions & 0 deletions x/distribution/keeper/hooks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package keeper

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down Expand Up @@ -119,3 +121,8 @@ func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _
func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error {
return nil
}
func (h Hooks) UnbondingDelegationEntryCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress, _ int64, _ time.Time, _ sdk.Int, _ uint64) {
}
func (h Hooks) BeforeUnbondingDelegationEntryComplete(_ sdk.Context, _ uint64) bool {
return false
}
5 changes: 5 additions & 0 deletions x/slashing/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ func (h Hooks) AfterDelegationModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.Va
return nil
}
func (h Hooks) BeforeValidatorSlashed(_ sdk.Context, _ sdk.ValAddress, _ sdk.Dec) error { return nil }
func (h Hooks) UnbondingDelegationEntryCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress, _ int64, _ time.Time, _ sdk.Int, _ uint64) {
}
func (h Hooks) BeforeUnbondingDelegationEntryComplete(_ sdk.Context, _ uint64) bool {
return false
}
1 change: 1 addition & 0 deletions x/staking/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func TestUnbondingDelegation(t *testing.T) {
0,
time.Unix(0, 0).UTC(),
sdk.NewInt(5),
app.StakingKeeper.IncrementUnbondingDelegationEntryId(ctx),
)

// set and retrieve a record
Expand Down
6 changes: 3 additions & 3 deletions x/staking/keeper/slash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestSlashUnbondingDelegation(t *testing.T) {
// set an unbonding delegation with expiration timestamp (beyond which the
// unbonding delegation shouldn't be slashed)
ubd := types.NewUnbondingDelegation(addrDels[0], addrVals[0], 0,
time.Unix(5, 0), sdk.NewInt(10))
time.Unix(5, 0), sdk.NewInt(10), app.StakingKeeper.IncrementUnbondingDelegationEntryId(ctx))

app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)

Expand Down Expand Up @@ -265,7 +265,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
// set an unbonding delegation with expiration timestamp beyond which the
// unbonding delegation shouldn't be slashed
ubdTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 4)
ubd := types.NewUnbondingDelegation(addrDels[0], addrVals[0], 11, time.Unix(0, 0), ubdTokens)
ubd := types.NewUnbondingDelegation(addrDels[0], addrVals[0], 11, time.Unix(0, 0), ubdTokens, app.StakingKeeper.IncrementUnbondingDelegationEntryId(ctx))
app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)

// slash validator for the first time
Expand Down Expand Up @@ -556,7 +556,7 @@ func TestSlashBoth(t *testing.T) {
// unbonding delegation shouldn't be slashed)
ubdATokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 4)
ubdA := types.NewUnbondingDelegation(addrDels[0], addrVals[0], 11,
time.Unix(0, 0), ubdATokens)
time.Unix(0, 0), ubdATokens, app.StakingKeeper.IncrementUnbondingDelegationEntryId(ctx))
app.StakingKeeper.SetUnbondingDelegation(ctx, ubdA)

bondedCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, rdATokens.MulRaw(2)))
Expand Down
2 changes: 1 addition & 1 deletion x/staking/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestDecodeStore(t *testing.T) {
val, err := types.NewValidator(valAddr1, delPk1, types.NewDescription("test", "test", "test", "test", "test"))
require.NoError(t, err)
del := types.NewDelegation(delAddr1, valAddr1, sdk.OneDec())
ubd := types.NewUnbondingDelegation(delAddr1, valAddr1, 15, bondTime, sdk.OneInt())
ubd := types.NewUnbondingDelegation(delAddr1, valAddr1, 15, bondTime, sdk.OneInt(), 1)
red := types.NewRedelegation(delAddr1, valAddr1, valAddr1, 12, bondTime, sdk.OneInt(), sdk.OneDec())

kvPairs := kv.Pairs{
Expand Down
4 changes: 2 additions & 2 deletions x/staking/types/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestDelegationString(t *testing.T) {

func TestUnbondingDelegationEqual(t *testing.T) {
ubd1 := types.NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0,
time.Unix(0, 0), sdk.NewInt(0))
time.Unix(0, 0), sdk.NewInt(0), 1)
ubd2 := ubd1

ok := ubd1.String() == ubd2.String()
Expand All @@ -48,7 +48,7 @@ func TestUnbondingDelegationEqual(t *testing.T) {

func TestUnbondingDelegationString(t *testing.T) {
ubd := types.NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0,
time.Unix(0, 0), sdk.NewInt(0))
time.Unix(0, 0), sdk.NewInt(0), 1)

require.NotEmpty(t, ubd.String())
}
Expand Down

0 comments on commit afe3c95

Please sign in to comment.