Skip to content

Commit

Permalink
chore: fix test TestValidateGenesisState, use expected errors (#7730)
Browse files Browse the repository at this point in the history
* fix test TestValidateGenesisState

* Update modules/apps/27-interchain-accounts/genesis/types/genesis_test.go

Co-authored-by: DimitrisJim <[email protected]>

* chore: bad linter call

---------

Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: iIvaki <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent 23bc6bd commit 661277c
Showing 1 changed file with 8 additions and 6 deletions.
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"
)

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

0 comments on commit 661277c

Please sign in to comment.