Skip to content

Commit

Permalink
refactor calls based on required error success in broadcast message. (#…
Browse files Browse the repository at this point in the history
…3475)

* refactor calls based on required error success in broadcast message.
---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
DimitrisJim and crodriguezvega authored May 17, 2023
1 parent 6e8389a commit b21014e
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 324 deletions.
5 changes: 2 additions & 3 deletions e2e/tests/core/03-connection/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() {

t.Run("ensure packets can be received, send from chainB to chainA", func(t *testing.T) {
t.Run("send tokens from chainB to chainA", func(t *testing.T) {
transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0, "")
s.Require().NoError(err)
s.AssertValidTxResponse(transferTxResp)
transferTxResp := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0, "")
s.AssertTxSuccess(transferTxResp)
})

t.Run("tokens are escrowed", func(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions e2e/tests/core/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
msgUpdateClient, err := clienttypes.NewMsgUpdateClient(ibctesting.FirstClientID, maliciousHeader, rlyWallet.FormattedAddress())
s.Require().NoError(err)

txResp, err := s.BroadcastMessages(ctx, chainA, rlyWallet, msgUpdateClient)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, rlyWallet, msgUpdateClient)
s.AssertTxSuccess(txResp)
})

t.Run("ensure client status is frozen", func(t *testing.T) {
Expand Down
35 changes: 14 additions & 21 deletions e2e/tests/interchain_accounts/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ func getICAVersion(chainAVersion, chainBVersion string) string {

// RegisterInterchainAccount will attempt to register an interchain account on the counterparty chain.
func (s *InterchainAccountsTestSuite) RegisterInterchainAccount(ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, msgRegisterAccount *controllertypes.MsgRegisterInterchainAccount) {
txResp, err := s.BroadcastMessages(ctx, chain, user, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chain, user, msgRegisterAccount)
s.AssertTxSuccess(txResp)
}

func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() {
Expand All @@ -72,9 +71,8 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() {
version := getICAVersion(testconfig.GetChainATag(), testconfig.GetChainBTag())
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version)

txResp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.AssertTxSuccess(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand Down Expand Up @@ -123,15 +121,14 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer() {

msgSendTx := controllertypes.NewMsgSendTx(controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)

resp, err := s.BroadcastMessages(
resp := s.BroadcastMessages(
ctx,
chainA,
controllerAccount,
msgSendTx,
)

s.AssertValidTxResponse(resp)
s.Require().NoError(err)
s.AssertTxSuccess(resp)

s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB))
})
Expand Down Expand Up @@ -169,9 +166,8 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF
version := getICAVersion(testconfig.GetChainATag(), testconfig.GetChainBTag())
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version)

txResp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.AssertTxSuccess(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand Down Expand Up @@ -216,15 +212,14 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF

msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)

txResp, err := s.BroadcastMessages(
txResp := s.BroadcastMessages(
ctx,
chainA,
controllerAccount,
msgSendTx,
)

s.AssertValidTxResponse(txResp)
s.Require().NoError(err)
s.AssertTxSuccess(txResp)

s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB))
})
Expand Down Expand Up @@ -322,15 +317,14 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulTransfer_AfterRe

msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(1), packetData)

resp, err := s.BroadcastMessages(
resp := s.BroadcastMessages(
ctx,
chainA,
controllerAccount,
msgSendTx,
)

s.AssertValidTxResponse(resp)
s.Require().NoError(err)
s.AssertTxSuccess(resp)

// this sleep is to allow the packet to timeout
time.Sleep(1 * time.Second)
Expand Down Expand Up @@ -397,15 +391,14 @@ func (s *InterchainAccountsTestSuite) TestMsgSubmitTx_SuccessfulTransfer_AfterRe

msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(5*time.Minute), packetData)

resp, err := s.BroadcastMessages(
resp := s.BroadcastMessages(
ctx,
chainA,
controllerAccount,
msgSendTx,
)

s.AssertValidTxResponse(resp)
s.Require().NoError(err)
s.AssertTxSuccess(resp)

// time for the packet to be relayed
s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB))
Expand Down
25 changes: 10 additions & 15 deletions e2e/tests/interchain_accounts/groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat
msgCreateGroupWithPolicy, err := grouptypes.NewMsgCreateGroupWithPolicy(chainAAddress, members, DefaultMetadata, DefaultMetadata, true, decisionPolicy)
s.Require().NoError(err)

