Skip to content

Commit

Permalink
adapt unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Aug 30, 2024
1 parent bbbb2bf commit 2e93e21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions testutil/keeper/unit_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context,
// TestProviderStateIsCleanedAfterConsumerChainIsStopped executes test assertions for the provider's state being cleaned
// after a stopped consumer chain.
func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk.Context, providerKeeper providerkeeper.Keeper,
consumerId, expectedChannelID string,
consumerId, expectedChannelID string, expErr bool,
) {
t.Helper()
_, found := providerKeeper.GetConsumerClientId(ctx, consumerId)
Expand All @@ -262,8 +262,13 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk
require.Empty(t, acks)

// in case the chain was successfully stopped, it should not contain a Top N associated to it
_, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId)
require.Error(t, err)
ps, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId)
if expErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
require.Empty(t, ps)

// test key assignment state is cleaned
require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &consumerId))
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestStopConsumerChain(t *testing.T) {
require.NoError(t, err)
}

testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID")
testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID", tc.expErr)

ctrl.Finish()
}
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func TestOnTimeoutPacketStopsChain(t *testing.T) {
}
err := providerKeeper.OnTimeoutPacket(ctx, packet)

testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID")
testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID", false)
require.NoError(t, err)
}

Expand Down Expand Up @@ -578,7 +578,7 @@ func TestOnAcknowledgementPacketWithAckError(t *testing.T) {

err = providerKeeper.OnAcknowledgementPacket(ctx, packet, ackError)

testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID")
testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID", false)
require.NoError(t, err)
}

Expand Down

0 comments on commit 2e93e21

Please sign in to comment.