-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ica: genesis state implementation (#481)
* initial genesis state draft * updating protos * including yaml tags, sorting proto file structure * updating to use range queries for active channels/interchain accounts * updating GetAllPorts test * moving test strings to expected vars
- Loading branch information
1 parent
cd2f81d
commit 3ff5bf8
Showing
11 changed files
with
872 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package interchain_accounts_test | ||
|
||
import ( | ||
ica "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts" | ||
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" | ||
) | ||
|
||
func (suite *InterchainAccountsTestSuite) TestInitGenesis() { | ||
var ( | ||
expectedChannelID string = "channel-0" | ||
) | ||
|
||
suite.SetupTest() | ||
|
||
genesisState := types.GenesisState{ | ||
Ports: []string{types.PortID, TestPortID}, | ||
ActiveChannels: []*types.ActiveChannel{ | ||
{ | ||
PortId: TestPortID, | ||
ChannelId: expectedChannelID, | ||
}, | ||
}, | ||
InterchainAccounts: []*types.RegisteredInterchainAccount{ | ||
{ | ||
PortId: TestPortID, | ||
AccountAddress: TestAccAddress.String(), | ||
}, | ||
}, | ||
} | ||
|
||
ica.InitGenesis(suite.chainA.GetContext(), suite.chainA.GetSimApp().ICAKeeper, genesisState) | ||
|
||
channelID, found := suite.chainA.GetSimApp().ICAKeeper.GetActiveChannelID(suite.chainA.GetContext(), TestPortID) | ||
suite.Require().True(found) | ||
suite.Require().Equal(expectedChannelID, channelID) | ||
|
||
accountAdrr, found := suite.chainA.GetSimApp().ICAKeeper.GetInterchainAccountAddress(suite.chainA.GetContext(), TestPortID) | ||
suite.Require().True(found) | ||
suite.Require().Equal(TestAccAddress.String(), accountAdrr) | ||
} | ||
|
||
func (suite *InterchainAccountsTestSuite) TestExportGenesis() { | ||
suite.SetupTest() | ||
path := NewICAPath(suite.chainA, suite.chainB) | ||
suite.coordinator.SetupConnections(path) | ||
|
||
err := SetupICAPath(path, TestOwnerAddress) | ||
suite.Require().NoError(err) | ||
|
||
genesisState := ica.ExportGenesis(suite.chainA.GetContext(), suite.chainA.GetSimApp().ICAKeeper) | ||
|
||
suite.Require().Equal([]string{types.PortID, TestPortID}, genesisState.GetPorts()) | ||
|
||
suite.Require().Equal(path.EndpointA.ChannelID, genesisState.ActiveChannels[0].ChannelId) | ||
suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.ActiveChannels[0].PortId) | ||
|
||
suite.Require().Equal(TestAccAddress.String(), genesisState.InterchainAccounts[0].AccountAddress) | ||
suite.Require().Equal(path.EndpointA.ChannelConfig.PortID, genesisState.InterchainAccounts[0].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
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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
package types | ||
|
||
// DefaultGenesis creates and returns the default interchain accounts GenesisState | ||
// The default GenesisState includes the standard port identifier to which all host chains must bind | ||
func DefaultGenesis() *GenesisState { | ||
return &GenesisState{ | ||
PortId: PortID, | ||
Ports: []string{PortID}, | ||
} | ||
} | ||
|
||
// NewGenesisState creates a returns a new GenesisState instance | ||
func NewGenesisState(ports []string, channels []*ActiveChannel, accounts []*RegisteredInterchainAccount) *GenesisState { | ||
return &GenesisState{ | ||
ActiveChannels: channels, | ||
InterchainAccounts: accounts, | ||
Ports: ports, | ||
} | ||
} |
Oops, something went wrong.