Skip to content

Commit

Permalink
update proposal UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Nov 17, 2023
1 parent 6ebcec4 commit fd5f4e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/integration/double_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
blockID1 := testutil.MakeBlockID([]byte("blockhash"), 1000, []byte("partshash"))
blockID2 := testutil.MakeBlockID([]byte("blockhash2"), 1000, []byte("partshash"))

// Set the equivocation evidence min height to a the previous block height
// Set the equivocation evidence min height to the previous block height
equivocationEvidenceMinHeight := uint64(s.consumerCtx().BlockHeight() - 1)
s.providerApp.GetProviderKeeper().SetEquivocationEvidenceMinHeight(
s.providerCtx(),
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() {
altSigners2,
)

// Set the equivocation evidence min height to a the previous block height
// Set the equivocation evidence min height to the previous block height
equivocationEvidenceMinHeight := clientHeight.RevisionHeight + 1
s.providerApp.GetProviderKeeper().SetEquivocationEvidenceMinHeight(
s.providerCtx(),
Expand Down Expand Up @@ -485,7 +485,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() {
false,
},
{
"invalid misbehaviour older than min equivocation evidence height - shouldn't pass",
"invalid misbehaviour older than the min equivocation evidence height - shouldn't pass",
&ibctmtypes.Misbehaviour{
ClientId: s.path.EndpointA.ClientID,
Header1: s.consumerChain.CreateTMClientHeader(
Expand Down
12 changes: 9 additions & 3 deletions x/ccv/provider/keeper/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,12 @@ func TestCreateConsumerClient(t *testing.T) {
tc.setup(&providerKeeper, ctx, &mocks)

// Call method with same arbitrary values as defined above in mock expectations.
err := providerKeeper.CreateConsumerClient(ctx, testkeeper.GetTestConsumerAdditionProp())
prop := testkeeper.GetTestConsumerAdditionProp()
err := providerKeeper.CreateConsumerClient(ctx, prop)

if tc.expClientCreated {
require.NoError(t, err)
testCreatedConsumerClient(t, ctx, providerKeeper, "chainID", "clientID")
testCreatedConsumerClient(t, ctx, providerKeeper, "chainID", "clientID", prop.InitialHeight.GetRevisionHeight())
} else {
require.Error(t, err)
}
Expand All @@ -197,14 +198,19 @@ func TestCreateConsumerClient(t *testing.T) {
//
// Note: Separated from TestCreateConsumerClient to also be called from TestCreateConsumerChainProposal.
func testCreatedConsumerClient(t *testing.T,
ctx sdk.Context, providerKeeper providerkeeper.Keeper, expectedChainID, expectedClientID string,
ctx sdk.Context, providerKeeper providerkeeper.Keeper,
expectedChainID, expectedClientID string, expectedEquivocationEvidenceMinHeight uint64,
) {
t.Helper()
// ClientID should be stored.
clientId, found := providerKeeper.GetConsumerClientId(ctx, expectedChainID)
require.True(t, found, "consumer client not found")
require.Equal(t, expectedClientID, clientId)

// check that the equivocation evidence min height was set
h := providerKeeper.GetEquivocationEvidenceMinHeight(ctx, expectedChainID)
require.Equal(t, h, expectedEquivocationEvidenceMinHeight)

// Only assert that consumer genesis was set,
// more granular tests on consumer genesis should be defined in TestMakeConsumerGenesis
_, ok := providerKeeper.GetConsumerGenesis(ctx, expectedChainID)
Expand Down

0 comments on commit fd5f4e1

Please sign in to comment.