Skip to content

Commit

Permalink
tests: fix broken unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Nov 27, 2023
1 parent 167a74d commit efc3f95
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions x/ccv/provider/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
k.SetPendingConsumerAdditionProp(ctx, &providertypes.ConsumerAdditionProposal{
ChainId: "chainid",
})
gomock.InOrder(
mocks.MockStakingKeeper.EXPECT().GetValidator(
ctx, providerCryptoId.SDKValOpAddress(),
Expand All @@ -64,11 +67,29 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
expError: false,
chainID: "chainid",
},
{
name: "fail: chain ID not registered",
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
gomock.InOrder(
mocks.MockStakingKeeper.EXPECT().GetValidator(
ctx, providerCryptoId.SDKValOpAddress(),
// Return a valid validator, found!
).Return(providerCryptoId.SDKStakingValidator(), true).Times(1),
)
},
expError: true,
chainID: "chainid",
},
{
name: "fail: missing validator",
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
k.SetPendingConsumerAdditionProp(ctx, &providertypes.ConsumerAdditionProposal{
ChainId: "chainid",
})
gomock.InOrder(
mocks.MockStakingKeeper.EXPECT().GetValidator(
ctx, providerCryptoId.SDKValOpAddress(),
Expand All @@ -84,6 +105,9 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) {
setup: func(ctx sdk.Context,
k keeper.Keeper, mocks testkeeper.MockedKeepers,
) {
k.SetPendingConsumerAdditionProp(ctx, &providertypes.ConsumerAdditionProposal{
ChainId: "chainid",
})
// Use the consumer key already
k.SetValidatorByConsumerAddr(ctx, "chainid", consumerConsAddr, providerConsAddr)

Expand Down
4 changes: 4 additions & 0 deletions x/ccv/provider/keeper/key_assignment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,10 @@ func TestCannotReassignDefaultKeyAssignment(t *testing.T) {
providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()

providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{
ChainId: "chain",
})

// Mock that the validator is validating with the single key, as confirmed by provider's staking keeper
gomock.InOrder(
mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx,
Expand Down

0 comments on commit efc3f95

Please sign in to comment.