-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add counterparty port ID to controller portID (#319)
* refactor! move GeneratePortID to types, add counterpartyConnection sequence change all PortId -> PortID move GeneratePortID to types package add counterparty connection sequence argument utilize connectiontypes connectionID parsing function * refactor! use counterparty portID in interchain account address gRPC Remove existing args from gRPC request for interchain account address Use counterparty portID * tests add generate port id tests * apply self-review fixes
- Loading branch information
1 parent
881276f
commit 9d3f02c
Showing
14 changed files
with
186 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/ibc-go/modules/apps/27-interchain-accounts/types" | ||
channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" | ||
ibctesting "github.com/cosmos/ibc-go/testing" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type TypesTestSuite struct { | ||
suite.Suite | ||
|
||
coordinator *ibctesting.Coordinator | ||
|
||
chainA *ibctesting.TestChain | ||
chainB *ibctesting.TestChain | ||
} | ||
|
||
func (suite *TypesTestSuite) SetupTest() { | ||
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) | ||
|
||
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) | ||
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) | ||
} | ||
|
||
func NewICAPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { | ||
path := ibctesting.NewPath(chainA, chainB) | ||
path.EndpointA.ChannelConfig.PortID = types.PortID | ||
path.EndpointB.ChannelConfig.PortID = types.PortID | ||
path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED | ||
path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED | ||
path.EndpointA.ChannelConfig.Version = types.Version | ||
path.EndpointB.ChannelConfig.Version = types.Version | ||
|
||
return path | ||
} | ||
|
||
func TestTypesTestSuite(t *testing.T) { | ||
suite.Run(t, new(TypesTestSuite)) | ||
} | ||
|
||
func (suite *TypesTestSuite) TestGeneratePortID() { | ||
var ( | ||
path *ibctesting.Path | ||
owner string | ||
) | ||
var testCases = []struct { | ||
name string | ||
malleate func() | ||
expValue string | ||
expPass bool | ||
}{ | ||
{"success", func() {}, "ics-27-0-0-owner123", true}, | ||
{"success with non matching connection sequences", func() { | ||
path.EndpointA.ConnectionID = "connection-1" | ||
}, "ics-27-1-0-owner123", true}, | ||
{"invalid owner address", func() { | ||
owner = " " | ||
}, "", false}, | ||
{"invalid connectionID", func() { | ||
path.EndpointA.ConnectionID = "connection" | ||
}, "", false}, | ||
{"invalid counterparty connectionID", func() { | ||
path.EndpointB.ConnectionID = "connection" | ||
}, "", false}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
suite.Run(tc.name, func() { | ||
suite.SetupTest() // reset | ||
path = NewICAPath(suite.chainA, suite.chainB) | ||
suite.coordinator.Setup(path) | ||
owner = "owner123" // must be explicitly changed | ||
|
||
tc.malleate() | ||
|
||
portID, err := types.GeneratePortID(owner, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID) | ||
if tc.expPass { | ||
suite.Require().NoError(err, tc.name) | ||
suite.Require().Equal(tc.expValue, portID) | ||
} else { | ||
suite.Require().Error(err, tc.name) | ||
suite.Require().Empty(portID) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.