-
Notifications
You must be signed in to change notification settings - Fork 616
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
e2e: ordered ica channel is upgraded to unordered #5616
Changes from all commits
b6c4ac5
684be17
0d8afac
1985e43
b0b3880
039c598
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -17,6 +17,7 @@ import ( | |||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types" | ||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||||
|
||||
"github.com/cosmos/ibc-go/e2e/testsuite" | ||||
"github.com/cosmos/ibc-go/e2e/testvalues" | ||||
|
@@ -406,3 +407,129 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop | |||
s.Require().Equal(expected, balance.Int64()) | ||||
}) | ||||
} | ||||
|
||||
func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterUpgradingOrdertoUnordered() { | ||||
t := s.T() | ||||
ctx := context.TODO() | ||||
|
||||
// setup relayers and connection-0 between two chains | ||||
// channel-0 is a transfer channel but it will not be used in this test case | ||||
relayer, _ := s.SetupChainsRelayerAndChannel(ctx, nil) | ||||
chainA, _ := s.GetChains() | ||||
|
||||
// setup 2 accounts: controller account on chain A, a second chain B account. | ||||
// host account will be created when the ICA is registered | ||||
controllerAccount := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) | ||||
controllerAddress := controllerAccount.FormattedAddress() | ||||
// chainBAccount := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) | ||||
|
||||
var ( | ||||
portID string | ||||
hostAccount string | ||||
|
||||
initialChannelID = "channel-1" | ||||
) | ||||
|
||||
t.Run("register interchain account", func(t *testing.T) { | ||||
var err error | ||||
// explicitly set the version string because we don't want to use incentivized channels. | ||||
version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) | ||||
msgRegisterInterchainAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, controllerAddress, version, channeltypes.ORDERED) | ||||
s.RegisterInterchainAccount(ctx, chainA, controllerAccount, msgRegisterInterchainAccount) | ||||
portID, err = icatypes.NewControllerPortID(controllerAddress) | ||||
s.Require().NoError(err) | ||||
}) | ||||
|
||||
t.Run("start relayer", func(t *testing.T) { | ||||
s.StartRelayer(relayer) | ||||
}) | ||||
|
||||
t.Run("verify interchain account", func(t *testing.T) { | ||||
var err error | ||||
hostAccount, err = s.QueryInterchainAccount(ctx, chainA, controllerAddress, ibctesting.FirstConnectionID) | ||||
s.Require().NoError(err) | ||||
s.Require().NotZero(len(hostAccount)) | ||||
|
||||
_, err = s.QueryChannel(ctx, chainA, portID, initialChannelID) | ||||
s.Require().NoError(err) | ||||
}) | ||||
|
||||
// t.Run("fund interchain account wallet", func(t *testing.T) { | ||||
// // fund the host account account so it has some $$ to send | ||||
// err := chainB.SendFunds(ctx, interchaintest.FaucetAccountKeyName, ibc.WalletAmount{ | ||||
// Address: hostAccount, | ||||
// Amount: sdkmath.NewInt(testvalues.StartingTokenAmount), | ||||
// Denom: chainB.Config().Denom, | ||||
// }) | ||||
// s.Require().NoError(err) | ||||
// }) | ||||
|
||||
// t.Run("broadcast MsgSendTx", func(t *testing.T) { | ||||
// // assemble bank transfer message from host account to user account on host chain | ||||
// msgSend := &banktypes.MsgSend{ | ||||
// FromAddress: hostAccount, | ||||
// ToAddress: chainBAccount.FormattedAddress(), | ||||
// Amount: sdk.NewCoins(testvalues.DefaultTransferAmount(chainB.Config().Denom)), | ||||
// } | ||||
|
||||
// cdc := testsuite.Codec() | ||||
|
||||
// bz, err := icatypes.SerializeCosmosTx(cdc, []proto.Message{msgSend}, icatypes.EncodingProtobuf) | ||||
// s.Require().NoError(err) | ||||
|
||||
// packetData := icatypes.InterchainAccountPacketData{ | ||||
// Type: icatypes.EXECUTE_TX, | ||||
// Data: bz, | ||||
// Memo: "e2e", | ||||
// } | ||||
|
||||
// msgSendTx := controllertypes.NewMsgSendTx(controllerAddress, ibctesting.FirstConnectionID, uint64(5*time.Minute), packetData) | ||||
|
||||
// resp := s.BroadcastMessages( | ||||
// ctx, | ||||
// chainA, | ||||
// controllerAccount, | ||||
// msgSendTx, | ||||
// ) | ||||
|
||||
// s.AssertTxSuccess(resp) | ||||
|
||||
// // time for the packet to be relayed | ||||
// s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB)) | ||||
// }) | ||||
|
||||
// t.Run("verify tokens transferred", func(t *testing.T) { | ||||
// balance, err := s.QueryBalance(ctx, chainB, chainBAccount.FormattedAddress(), chainB.Config().Denom) | ||||
// s.Require().NoError(err) | ||||
|
||||
// expected := testvalues.IBCTransferAmount + testvalues.StartingTokenAmount | ||||
// s.Require().Equal(expected, balance.Int64()) | ||||
// }) | ||||
|
||||
channel, err := s.QueryChannel(ctx, chainA, portID, initialChannelID) | ||||
s.Require().NoError(err) | ||||
|
||||
// upgrade the channel ordering to UNORDERED | ||||
upgradeFields := channeltypes.NewUpgradeFields(channeltypes.UNORDERED, channel.ConnectionHops, channel.Version) | ||||
|
||||
t.Run("execute gov proposal to initiate channel upgrade", func(t *testing.T) { | ||||
govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linking #5611 |
||||
s.Require().NoError(err) | ||||
s.Require().NotNil(govModuleAddress) | ||||
|
||||
msg := channeltypes.NewMsgChannelUpgradeInit(portID, initialChannelID, upgradeFields, govModuleAddress.String()) | ||||
s.ExecuteAndPassGovV1Proposal(ctx, msg, chainA, controllerAccount) | ||||
}) | ||||
|
||||
t.Run("verify channel A upgraded and is now unordered", func(t *testing.T) { | ||||
var channel channeltypes.Channel | ||||
waitErr := test.WaitForCondition(time.Minute*2, time.Second*5, func() (bool, error) { | ||||
channel, err = s.QueryChannel(ctx, chainA, portID, initialChannelID) | ||||
if err != nil { | ||||
return false, err | ||||
} | ||||
return channel.Ordering == channeltypes.UNORDERED, nil | ||||
}) | ||||
s.Require().NoErrorf(waitErr, "channel was not upgraded: expected %s got %s", channeltypes.UNORDERED, channel.Ordering) | ||||
Comment on lines
+525
to
+533
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is waiting for a while not possible here? I.e similar to Carlos's PR
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was part of the debugging efforts actually, so this kind of polling made more sense. basically the situation was that if we tried to do a transfer before upgrading the ICA channel, the test would fail at hanging on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sgtm as long as its tracked! |
||||
}) | ||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we wanna rm these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, im waiting for another relayer image to hopefully be able to enable this logic, as currently this test fails with this logic in (for some reason)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so im keeping it in but commented out for now :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah gotcha, someone was bound to leave this comment 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we open an issue to track? Feels like something that could get lost in the weeds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can open an issue to track this!