txResp, err := s.BroadcastMessages(ctx, chainA, chainAWallet, msgCreateGroupWithPolicy)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgCreateGroupWithPolicy)
s.AssertTxSuccess(txResp)
})

t.Run("submit proposal for MsgRegisterInterchainAccount", func(t *testing.T) {
Expand All @@ -115,9 +114,8 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat
msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgRegisterAccount}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount")
s.Require().NoError(err)

txResp, err := s.BroadcastMessages(ctx, chainA, chainAWallet, msgSubmitProposal)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgSubmitProposal)
s.AssertTxSuccess(txResp)
})

t.Run("vote and exec proposal", func(t *testing.T) {
Expand All @@ -128,9 +126,8 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat
Exec: grouptypes.Exec_EXEC_TRY,
}

txResp, err := s.BroadcastMessages(ctx, chainA, chainAWallet, msgVote)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgVote)
s.AssertTxSuccess(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand Down Expand Up @@ -178,9 +175,8 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat
msgSubmitProposal, err := grouptypes.NewMsgSubmitProposal(groupPolicyAddr, []string{chainAAddress}, []sdk.Msg{msgSubmitTx}, DefaultMetadata, grouptypes.Exec_EXEC_UNSPECIFIED, "e2e groups proposal: for MsgRegisterInterchainAccount", "e2e groups proposal: for MsgRegisterInterchainAccount")
s.Require().NoError(err)

txResp, err := s.BroadcastMessages(ctx, chainA, chainAWallet, msgSubmitProposal)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgSubmitProposal)
s.AssertTxSuccess(txResp)
})

t.Run("vote and exec proposal", func(t *testing.T) {
Expand All @@ -191,9 +187,8 @@ func (s *InterchainAccountsGroupsTestSuite) TestInterchainAccountsGroupsIntegrat
Exec: grouptypes.Exec_EXEC_TRY,
}

txResp, err := s.BroadcastMessages(ctx, chainA, chainAWallet, msgVote)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, chainAWallet, msgVote)
s.AssertTxSuccess(txResp)
})

t.Run("verify tokens transferred", func(t *testing.T) {
Expand Down
30 changes: 12 additions & 18 deletions e2e/tests/interchain_accounts/incentivized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe
version := getICAVersion(testconfig.GetChainATag(), testconfig.GetChainBTag())
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAccount.FormattedAddress(), version)

txResp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.AssertTxSuccess(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand Down Expand Up @@ -107,9 +106,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe
})

t.Run("register counterparty payee", func(t *testing.T) {
resp, err := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelOutput.Counterparty.PortID, channelOutput.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress())
s.Require().NoError(err)
s.AssertValidTxResponse(resp)
resp := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelOutput.Counterparty.PortID, channelOutput.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress())
s.AssertTxSuccess(resp)
})

t.Run("verify counterparty payee", func(t *testing.T) {
Expand Down Expand Up @@ -154,9 +152,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe

msgSendTx := controllertypes.NewMsgSendTx(controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)

resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSendTx)
s.AssertValidTxResponse(resp)
s.Require().NoError(err)
resp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSendTx)
s.AssertTxSuccess(resp)

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB))
})
Expand Down Expand Up @@ -250,9 +247,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I
version := getICAVersion(testconfig.GetChainATag(), testconfig.GetChainBTag())
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAccount.FormattedAddress(), version)

