-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
missing cli tests for distr and mint (#6349)
Add cli tests for distribution and mint modules. Co-authored-by: Alexander Bezobchuk <[email protected]> Co-authored-by: Alessio Treglia <[email protected]>
- Loading branch information
1 parent
783e995
commit 4ecbd00
Showing
5 changed files
with
224 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// +build cli_test | ||
|
||
package cli_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/tests/cli" | ||
"github.com/cosmos/cosmos-sdk/x/mint/client/testutil" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCLIMintQueries(t *testing.T) { | ||
t.Parallel() | ||
f := cli.InitFixtures(t) | ||
|
||
proc := f.SDStart() | ||
t.Cleanup(func() { proc.Stop(false) }) | ||
|
||
params := testutil.QueryMintingParams(f) | ||
require.NotEmpty(t, params) | ||
|
||
inflation := testutil.QueryInflation(f) | ||
require.False(t, inflation.IsZero()) | ||
|
||
annualProvisions := testutil.QueryAnnualProvisions(f) | ||
require.False(t, annualProvisions.IsZero()) | ||
} |
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,44 @@ | ||
package testutil | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/tests" | ||
"github.com/cosmos/cosmos-sdk/tests/cli" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/mint/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// QueryMintingParams returns the current minting parameters | ||
func QueryMintingParams(f *cli.Fixtures, flags ...string) types.Params { | ||
cmd := fmt.Sprintf("%s query mint params %v", f.SimcliBinary, f.Flags()) | ||
out, errStr := tests.ExecuteT(f.T, cli.AddFlags(cmd, flags), "") | ||
require.Empty(f.T, errStr) | ||
|
||
var params types.Params | ||
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(out), ¶ms)) | ||
return params | ||
} | ||
|
||
// QueryInflation returns the current minting inflation value | ||
func QueryInflation(f *cli.Fixtures, flags ...string) sdk.Dec { | ||
cmd := fmt.Sprintf("%s query mint inflation %v", f.SimcliBinary, f.Flags()) | ||
out, errStr := tests.ExecuteT(f.T, cli.AddFlags(cmd, flags), "") | ||
require.Empty(f.T, errStr) | ||
|
||
var inflation sdk.Dec | ||
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(out), &inflation)) | ||
return inflation | ||
} | ||
|
||
// QueryAnnualProvisions returns the current minting annual provisions value | ||
func QueryAnnualProvisions(f *cli.Fixtures, flags ...string) sdk.Dec { | ||
cmd := fmt.Sprintf("%s query mint annual-provisions %v", f.SimcliBinary, f.Flags()) | ||
out, errStr := tests.ExecuteT(f.T, cli.AddFlags(cmd, flags), "") | ||
require.Empty(f.T, errStr) | ||
|
||
var annualProvisions sdk.Dec | ||
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(out), &annualProvisions)) | ||
return annualProvisions | ||
} |