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

chore: fix test TestValidateGenesisState, use expected errors #7730

Merged
merged 7 commits into from
Dec 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
genesistypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/genesis/types"
hosttypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types"
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
ibctesting "github.com/cosmos/ibc-go/v9/testing"
essenmeoikia marked this conversation as resolved.
Show resolved Hide resolved
)

Expand All @@ -34,33 +35,33 @@ func (suite *GenesisTypesTestSuite) TestValidateGenesisState() {
testCases := []struct {
name string
malleate func()
expPass bool
expErr error
}{
{
"success",
func() {},
true,
nil,
},
{
"failed to validate - empty value",
func() {
genesisState = genesistypes.GenesisState{}
},
false,
host.ErrInvalidID,
},
{
"failed to validate - invalid controller genesis",
func() {
genesisState = *genesistypes.NewGenesisState(genesistypes.ControllerGenesisState{Ports: []string{"invalid|port"}}, genesistypes.DefaultHostGenesis())
},
false,
host.ErrInvalidID,
},
{
"failed to validate - invalid host genesis",
func() {
genesisState = *genesistypes.NewGenesisState(genesistypes.DefaultControllerGenesis(), genesistypes.HostGenesisState{})
},
false,
host.ErrInvalidID,
},
}

Expand All @@ -74,10 +75,11 @@ func (suite *GenesisTypesTestSuite) TestValidateGenesisState() {

err := genesisState.Validate()

if tc.expPass {
if tc.expErr == nil {
suite.Require().NoError(err, tc.name)
} else {
suite.Require().Error(err, tc.name)
suite.Require().ErrorIs(err, tc.expErr)
}
})
}
Expand Down
Loading