Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ibc/02-client: import export GenesisState #6073

Merged
merged 12 commits into from
Apr 27, 2020
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
fedekunze committed Apr 27, 2020
commit 48fbfed06ab85af394e9859e5eb6df74fa0a0ea8
3 changes: 3 additions & 0 deletions x/ibc/07-tendermint/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func (msg MsgCreateClient) ValidateBasic() error {
if msg.Signer.Empty() {
return sdkerrors.ErrInvalidAddress
}
if msg.Header.SignedHeader.Header == nil {
return sdkerrors.Wrap(ErrInvalidHeader, "header cannot be nil")
}
// ValidateBasic of provided header with self-attested chain-id
if err := msg.Header.ValidateBasic(msg.Header.ChainID); err != nil {
return sdkerrors.Wrapf(ErrInvalidHeader, "header failed validatebasic with its own chain-id: %v", err)
Expand Down
12 changes: 5 additions & 7 deletions x/ibc/07-tendermint/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ func (suite *TendermintTestSuite) TestMsgCreateClientValidateBasic() {
}{
{ibctmtypes.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, trustingPeriod, ubdPeriod, maxClockDrift, signer), true, "success msg should pass"},
{ibctmtypes.NewMsgCreateClient("BADCHAIN", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, signer), false, "invalid client id passed"},
{ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, signer), false, "unregistered client type passed"},
{ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, signer), false, "invalid Consensus State in msg passed"},
{ibctmtypes.NewMsgCreateClient("goodchain", suite.header, 0, ubdPeriod, maxClockDrift, signer), false, "zero trusting period passed"},
{ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, 0, maxClockDrift, signer), false, "zero unbonding period passed"},
{ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, nil), false, "Empty address passed"},
{ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, nil), false, "Empty chain ID"},
{ibctmtypes.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, 0, ubdPeriod, maxClockDrift, signer), false, "zero trusting period passed"},
{ibctmtypes.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, trustingPeriod, 0, maxClockDrift, signer), false, "zero unbonding period passed"},
{ibctmtypes.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, trustingPeriod, ubdPeriod, maxClockDrift, nil), false, "Empty address passed"},
{ibctmtypes.NewMsgCreateClient(exported.ClientTypeTendermint, ibctmtypes.Header{}, trustingPeriod, ubdPeriod, maxClockDrift, signer), false, "nil header"},
}

for i, tc := range cases {
err := tc.msg.ValidateBasic()
if tc.expPass {
suite.Require().NoError(err, "Msg %d failed: %v", i, err)
suite.Require().NoError(err, "Msg %d failed: %v", i, tc.errMsg)
} else {
suite.Require().Error(err, "Invalid Msg %d passed: %s", i, tc.errMsg)
}
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/24-host/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func defaultIdentifierValidator(id string, min, max int) error {
if strings.Contains(id, "/") {
return sdkerrors.Wrapf(ErrInvalidID, "identifier %s cannot contain separator '/'", id)
}
// valid id must be between 10 and 20 characters
// valid id must be between 9 and 20 characters
if len(id) < min || len(id) > max {
return sdkerrors.Wrapf(ErrInvalidID, "identifier %s has invalid length: %d, must be between %d-%d characters", id, len(id), min, max)
}
Expand Down