Skip to content

Commit

Permalink
chore: update ica prefix for port identifiers (#434)
Browse files Browse the repository at this point in the history
* removing ICAPrefix const in favour of VersionPrefix

* updating tests
  • Loading branch information
damiannolan authored Sep 23, 2021
1 parent 7fb133e commit c149317
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
// TestOwnerAddress defines a reusable bech32 address for testing purposes
TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs"
// TestPortID defines a resuable port identifier for testing purposes
TestPortID = fmt.Sprintf("ics-27-0-0-%s", TestOwnerAddress)
TestPortID = fmt.Sprintf("%s-0-0-%s", types.VersionPrefix, TestOwnerAddress)
// TestVersion defines a resuable interchainaccounts version string for testing purposes
TestVersion = types.NewAppVersion(types.VersionPrefix, types.GenerateAddress(TestPortID).String())
)
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
// TestOwnerAddress defines a reusable bech32 address for testing purposes
TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs"
// TestPortID defines a resuable port identifier for testing purposes
TestPortID = fmt.Sprintf("ics-27-0-0-%s", TestOwnerAddress)
TestPortID = fmt.Sprintf("%s-0-0-%s", types.VersionPrefix, TestOwnerAddress)
// TestVersion defines a resuable interchainaccounts version string for testing purposes
TestVersion = types.NewAppVersion(types.VersionPrefix, types.GenerateAddress(TestPortID).String())
)
Expand Down
6 changes: 1 addition & 5 deletions modules/apps/27-interchain-accounts/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import (
connectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types"
)

const (
ICAPrefix string = "ics-27"
)

// GenerateAddress returns an sdk.AccAddress using the provided port identifier
func GenerateAddress(portID string) sdk.AccAddress {
return sdk.AccAddress(tmhash.SumTruncated([]byte(portID)))
Expand Down Expand Up @@ -50,7 +46,7 @@ func GeneratePortID(owner, connectionID, counterpartyConnectionID string) (strin
return "", sdkerrors.Wrap(err, "invalid counterparty connection identifier")
}

return fmt.Sprintf("%s-%d-%d-%s", ICAPrefix, connectionSeq, counterpartyConnectionSeq, owner), nil
return fmt.Sprintf("%s-%d-%d-%s", VersionPrefix, connectionSeq, counterpartyConnectionSeq, owner), nil
}

type InterchainAccountI interface {
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/types/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ func (suite *TypesTestSuite) TestGeneratePortID() {
{
"success",
func() {},
fmt.Sprintf("ics-27-0-0-%s", TestOwnerAddress),
fmt.Sprintf("%s-0-0-%s", types.VersionPrefix, TestOwnerAddress),
true,
},
{
"success with non matching connection sequences",
func() {
path.EndpointA.ConnectionID = "connection-1"
},
fmt.Sprintf("ics-27-1-0-%s", TestOwnerAddress),
fmt.Sprintf("%s-1-0-%s", types.VersionPrefix, TestOwnerAddress),
true,
},
{
Expand Down

0 comments on commit c149317

Please sign in to comment.