txResp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
s.AssertValidTxResponse(txResp)
txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.AssertTxSuccess(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand All @@ -278,9 +274,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I

t.Run("execute interchain account bank send through controller", func(t *testing.T) {
t.Run("register counterparty payee", func(t *testing.T) {
resp, err := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelOutput.Counterparty.PortID, channelOutput.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress())
s.Require().NoError(err)
s.AssertValidTxResponse(resp)
resp := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelOutput.Counterparty.PortID, channelOutput.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress())
s.AssertTxSuccess(resp)
})

t.Run("verify counterparty payee", func(t *testing.T) {
Expand Down Expand Up @@ -326,9 +321,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I

msgSendTx := controllertypes.NewMsgSendTx(controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)

resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSendTx)
s.AssertValidTxResponse(resp)
s.Require().NoError(err)
resp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSendTx)
s.AssertTxSuccess(resp)

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB))
})
Expand Down
28 changes: 12 additions & 16 deletions e2e/tests/interchain_accounts/intertx_incentivized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (s *IncentivizedInterTxTestSuite) TestMsgSubmitTx_SuccessfulBankSend_Incent
t.Run("register interchain account", func(t *testing.T) {
version := "" // allow app to handle the version as appropriate.
msgRegisterAccount := intertxtypes.NewMsgRegisterAccount(controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID, version)
err := s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.AssertTxSuccess(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand Down Expand Up @@ -98,9 +98,8 @@ func (s *IncentivizedInterTxTestSuite) TestMsgSubmitTx_SuccessfulBankSend_Incent
})

t.Run("register counterparty payee", func(t *testing.T) {
resp, err := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelOutput.Counterparty.PortID, channelOutput.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress())
s.Require().NoError(err)
s.AssertValidTxResponse(resp)
resp := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelOutput.Counterparty.PortID, channelOutput.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress())
s.AssertTxSuccess(resp)
})

t.Run("verify counterparty payee", func(t *testing.T) {
Expand Down Expand Up @@ -136,9 +135,8 @@ func (s *IncentivizedInterTxTestSuite) TestMsgSubmitTx_SuccessfulBankSend_Incent
msgSubmitTx, err := intertxtypes.NewMsgSubmitTx(msgSend, ibctesting.FirstConnectionID, controllerAccount.FormattedAddress())
s.Require().NoError(err)

resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSubmitTx)
s.AssertValidTxResponse(resp)
s.Require().NoError(err)
resp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSubmitTx)
s.AssertTxSuccess(resp)

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB))
})
Expand Down Expand Up @@ -231,8 +229,8 @@ func (s *IncentivizedInterTxTestSuite) TestMsgSubmitTx_FailedBankSend_Incentiviz
t.Run("register interchain account", func(t *testing.T) {
version := "" // allow app to handle the version as appropriate.
msgRegisterAccount := intertxtypes.NewMsgRegisterAccount(controllerAccount.FormattedAddress(), ibctesting.FirstConnectionID, version)
err := s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterAccount)
s.Require().NoError(err)
txResp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgRegisterAccount)
s.AssertTxSuccess(txResp)
})

t.Run("start relayer", func(t *testing.T) {
Expand All @@ -258,9 +256,8 @@ func (s *IncentivizedInterTxTestSuite) TestMsgSubmitTx_FailedBankSend_Incentiviz

t.Run("execute interchain account bank send through controller", func(t *testing.T) {
t.Run("register counterparty payee", func(t *testing.T) {
resp, err := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelOutput.Counterparty.PortID, channelOutput.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress())
s.Require().NoError(err)
s.AssertValidTxResponse(resp)
resp := s.RegisterCounterPartyPayee(ctx, chainB, chainBRelayerUser, channelOutput.Counterparty.PortID, channelOutput.Counterparty.ChannelID, chainBRelayerWallet.FormattedAddress(), chainARelayerWallet.FormattedAddress())
s.AssertTxSuccess(resp)
})

t.Run("verify counterparty payee", func(t *testing.T) {
Expand Down Expand Up @@ -297,9 +294,8 @@ func (s *IncentivizedInterTxTestSuite) TestMsgSubmitTx_FailedBankSend_Incentiviz
msgSubmitTx, err := intertxtypes.NewMsgSubmitTx(msgSend, ibctesting.FirstConnectionID, controllerAccount.FormattedAddress())
s.Require().NoError(err)

resp, err := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSubmitTx)
s.AssertValidTxResponse(resp)
s.Require().NoError(err)
resp := s.BroadcastMessages(ctx, chainA, controllerAccount, msgPayPacketFee, msgSubmitTx)
s.AssertTxSuccess(resp)

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB))
})
Expand Down
Loading

0 comments on commit b21014e

Please sign in to comment.