Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event testing for connection handshake #5682

Merged
merged 7 commits into from
Jan 23, 2024
Prev Previous commit
Next Next commit
test: adding TestMsgConnectionOpenTryEvents
  • Loading branch information
chatton committed Jan 22, 2024
commit b885208520c3244b82494448cb45b131e7812b3d
40 changes: 40 additions & 0 deletions modules/core/03-connection/keeper/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,43 @@ func (suite *KeeperTestSuite) TestMsgConnectionOpenInitEvents() {
expectedEvents = sdk.MarkEventsToIndex(expectedEvents, indexSet)
ibctesting.AssertEvents(&suite.Suite, expectedEvents, events)
}

func (suite *KeeperTestSuite) TestMsgConnectionOpenTryEvents() {
suite.SetupTest()
path := ibctesting.NewPath(suite.chainA, suite.chainB)
suite.coordinator.SetupClients(path)

suite.Require().NoError(path.EndpointA.ConnOpenInit())

err := path.EndpointB.UpdateClient()
suite.Require().NoError(err)

counterpartyClient, clientProof, consensusProof, consensusHeight, initProof, proofHeight := path.EndpointB.QueryConnectionHandshakeProof()

msg := types.NewMsgConnectionOpenTry(
path.EndpointB.ClientID, path.EndpointB.Counterparty.ConnectionID, path.EndpointB.Counterparty.ClientID,
counterpartyClient, path.EndpointB.Counterparty.Chain.GetPrefix(), []*types.Version{ibctesting.ConnectionVersion}, path.EndpointB.ConnectionConfig.DelayPeriod,
initProof, clientProof, consensusProof,
proofHeight, consensusHeight,
path.EndpointB.Chain.SenderAccount.GetAddress().String(),
)

res, err := path.EndpointB.Chain.SendMsgs(msg)
suite.Require().NoError(err)
suite.Require().NotNil(res)

events := res.Events
expectedEvents := sdk.Events{
sdk.NewEvent(
types.EventTypeConnectionOpenTry,
sdk.NewAttribute(types.AttributeKeyConnectionID, ibctesting.FirstConnectionID),
sdk.NewAttribute(types.AttributeKeyClientID, path.EndpointB.ClientID),
sdk.NewAttribute(types.AttributeKeyCounterpartyClientID, path.EndpointA.ClientID),
sdk.NewAttribute(types.AttributeKeyCounterpartyConnectionID, path.EndpointA.ConnectionID),
),
}.ToABCIEvents()

var indexSet map[string]struct{}
expectedEvents = sdk.MarkEventsToIndex(expectedEvents, indexSet)
ibctesting.AssertEvents(&suite.Suite, expectedEvents, events)
}