Skip to content

Commit

Permalink
imp(testing/callback-counter): entire callback msgs are stored (#109)
Browse files Browse the repository at this point in the history
* imp: the callback counter now records the entire callback messages

* fix: clippy complaint

* imp: ran go-codegen

* fix: the new types
  • Loading branch information
srdtrk committed May 18, 2024
1 parent 2727bcd commit 3598978
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 152 deletions.
80 changes: 40 additions & 40 deletions e2e/interchaintestv8/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ func (s *ContractTestSuite) IcaContractExecutionTestWithOrdering(ordering cwicac
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(1), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(1), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))

// Check if the proposal was created:
proposalResp, err := e2esuite.GRPCQuery[govv1.QueryProposalResponse](ctx, simd, &govv1.QueryProposalRequest{
Expand Down Expand Up @@ -426,8 +426,8 @@ func (s *ContractTestSuite) IcaContractExecutionTestWithOrdering(ordering cwicac

callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(2), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(2), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))

// Check if the delegation was successful:
postBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
Expand Down Expand Up @@ -484,9 +484,9 @@ func (s *ContractTestSuite) IcaContractExecutionTestWithOrdering(ordering cwicac
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(2), callbackCounter.Success)
s.Require().Equal(int(1), callbackCounter.Error)
s.Require().Equal(int(0), callbackCounter.Timeout)
s.Require().Equal(int(2), len(callbackCounter.Success))
s.Require().Equal(int(1), len(callbackCounter.Error))
s.Require().Equal(int(0), len(callbackCounter.Timeout))
})
}

Expand Down Expand Up @@ -554,8 +554,8 @@ func (s *ContractTestSuite) SendCosmosMsgsTestWithOrdering(ordering cwicacontrol
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(1), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(1), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))

// Check if the proposal was created:
proposalResp, err := e2esuite.GRPCQuery[govv1.QueryProposalResponse](ctx, simd, &govv1.QueryProposalRequest{
Expand Down Expand Up @@ -633,8 +633,8 @@ func (s *ContractTestSuite) SendCosmosMsgsTestWithOrdering(ordering cwicacontrol

callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(2), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(2), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))

// Check if the delegation was successful:
postBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
Expand Down Expand Up @@ -711,8 +711,8 @@ func (s *ContractTestSuite) SendCosmosMsgsTestWithOrdering(ordering cwicacontrol

callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(3), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(3), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))

// Check if the send was successful:
postBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
Expand Down Expand Up @@ -790,9 +790,9 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Ordered_Protobuf() {
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(0), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(1), callbackCounter.Timeout)
s.Require().Equal(int(0), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(1), len(callbackCounter.Timeout))

// Check if contract channel state was updated:
contractChannelState, err := s.Contract.QueryClient().GetChannel(ctx, &cwicacontroller.QueryMsg_GetChannel{})
Expand Down Expand Up @@ -848,9 +848,9 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Ordered_Protobuf() {

callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(0), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(1), callbackCounter.Timeout)
s.Require().Equal(int(0), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(1), len(callbackCounter.Timeout))
})

s.Run("TestSendCustomIcaMessagesAfterReopen", func() {
Expand Down Expand Up @@ -878,9 +878,9 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Ordered_Protobuf() {
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(1), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(1), callbackCounter.Timeout)
s.Require().Equal(int(1), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(1), len(callbackCounter.Timeout))
})
}

Expand Down Expand Up @@ -953,9 +953,9 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Unordered_Protobuf() {
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(0), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(1), callbackCounter.Timeout)
s.Require().Equal(int(0), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(1), len(callbackCounter.Timeout))

// Check if contract channel state is still open:
contractChannelState, err := s.Contract.QueryClient().GetChannel(ctx, &cwicacontroller.QueryMsg_GetChannel{})
Expand Down Expand Up @@ -988,9 +988,9 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Unordered_Protobuf() {
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(1), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(1), callbackCounter.Timeout)
s.Require().Equal(int(1), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(1), len(callbackCounter.Timeout))
})
}

Expand Down Expand Up @@ -1034,9 +1034,9 @@ func (s *ContractTestSuite) TestMigrateOrderedToUnordered() {
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(0), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(0), callbackCounter.Timeout)
s.Require().Equal(int(0), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(0), len(callbackCounter.Timeout))

// Check if contract channel state was updated:
contractChannelState, err := s.Contract.QueryClient().GetChannel(ctx, &cwicacontroller.QueryMsg_GetChannel{})
Expand Down Expand Up @@ -1101,9 +1101,9 @@ func (s *ContractTestSuite) TestMigrateOrderedToUnordered() {

callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(0), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(0), callbackCounter.Timeout)
s.Require().Equal(int(0), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(0), len(callbackCounter.Timeout))
})

s.Run("TestSendCustomIcaMessagesAfterReopen", func() {
Expand Down Expand Up @@ -1131,9 +1131,9 @@ func (s *ContractTestSuite) TestMigrateOrderedToUnordered() {
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(1), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(0), callbackCounter.Timeout)
s.Require().Equal(int(1), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(0), len(callbackCounter.Timeout))
})
}

Expand Down Expand Up @@ -1176,9 +1176,9 @@ func (s *ContractTestSuite) TestCloseChannel_Protobuf_Unordered() {
// Check if contract callbacks were executed:
callbackCounter, err := s.CallbackCounterContract.QueryClient().GetCallbackCounter(ctx, &callbackcounter.QueryMsg_GetCallbackCounter{})
s.Require().NoError(err)
s.Require().Equal(int(0), callbackCounter.Success)
s.Require().Equal(int(0), callbackCounter.Error)
s.Require().Equal(int(0), callbackCounter.Timeout)
s.Require().Equal(int(0), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(0), len(callbackCounter.Timeout))

// Check if contract channel state was updated:
contractChannelState, err := s.Contract.QueryClient().GetChannel(ctx, &cwicacontroller.QueryMsg_GetChannel{})
Expand Down
Loading

0 comments on commit 3598978

Please sign in to comment.