From fd5f4e1cf5be6c1f84bac274640bb160e3a4b228 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 17 Nov 2023 14:15:47 +0100 Subject: [PATCH] update proposal UTs --- tests/integration/double_vote.go | 2 +- tests/integration/misbehaviour.go | 4 ++-- x/ccv/provider/keeper/proposal_test.go | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go index cc9331adc6..b3f2663c9b 100644 --- a/tests/integration/double_vote.go +++ b/tests/integration/double_vote.go @@ -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(), diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go index f6b737ad6a..d6e92e218c 100644 --- a/tests/integration/misbehaviour.go +++ b/tests/integration/misbehaviour.go @@ -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(), @@ -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( diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index cbaf58ef38..a522a73441 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -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) } @@ -197,7 +198,8 @@ 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. @@ -205,6 +207,10 @@ func testCreatedConsumerClient(t *testing.T, 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)