-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add genesis test for mint module
- Loading branch information
Showing
7 changed files
with
125 additions
and
8 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
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,75 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
squadtypes "github.com/cosmosquad-labs/squad/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmosquad-labs/squad/x/mint/types" | ||
) | ||
|
||
func TestGenesisState_Validate(t *testing.T) { | ||
for _, tc := range []struct { | ||
name string | ||
malleate func(genState *types.GenesisState) | ||
expectedErr string | ||
}{ | ||
{ | ||
"default is valid", | ||
func(genState *types.GenesisState) {}, | ||
"", | ||
}, | ||
{ | ||
"valid last block time", | ||
func(genState *types.GenesisState) { | ||
tmpTime := squadtypes.MustParseRFC3339("0001-01-01T00:00:00Z") | ||
genState.LastBlockTime = &tmpTime | ||
}, | ||
"", | ||
}, | ||
{ | ||
"valid last block time2", | ||
func(genState *types.GenesisState) { | ||
tmpTime := squadtypes.MustParseRFC3339("9999-12-31T00:00:00Z") | ||
genState.LastBlockTime = &tmpTime | ||
}, | ||
"", | ||
}, | ||
{ | ||
"invalid last block time", | ||
func(genState *types.GenesisState) { | ||
|
||
tmpTime := time.UnixMicro(-62136697900000001).UTC() | ||
genState.LastBlockTime = &tmpTime | ||
}, | ||
"invalid last block time", | ||
}, | ||
{ | ||
"invalid mint denom", | ||
func(genState *types.GenesisState) { | ||
genState.Params.MintDenom = "" | ||
}, | ||
"mint denom cannot be blank", | ||
}, | ||
{ | ||
"invalid mint denom2", | ||
func(genState *types.GenesisState) { | ||
genState.Params.MintDenom = "a" | ||
}, | ||
"invalid denom: a", | ||
}, | ||
} { | ||
t.Run(tc.name, func(t *testing.T) { | ||
genState := types.DefaultGenesisState() | ||
tc.malleate(genState) | ||
err := types.ValidateGenesis(*genState) | ||
if tc.expectedErr == "" { | ||
require.NoError(t, err) | ||
} else { | ||
require.EqualError(t, err, tc.expectedErr) | ||
} | ||
}) | ||
} | ||
} |
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