Skip to content

Commit

Permalink
imp(e2e): made subtests sequential
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed Jun 16, 2024
1 parent d6b0330 commit e0f0e1a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
76 changes: 38 additions & 38 deletions e2e/interchaintestv8/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (s *ContractTestSuite) IcaContractChannelHandshakeTest_WithOrdering(orderin
s.SetupContractTestSuite(ctx, ordering)
wasmd, simd := s.ChainA, s.ChainB

s.Run("TestChannelHandshakeSuccess", func() {
s.Require().True(s.Run("TestChannelHandshakeSuccess", func() {
// Test if the handshake was successful
wasmdChannels, err := s.Relayer.GetChannels(ctx, s.ExecRep, wasmd.Config().ChainID)
s.Require().NoError(err)
Expand Down Expand Up @@ -165,7 +165,7 @@ func (s *ContractTestSuite) IcaContractChannelHandshakeTest_WithOrdering(orderin
contractState, err := s.Contract.QueryClient().GetContractState(ctx, &cwicacontroller.QueryMsg_GetContractState{})
s.Require().NoError(err)
s.Require().Equal(wasmdChannel.ChannelID, contractState.IcaInfo.ChannelId)
})
}))
}

// This tests that the relayer cannot create a channel with the contract's port.
Expand Down Expand Up @@ -217,7 +217,7 @@ func (s *ContractTestSuite) TestRecoveredIcaContractInstantiatedChannelHandshake
codeId, err := wasmd.StoreContract(ctx, wasmdUser.KeyName(), "../../artifacts/cw_ica_controller.wasm")
s.Require().NoError(err)

s.Run("TestChannelHandshakeFail: invalid connection id", func() {
s.Require().True(s.Run("TestChannelHandshakeFail: invalid connection id", func() {
// Instantiate the contract with channel:
instantiateMsg := cwicacontroller.InstantiateMsg{
Owner: nil,
Expand All @@ -231,9 +231,9 @@ func (s *ContractTestSuite) TestRecoveredIcaContractInstantiatedChannelHandshake

_, err = cwicacontroller.Instantiate(ctx, wasmdUser.KeyName(), codeId, "", wasmd, instantiateMsg, "--gas", "500000")
s.Require().ErrorContains(err, "submessages: invalid connection hop ID")
})
}))

s.Run("TestChannelHandshakeFail: invalid counterparty connection id", func() {
s.Require().True(s.Run("TestChannelHandshakeFail: invalid counterparty connection id", func() {
// Instantiate the contract with channel:
instantiateMsg := cwicacontroller.InstantiateMsg{
Owner: nil,
Expand All @@ -247,9 +247,9 @@ func (s *ContractTestSuite) TestRecoveredIcaContractInstantiatedChannelHandshake

s.Contract, err = cwicacontroller.Instantiate(ctx, wasmdUser.KeyName(), codeId, "", wasmd, instantiateMsg, "--gas", "500000")
s.Require().NoError(err)
})
}))

s.Run("TestChannelHandshakeSuccessAfterFail", func() {
s.Require().True(s.Run("TestChannelHandshakeSuccessAfterFail", func() {
createChannelMsg := cwicacontroller.ExecuteMsg{
CreateChannel: &cwicacontroller.ExecuteMsg_CreateChannel{
ChannelOpenInitOptions: &cwicacontroller.ChannelOpenInitOptions{
Expand Down Expand Up @@ -310,7 +310,7 @@ func (s *ContractTestSuite) TestRecoveredIcaContractInstantiatedChannelHandshake
contractState, err := s.Contract.QueryClient().GetContractState(ctx, &cwicacontroller.QueryMsg_GetContractState{})
s.Require().NoError(err)
s.Require().Equal(wasmdChannel.ChannelID, contractState.IcaInfo.ChannelId)
})
}))
}

func (s *ContractTestSuite) TestIcaContractExecution_Ordered_Protobuf() {
Expand All @@ -333,7 +333,7 @@ func (s *ContractTestSuite) IcaContractExecutionTestWithOrdering(ordering cwicac
// Fund the ICA address:
s.FundAddressChainB(ctx, s.IcaContractToAddrMap[s.Contract.Address])

s.Run("TestStargateMsgSuccess", func() {
s.Require().True(s.Run("TestStargateMsgSuccess", func() {
// Send custom ICA messages through the contract:
// Let's create a governance proposal on simd and deposit some funds to it.
govAddress := s.GetModuleAddress(ctx, simd, govtypes.ModuleName)
Expand Down Expand Up @@ -381,9 +381,9 @@ func (s *ContractTestSuite) IcaContractExecutionTestWithOrdering(ordering cwicac
postBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
s.Require().NoError(err)
s.Require().Equal(intialBalance.Sub(sdkmath.NewInt(10_000_000)), postBalance)
})
}))

s.Run("TestSendCosmosMsgsSuccess", func() {
s.Require().True(s.Run("TestSendCosmosMsgsSuccess", func() {
intialBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
s.Require().NoError(err)

Expand Down Expand Up @@ -450,9 +450,9 @@ func (s *ContractTestSuite) IcaContractExecutionTestWithOrdering(ordering cwicac
s.Require().Len(voteResp.Vote.Options, 1)
s.Require().Equal(govv1.OptionYes, voteResp.Vote.Options[0].Option)
s.Require().Equal(sdkmath.LegacyNewDec(1).String(), voteResp.Vote.Options[0].Weight)
})
}))

s.Run("TestIcaError", func() {
s.Require().True(s.Run("TestIcaError", func() {
// Test erroneous callback:
// Send incorrect custom ICA messages through the contract:
badSendMsg := cwicacontroller.CosmosMsg_for_Empty{
Expand Down Expand Up @@ -487,7 +487,7 @@ func (s *ContractTestSuite) IcaContractExecutionTestWithOrdering(ordering cwicac
s.Require().Equal(int(2), len(callbackCounter.Success))
s.Require().Equal(int(1), len(callbackCounter.Error))
s.Require().Equal(int(0), len(callbackCounter.Timeout))
})
}))
}

func (s *ContractTestSuite) TestSendCosmosMsgs_Ordered_Protobuf() {
Expand Down Expand Up @@ -519,7 +519,7 @@ func (s *ContractTestSuite) SendCosmosMsgsTestWithOrdering(ordering cwicacontrol
// Fund the ICA address:
s.FundAddressChainB(ctx, s.IcaContractToAddrMap[s.Contract.Address])

s.Run("TestStargate", func() {
s.Require().True(s.Run("TestStargate", func() {
// Send custom ICA messages through the contract:
// Let's create a governance proposal on simd and deposit some funds to it.
govAddress := s.GetModuleAddress(ctx, simd, govtypes.ModuleName)
Expand Down Expand Up @@ -567,9 +567,9 @@ func (s *ContractTestSuite) SendCosmosMsgsTestWithOrdering(ordering cwicacontrol
postBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
s.Require().NoError(err)
s.Require().Equal(initialBalance.Sub(sdkmath.NewInt(10_000_000)), postBalance)
})
}))

s.Run("TestDelegateAndVoteWeightedAndCommunityPool", func() {
s.Require().True(s.Run("TestDelegateAndVoteWeightedAndCommunityPool", func() {
intialBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
s.Require().NoError(err)

Expand Down Expand Up @@ -667,9 +667,9 @@ func (s *ContractTestSuite) SendCosmosMsgsTestWithOrdering(ordering cwicacontrol
s.Require().True(expWeight.Equal(actualWeight))
s.Require().Equal(govv1.OptionAbstain, voteResp.Vote.Options[1].Option)
s.Require().True(expWeight.Equal(actualWeight2))
})
}))

s.Run("TestSendAndSetWithdrawAddress", func() {
s.Require().True(s.Run("TestSendAndSetWithdrawAddress", func() {
initialBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
s.Require().NoError(err)

Expand Down Expand Up @@ -718,7 +718,7 @@ func (s *ContractTestSuite) SendCosmosMsgsTestWithOrdering(ordering cwicacontrol
postBalance, err := simd.GetBalance(ctx, s.IcaContractToAddrMap[s.Contract.Address], simd.Config().Denom)
s.Require().NoError(err)
s.Require().Equal(sdkmath.NewInt(1_000_000), initialBalance.Sub(postBalance))
})
}))
}

func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Ordered_Protobuf() {
Expand All @@ -737,7 +737,7 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Ordered_Protobuf() {
s.Require().NoError(err)

var simdChannelsLen int
s.Run("TestTimeout", func() {
s.Require().True(s.Run("TestTimeout", func() {
// We will send a message to the host that will timeout after 3 seconds.
// You cannot use 0 seconds because block timestamp will be greater than the timeout timestamp which is not allowed.
// Host will not be able to respond to this message in time.
Expand Down Expand Up @@ -798,9 +798,9 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Ordered_Protobuf() {
contractChannelState, err := s.Contract.QueryClient().GetChannel(ctx, &cwicacontroller.QueryMsg_GetChannel{})
s.Require().NoError(err)
s.Require().Equal(cwicacontroller.Status_StateClosed, contractChannelState.ChannelStatus)
})
}))

s.Run("TestChannelReopening", func() {
s.Require().True(s.Run("TestChannelReopening", func() {
// Reopen the channel:
createChannelMsg := cwicacontroller.ExecuteMsg{
CreateChannel: &cwicacontroller.ExecuteMsg_CreateChannel{
Expand Down Expand Up @@ -851,9 +851,9 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Ordered_Protobuf() {
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() {
s.Require().True(s.Run("TestSendCustomIcaMessagesAfterReopen", func() {
// Send custom ICA message through the contract:
sendMsg := &banktypes.MsgSend{
FromAddress: s.IcaContractToAddrMap[s.Contract.Address],
Expand Down Expand Up @@ -881,7 +881,7 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Ordered_Protobuf() {
s.Require().Equal(int(1), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(1), len(callbackCounter.Timeout))
})
}))
}

func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Unordered_Protobuf() {
Expand All @@ -900,7 +900,7 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Unordered_Protobuf() {
s.Require().NoError(err)

var simdChannelsLen int
s.Run("TestTimeout", func() {
s.Require().True(s.Run("TestTimeout", func() {
// We will send a message to the host that will timeout after 3 seconds.
// You cannot use 0 seconds because block timestamp will be greater than the timeout timestamp which is not allowed.
// Host will not be able to respond to this message in time.
Expand Down Expand Up @@ -961,9 +961,9 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Unordered_Protobuf() {
contractChannelState, err := s.Contract.QueryClient().GetChannel(ctx, &cwicacontroller.QueryMsg_GetChannel{})
s.Require().NoError(err)
s.Require().Equal(cwicacontroller.Status_StateOpen, contractChannelState.ChannelStatus)
})
}))

s.Run("TestSendCustomIcaMessagesAfterTimeout", func() {
s.Require().True(s.Run("TestSendCustomIcaMessagesAfterTimeout", func() {
// Send custom ICA message through the contract:
sendMsg := &banktypes.MsgSend{
FromAddress: s.IcaContractToAddrMap[s.Contract.Address],
Expand Down Expand Up @@ -991,7 +991,7 @@ func (s *ContractTestSuite) TestIcaContractTimeoutPacket_Unordered_Protobuf() {
s.Require().Equal(int(1), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(1), len(callbackCounter.Timeout))
})
}))
}

func (s *ContractTestSuite) TestMigrateOrderedToUnordered() {
Expand All @@ -1007,7 +1007,7 @@ func (s *ContractTestSuite) TestMigrateOrderedToUnordered() {
s.FundAddressChainB(ctx, s.IcaContractToAddrMap[s.Contract.Address])

var simdChannelsLen int
s.Run("TestCloseChannel", func() {
s.Require().True(s.Run("TestCloseChannel", func() {
// Close the channel:
closeChannelMsg := cwicacontroller.ExecuteMsg{
CloseChannel: &cwicacontroller.ExecuteMsg_CloseChannel{},
Expand Down Expand Up @@ -1042,9 +1042,9 @@ func (s *ContractTestSuite) TestMigrateOrderedToUnordered() {
contractChannelState, err := s.Contract.QueryClient().GetChannel(ctx, &cwicacontroller.QueryMsg_GetChannel{})
s.Require().NoError(err)
s.Require().Equal(cwicacontroller.Status_StateClosed, contractChannelState.ChannelStatus)
})
}))

s.Run("TestChannelReopening", func() {
s.Require().True(s.Run("TestChannelReopening", func() {
// Reopen the channel:
ordering := cwicacontroller.IbcOrder_OrderUnordered

Expand Down Expand Up @@ -1104,9 +1104,9 @@ func (s *ContractTestSuite) TestMigrateOrderedToUnordered() {
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() {
s.Require().True(s.Run("TestSendCustomIcaMessagesAfterReopen", func() {
// Send custom ICA message through the contract:
sendMsg := &banktypes.MsgSend{
FromAddress: s.IcaContractToAddrMap[s.Contract.Address],
Expand Down Expand Up @@ -1134,7 +1134,7 @@ func (s *ContractTestSuite) TestMigrateOrderedToUnordered() {
s.Require().Equal(int(1), len(callbackCounter.Success))
s.Require().Equal(int(0), len(callbackCounter.Error))
s.Require().Equal(int(0), len(callbackCounter.Timeout))
})
}))
}

func (s *ContractTestSuite) TestCloseChannel_Protobuf_Unordered() {
Expand All @@ -1149,7 +1149,7 @@ func (s *ContractTestSuite) TestCloseChannel_Protobuf_Unordered() {
// Fund the ICA address:
s.FundAddressChainB(ctx, s.IcaContractToAddrMap[s.Contract.Address])

s.Run("TestCloseChannel", func() {
s.Require().True(s.Run("TestCloseChannel", func() {
// Close the channel:
closeChannelMsg := cwicacontroller.ExecuteMsg{
CloseChannel: &cwicacontroller.ExecuteMsg_CloseChannel{},
Expand Down Expand Up @@ -1184,7 +1184,7 @@ func (s *ContractTestSuite) TestCloseChannel_Protobuf_Unordered() {
contractChannelState, err := s.Contract.QueryClient().GetChannel(ctx, &cwicacontroller.QueryMsg_GetChannel{})
s.Require().NoError(err)
s.Require().Equal(cwicacontroller.Status_StateClosed, contractChannelState.ChannelStatus)
})
}))
}

// toJSONString returns a string representation of the given value
Expand Down
8 changes: 4 additions & 4 deletions e2e/interchaintestv8/owner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *OwnerTestSuite) TestOwnerCreateIcaContract() {
icaContract, err := cwicacontroller.NewContract(string(icaState.ContractAddr), strconv.FormatInt(s.IcaContractCodeId, 10), wasmd)
s.Require().NoError(err)

s.Run("TestChannelHandshakeSuccess", func() {
s.Require().True(s.Run("TestChannelHandshakeSuccess", func() {
// Test if the handshake was successful
wasmdChannels, err := s.Relayer.GetChannels(ctx, s.ExecRep, wasmd.Config().ChainID)
s.Require().NoError(err)
Expand Down Expand Up @@ -140,7 +140,7 @@ func (s *OwnerTestSuite) TestOwnerCreateIcaContract() {
s.Require().Equal(s.OwnerContract.Address, *ownershipResponse.Owner)
s.Require().Nil(ownershipResponse.PendingOwner)
s.Require().Nil(ownershipResponse.PendingExpiry)
})
}))
}

func (s *OwnerTestSuite) TestOwnerPredefinedAction() {
Expand All @@ -167,7 +167,7 @@ func (s *OwnerTestSuite) TestOwnerPredefinedAction() {
// Fund the ICA address:
s.FundAddressChainB(ctx, icaAddress)

s.Run("TestSendPredefinedActionSuccess", func() {
s.Require().True(s.Run("TestSendPredefinedActionSuccess", func() {
execPredefinedActionMsg := cwicaowner.ExecuteMsg{
SendPredefinedAction: &cwicaowner.ExecuteMsg_SendPredefinedAction{
IcaId: 0,
Expand All @@ -183,5 +183,5 @@ func (s *OwnerTestSuite) TestOwnerPredefinedAction() {
icaBalance, err := simd.GetBalance(ctx, icaAddress, simd.Config().Denom)
s.Require().NoError(err)
s.Require().Equal(sdkmath.NewInt(1000000000-100), icaBalance)
})
}))
}
12 changes: 6 additions & 6 deletions e2e/interchaintestv8/wasm_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *ContractTestSuite) TestSendWasmMsgsProtobufEncoding() {
s.FundAddressChainB(ctx, s.IcaContractToAddrMap[s.Contract.Address])

var counterContract *simplecounter.Contract
s.Run("TestInstantiate", func() {
s.Require().True(s.Run("TestInstantiate", func() {
icaAddress := s.IcaContractToAddrMap[s.Contract.Address]

// Instantiate the contract:
Expand Down Expand Up @@ -164,10 +164,10 @@ func (s *ContractTestSuite) TestSendWasmMsgsProtobufEncoding() {
counterState, err := counterContract.QueryClient().GetCount(ctx, &simplecounter.QueryMsg_GetCount{})
s.Require().NoError(err)
s.Require().Equal(int(0), counterState.Count)
})
}))

var counterContract2 *simplecounter.Contract
s.Run("TestExecuteAndInstantiate2AndClearAdminMsg", func() {
s.Require().True(s.Run("TestExecuteAndInstantiate2AndClearAdminMsg", func() {
icaAddress := s.IcaContractToAddrMap[s.Contract.Address]

// Execute the contract:
Expand Down Expand Up @@ -242,9 +242,9 @@ func (s *ContractTestSuite) TestSendWasmMsgsProtobufEncoding() {

counterContract2, err = simplecounter.NewContract(contractByCodeResp.Contracts[1], strconv.FormatUint(uint64(counterCodeID), 10), wasmd2)
s.Require().NoError(err)
})
}))

s.Run("TestMigrateAndUpdateAdmin", func() {
s.Require().True(s.Run("TestMigrateAndUpdateAdmin", func() {
migrateMsg := cwicacontroller.CosmosMsg_for_Empty{
Wasm: &cwicacontroller.CosmosMsg_for_Empty_Wasm{
Migrate: &cwicacontroller.WasmMsg_Migrate{
Expand Down Expand Up @@ -293,7 +293,7 @@ func (s *ContractTestSuite) TestSendWasmMsgsProtobufEncoding() {
s.Require().NoError(err)
s.Require().Equal(counterCodeID+1, int(contractInfoResp.ContractInfo.CodeID))
s.Require().Equal(wasmd2User.FormattedAddress(), contractInfoResp.ContractInfo.Admin)
})
}))
}

func toBase64(msg string) string {
Expand Down

0 comments on commit e0f0e1a

Please sign in to comment.