@@ -46,16 +46,18 @@ type InterchainAccountsTestSuite struct {
46
46
// testing chains used for convenience and readability
47
47
chainA * ibctesting.TestChain
48
48
chainB * ibctesting.TestChain
49
+ chainC * ibctesting.TestChain
49
50
}
50
51
51
52
func TestICATestSuite (t * testing.T ) {
52
53
suite .Run (t , new (InterchainAccountsTestSuite ))
53
54
}
54
55
55
56
func (suite * InterchainAccountsTestSuite ) SetupTest () {
56
- suite .coordinator = ibctesting .NewCoordinator (suite .T (), 2 )
57
+ suite .coordinator = ibctesting .NewCoordinator (suite .T (), 3 )
57
58
suite .chainA = suite .coordinator .GetChain (ibctesting .GetChainID (1 ))
58
59
suite .chainB = suite .coordinator .GetChain (ibctesting .GetChainID (2 ))
60
+ suite .chainC = suite .coordinator .GetChain (ibctesting .GetChainID (3 ))
59
61
}
60
62
61
63
func NewICAPath (chainA , chainB * ibctesting.TestChain ) * ibctesting.Path {
@@ -89,6 +91,7 @@ func RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) erro
89
91
// update port/channel ids
90
92
endpoint .ChannelID = channeltypes .FormatChannelIdentifier (channelSequence )
91
93
endpoint .ChannelConfig .PortID = portID
94
+ endpoint .ChannelConfig .Version = TestVersion
92
95
93
96
return nil
94
97
}
@@ -632,3 +635,68 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() {
632
635
})
633
636
}
634
637
}
638
+
639
+ func (suite * InterchainAccountsTestSuite ) TestSingleHostMultipleControllers () {
640
+ var (
641
+ pathAToB * ibctesting.Path
642
+ pathCToB * ibctesting.Path
643
+ )
644
+
645
+ testCases := []struct {
646
+ msg string
647
+ malleate func ()
648
+ expPass bool
649
+ }{
650
+ {
651
+ "success" ,
652
+ func () {},
653
+ true ,
654
+ },
655
+ }
656
+
657
+ for _ , tc := range testCases {
658
+ suite .Run (tc .msg , func () {
659
+ suite .SetupTest () // reset
660
+
661
+ // Setup a new path from A(controller) -> B(host)
662
+ pathAToB = NewICAPath (suite .chainA , suite .chainB )
663
+ suite .coordinator .SetupConnections (pathAToB )
664
+
665
+ err := SetupICAPath (pathAToB , TestOwnerAddress )
666
+ suite .Require ().NoError (err )
667
+
668
+ // Setup a new path from C(controller) -> B(host)
669
+ pathCToB = NewICAPath (suite .chainC , suite .chainB )
670
+ suite .coordinator .SetupConnections (pathCToB )
671
+
672
+ // NOTE: Here the version metadata is overridden to include to the next host connection sequence (i.e. chainB's connection to chainC)
673
+ // SetupICAPath() will set endpoint.ChannelConfig.Version to TestVersion
674
+ TestVersion = string (icatypes .ModuleCdc .MustMarshalJSON (& icatypes.Metadata {
675
+ Version : icatypes .Version ,
676
+ ControllerConnectionId : pathCToB .EndpointA .ConnectionID ,
677
+ HostConnectionId : pathCToB .EndpointB .ConnectionID ,
678
+ }))
679
+
680
+ err = SetupICAPath (pathCToB , TestOwnerAddress )
681
+ suite .Require ().NoError (err )
682
+
683
+ tc .malleate () // malleate mutates test data
684
+
685
+ accAddressChainA , found := suite .chainB .GetSimApp ().ICAHostKeeper .GetInterchainAccountAddress (suite .chainB .GetContext (), pathAToB .EndpointB .ConnectionID , pathAToB .EndpointA .ChannelConfig .PortID )
686
+ suite .Require ().True (found )
687
+
688
+ accAddressChainC , found := suite .chainB .GetSimApp ().ICAHostKeeper .GetInterchainAccountAddress (suite .chainB .GetContext (), pathCToB .EndpointB .ConnectionID , pathCToB .EndpointA .ChannelConfig .PortID )
689
+ suite .Require ().True (found )
690
+
691
+ suite .Require ().NotEqual (accAddressChainA , accAddressChainC )
692
+
693
+ chainAChannelID , found := suite .chainB .GetSimApp ().ICAHostKeeper .GetActiveChannelID (suite .chainB .GetContext (), pathAToB .EndpointB .ConnectionID , pathAToB .EndpointA .ChannelConfig .PortID )
694
+ suite .Require ().True (found )
695
+
696
+ chainCChannelID , found := suite .chainB .GetSimApp ().ICAHostKeeper .GetActiveChannelID (suite .chainB .GetContext (), pathCToB .EndpointB .ConnectionID , pathCToB .EndpointA .ChannelConfig .PortID )
697
+ suite .Require ().True (found )
698
+
699
+ suite .Require ().NotEqual (chainAChannelID , chainCChannelID )
700
+ })
701
+ }
702
+ }
0 commit comments