Skip to content

Commit

Permalink
fix!: address minor bugs during main upgrade to SDK v50 (#2067)
Browse files Browse the repository at this point in the history
* fix consumer misb e2e test and mistakenly removed line during main upgrade to v50

* update UT

* godoc
  • Loading branch information
sainoe committed Jul 19, 2024
1 parent 9bdc104 commit 5c65a15
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ func ConsumerMisbehaviourTestConfig() TestConfig {
IpPrefix: "7.7.7",
VotingWaitTime: 20,
GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ func (tr Commands) GetClientFrozenHeight(chain ChainID, clientID string) (uint64
log.Fatal(err, "\n", string(bz))
}

return uint64(revHeight), uint64(revNumber)
return uint64(revNumber), uint64(revHeight)
}

func (tr Commands) GetHasToValidate(
Expand Down
1 change: 1 addition & 0 deletions testutil/keeper/unit_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk
require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &expectedChainID))
require.Empty(t, providerKeeper.GetAllConsumerAddrsToPrune(ctx, expectedChainID))
require.Empty(t, providerKeeper.GetAllCommissionRateValidators(ctx, expectedChainID))
require.Zero(t, providerKeeper.GetEquivocationEvidenceMinHeight(ctx, expectedChainID))
}

func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal {
Expand Down
1 change: 1 addition & 0 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan boo
// Note: this call panics if the key assignment state is invalid
k.DeleteKeyAssignments(ctx, chainID)
k.DeleteMinimumPowerInTopN(ctx, chainID)
k.DeleteEquivocationEvidenceMinHeight(ctx, chainID)

// close channel and delete the mappings between chain ID and channel ID
if channelID, found := k.GetChainToChannel(ctx, chainID); found {
Expand Down
9 changes: 7 additions & 2 deletions x/ccv/provider/keeper/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ func TestStopConsumerChain(t *testing.T) {
expErr bool
}

consumerCID := "chainID"

tests := []testCase{
{
description: "proposal dropped, client doesn't exist",
Expand All @@ -407,6 +409,9 @@ func TestStopConsumerChain(t *testing.T) {
setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) {
testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks)

// set consumer minimum equivocation height
providerKeeper.SetEquivocationEvidenceMinHeight(ctx, consumerCID, 1)

// assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel
gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...)
},
Expand All @@ -424,15 +429,15 @@ func TestStopConsumerChain(t *testing.T) {
// Setup specific to test case
tc.setup(ctx, &providerKeeper, mocks)

err := providerKeeper.StopConsumerChain(ctx, "chainID", true)
err := providerKeeper.StopConsumerChain(ctx, consumerCID, true)

if tc.expErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}

testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "chainID", "channelID")
testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerCID, "channelID")

ctrl.Finish()
}
Expand Down

0 comments on commit 5c65a15

Please sign in to comment.