forked from cosmos/interchain-security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changeover.go
53 lines (42 loc) · 2.08 KB
/
changeover.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package integration
import (
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
)
func (suite *CCVTestSuite) TestRecycleTransferChannel() {
consumerKeeper := suite.consumerApp.GetConsumerKeeper()
// Only create a connection between consumer and provider
suite.coordinator.CreateConnections(suite.path)
// Confirm transfer channel has not been persisted
transChan := consumerKeeper.GetDistributionTransmissionChannel(suite.consumerCtx())
suite.Require().Empty(transChan)
// Create transfer channel manually
distrTransferMsg := channeltypes.NewMsgChannelOpenInit(
transfertypes.PortID,
transfertypes.Version,
channeltypes.UNORDERED,
[]string{suite.path.EndpointA.ConnectionID},
transfertypes.PortID,
"", // signer unused
)
resp, err := consumerKeeper.ChannelOpenInit(suite.consumerCtx(), distrTransferMsg)
suite.Require().NoError(err)
// Confirm transfer channel still not persisted
transChan = consumerKeeper.GetDistributionTransmissionChannel(suite.consumerCtx())
suite.Require().Empty(transChan)
// Setup state s.t. the consumer keeper emulates a consumer that was previously standalone
consumerKeeper.MarkAsPrevStandaloneChain(suite.consumerCtx())
suite.Require().True(consumerKeeper.IsPrevStandaloneChain(suite.consumerCtx()))
suite.consumerApp.GetConsumerKeeper().SetDistributionTransmissionChannel(suite.consumerCtx(), resp.ChannelId)
// Now finish setting up CCV channel
suite.ExecuteCCVChannelHandshake(suite.path)
// Confirm transfer channel is now persisted with expected channel id from open init response
transChan = consumerKeeper.GetDistributionTransmissionChannel(suite.consumerCtx())
suite.Require().Equal(resp.ChannelId, transChan)
// Confirm channel exists
found := consumerKeeper.TransferChannelExists(suite.consumerCtx(), transChan)
suite.Require().True(found)
// Sanity check, only two channels should exist, one transfer and one ccv
channels := suite.consumerApp.GetIBCKeeper().ChannelKeeper.GetAllChannels(suite.consumerCtx())
suite.Require().Len(channels, 2)
}