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

Resolve commented out testcases for Channel Upgrades #4474

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6999e94
chore: removed error receipt and proof from MsgChannelUpgradeTimeout
chatton Aug 24, 2023
2d0a4a8
Merge branch '04-channel-upgrades' into cian/issue#4450-refactor-chan…
chatton Aug 24, 2023
8eedd41
chore: fix linter
chatton Aug 24, 2023
09a0d2f
Merge branch 'cian/issue#4450-refactor-channel-ugpradability-msgs-to-…
chatton Aug 24, 2023
b9e4019
wip
chatton Aug 24, 2023
a98ba3f
wip: partial work on TestChannelUpgradeTimeout
chatton Aug 24, 2023
4cb1759
wip: partial work on TestChannelUpgradeTimeout
chatton Aug 24, 2023
3e919d9
wip
chatton Aug 24, 2023
9c00c47
wip: partial work on TestChannelUpgradeTimeout
chatton Aug 24, 2023
364a406
wip: partial work on TestChannelUpgradeTimeout
chatton Aug 24, 2023
ce7455e
Refactor test for msg server cancel upgrade.
DimitrisJim Aug 24, 2023
d9f23da
Refactor test for msg server timeout upgrade.
DimitrisJim Aug 28, 2023
d575428
merge remote branch
chatton Aug 28, 2023
d8c11fb
chore: fixing tests for TestChanUpgradeOpenCounterpartyStates
chatton Aug 28, 2023
d5a7a6d
Merge branch '04-channel-upgrades' into cian/issue#4346-tracker-resol…
chatton Aug 29, 2023
1f82a62
chore: addressing PR feedback
chatton Aug 29, 2023
eb7c68d
Merge branch '04-channel-upgrades' into cian/issue#4346-tracker-resol…
chatton Aug 29, 2023
ef48f65
Merge branch '04-channel-upgrades' into cian/issue#4346-tracker-resol…
chatton Aug 29, 2023
99f69d7
chore: fix linter
chatton Aug 29, 2023
8f29de5
Merge branch '04-channel-upgrades' into cian/issue#4346-tracker-resol…
chatton Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 37 additions & 92 deletions modules/core/04-channel/keeper/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,43 @@ func (suite *KeeperTestSuite) TestChanUpgradeOpen() {
func() {},
nil,
},
{
"success: counterparty in flushcomplete",
func() {
path = ibctesting.NewPath(suite.chainA, suite.chainB)
suite.coordinator.Setup(path)

path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion
path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion

// Need to create a packet commitment on A so as to keep it from going to FLUSHCOMPLETE if no inflight packets exist.
sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData)
suite.Require().NoError(err)
packet := types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp)
err = path.EndpointB.RecvPacket(packet)
suite.Require().NoError(err)

err = path.EndpointA.ChanUpgradeInit()
suite.Require().NoError(err)

err = path.EndpointB.ChanUpgradeTry()
suite.Require().NoError(err)

err = path.EndpointA.ChanUpgradeAck()
suite.Require().NoError(err)

err = path.EndpointB.ChanUpgradeConfirm()
suite.Require().NoError(err)

err = path.EndpointA.AcknowledgePacket(packet, ibctesting.MockAcknowledgement)
suite.Require().NoError(err)

// cause the packet commitment on chain A to be deleted and the channel state to be updated to FLUSHCOMPLETE.
suite.coordinator.CommitBlock(suite.chainA, suite.chainB)
suite.Require().NoError(path.EndpointA.UpdateClient())
},
nil,
},
{
"channel not found",
func() {
Expand Down Expand Up @@ -1027,98 +1064,6 @@ func (suite *KeeperTestSuite) TestChanUpgradeOpen() {
}
}

// TestChanUpgradeOpenCounterPartyStates tests the handshake in the cases where
// the counterparty is in a state other than OPEN.
// func (suite *KeeperTestSuite) TestChanUpgradeOpenCounterpartyStates() {
// var path *ibctesting.Path
// testCases := []struct {
// name string
// malleate func()
// expError error
// }{
// {
// "success, counterparty in OPEN",
// func() {
// err := path.EndpointB.ChanUpgradeInit()
// suite.Require().NoError(err)

// err = path.EndpointA.ChanUpgradeTry()
// suite.Require().NoError(err)

// err = path.EndpointB.ChanUpgradeAck()
// suite.Require().NoError(err)

// suite.coordinator.CommitBlock(suite.chainA, suite.chainB)
// suite.Require().NoError(path.EndpointA.UpdateClient())
// },
// nil,
// },
// {
// "success, counterparty in TRYUPGRADE",
// func() {
// // Need to create a packet commitment on A so as to keep it from going to OPEN if no inflight packets exist.
// sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, disabledTimeoutTimestamp, ibctesting.MockPacketData)
// suite.Require().NoError(err)
// packet := types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp)
// err = path.EndpointB.RecvPacket(packet)
// suite.Require().NoError(err)

// err = path.EndpointA.ChanUpgradeInit()
// suite.Require().NoError(err)

// err = path.EndpointB.ChanUpgradeTry()
// suite.Require().NoError(err)

// err = path.EndpointA.ChanUpgradeAck()
// suite.Require().NoError(err)

// // Ack packet to delete packet commitment before calling ChanUpgradeOpen
// err = path.EndpointA.AcknowledgePacket(packet, ibctesting.MockAcknowledgement)
// suite.Require().NoError(err)
// },
// nil,
// },
// }

// // Create an initial path used only to invoke ConnOpenInit/ChanOpenInit handlers.
// // This bumps the connection/channel identifiers generated for chain A on the
// // next path used to run the upgrade handshake.
// // See issue 4062.
// path = ibctesting.NewPath(suite.chainA, suite.chainB)
// suite.coordinator.SetupClients(path)
// suite.Require().NoError(path.EndpointA.ConnOpenInit())
// suite.coordinator.SetupConnections(path)
// suite.Require().NoError(path.EndpointA.ChanOpenInit())

// for _, tc := range testCases {
// tc := tc
// suite.Run(tc.name, func() {
// suite.SetupTest()

// path = ibctesting.NewPath(suite.chainA, suite.chainB)
// suite.coordinator.Setup(path)

// path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion
// path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion

// tc.malleate()

// proofCounterpartyChannel, _, proofHeight := path.EndpointA.QueryChannelUpgradeProof()
// err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ChanUpgradeOpen(
// suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID,
// path.EndpointB.GetChannel().State, proofCounterpartyChannel, proofHeight,
// )

// expPass := tc.expError == nil
// if expPass {
// suite.Require().NoError(err)
// } else {
// suite.Require().ErrorIs(err, tc.expError)
// }
// })
// }
// }

func (suite *KeeperTestSuite) TestWriteUpgradeOpenChannel() {
var path *ibctesting.Path

Expand Down
Loading