Skip to content

Commit

Permalink
update UT
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Jul 19, 2024
1 parent 5a8caad commit 3a50539
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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
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 min 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 3a50539

Please sign in to comment.