Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Sep 12, 2024
1 parent 75eaaac commit f01055b
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 142 deletions.
27 changes: 12 additions & 15 deletions testutil/keeper/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,18 @@ import (
func GetMocksForCreateConsumerClient(ctx sdk.Context, mocks *MockedKeepers,
expectedChainID string, expectedLatestHeight clienttypes.Height,
) []*gomock.Call {
// append MakeConsumerGenesis and CreateClient expectations
expectations := GetMocksForMakeConsumerGenesis(ctx, mocks, time.Hour)
createClientExp := mocks.MockClientKeeper.EXPECT().CreateClient(
gomock.Any(),
// Allows us to expect a match by field. These are the only two client state values
// that are dependent on parameters passed to CreateConsumerClient.
extra.StructMatcher().Field(
"ChainId", expectedChainID).Field(
"LatestHeight", expectedLatestHeight,
),
gomock.Any(),
).Return("clientID", nil).Times(1)
expectations = append(expectations, createClientExp)

return expectations
return []*gomock.Call{
mocks.MockClientKeeper.EXPECT().CreateClient(
gomock.Any(),
// Allows us to expect a match by field. These are the only two client state values
// that are dependent on parameters passed to CreateConsumerClient.
extra.StructMatcher().Field(
"ChainId", expectedChainID).Field(
"LatestHeight", expectedLatestHeight,
),
gomock.Any(),
).Return("clientID", nil).Times(1),
}
}

// GetMocksForMakeConsumerGenesis returns mock expectations needed to call MakeConsumerGenesis().
Expand Down
4 changes: 1 addition & 3 deletions testutil/keeper/unit_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ func SetupForDeleteConsumerChain(t *testing.T, ctx sdk.Context,
) {
t.Helper()

SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 1, []stakingtypes.Validator{}, 1)

expectations := GetMocksForCreateConsumerClient(ctx, &mocks,
"chainID", clienttypes.NewHeight(4, 5))
expectations = append(expectations, GetMocksForSetConsumerChain(ctx, &mocks, "chainID")...)
Expand All @@ -241,7 +239,7 @@ func SetupForDeleteConsumerChain(t *testing.T, ctx sdk.Context,
// set the chain to initialized so that we can create a consumer client
providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_INITIALIZED)

err = providerKeeper.CreateConsumerClient(ctx, consumerId)
err = providerKeeper.CreateConsumerClient(ctx, consumerId, []byte{})
require.NoError(t, err)
// set the mapping consumer ID <> client ID for the consumer chain
providerKeeper.SetConsumerClientId(ctx, consumerId, "clientID")
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/provider/keeper/consumer_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ func (k Keeper) ConsumeIdsFromTimeQueue(

// LaunchConsumer launches the chain with the provided consumer id by creating the consumer client and the respective
// consumer genesis file
//
// TODO add unit test for LaunchConsumer
func (k Keeper) LaunchConsumer(
ctx sdk.Context,
bondedValidators []stakingtypes.Validator,
Expand Down
Loading

0 comments on commit f01055b

Please sign in to comment.