forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cli test for slashing (cosmos#6102)
Reference: cosmos#5951
- Loading branch information
1 parent
4a28dd1
commit 7e72e5b
Showing
6 changed files
with
115 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// +build cli_test | ||
|
||
package cli_test | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/x/slashing/client/testutil" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
cli "github.com/cosmos/cosmos-sdk/tests/cli" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func TestCLISlashingGetParams(t *testing.T) { | ||
t.Parallel() | ||
f := cli.InitFixtures(t) | ||
|
||
// start simd server | ||
proc := f.SDStart() | ||
defer proc.Stop(false) | ||
|
||
params := testutil.QuerySlashingParams(f) | ||
require.Equal(t, int64(100), params.SignedBlocksWindow) | ||
require.Equal(t, sdk.NewDecWithPrec(5, 1), params.MinSignedPerWindow) | ||
|
||
sinfo := testutil.QuerySigningInfo(f, f.SDTendermint("show-validator")) | ||
require.Equal(t, int64(0), sinfo.StartHeight) | ||
require.False(t, sinfo.Tombstoned) | ||
|
||
// Cleanup testing directories | ||
f.Cleanup() | ||
} |
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,33 @@ | ||
package testutil | ||
|
||
import ( | ||
"fmt" | ||
"github.com/cosmos/cosmos-sdk/tests" | ||
"github.com/cosmos/cosmos-sdk/tests/cli" | ||
"github.com/cosmos/cosmos-sdk/x/slashing" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// QuerySigningInfo returns the signing info for a validator | ||
func QuerySigningInfo(f *cli.Fixtures, val string) slashing.ValidatorSigningInfo { | ||
cmd := fmt.Sprintf("%s query slashing signing-info %s %s", f.SimcliBinary, val, f.Flags()) | ||
res, errStr := tests.ExecuteT(f.T, cmd, "") | ||
require.Empty(f.T, errStr) | ||
|
||
var sinfo slashing.ValidatorSigningInfo | ||
err := f.Cdc.UnmarshalJSON([]byte(res), &sinfo) | ||
require.NoError(f.T, err) | ||
return sinfo | ||
} | ||
|
||
// QuerySlashingParams returns query slashing params | ||
func QuerySlashingParams(f *cli.Fixtures) slashing.Params { | ||
cmd := fmt.Sprintf("%s query slashing params %s", f.SimcliBinary, f.Flags()) | ||
res, errStr := tests.ExecuteT(f.T, cmd, "") | ||
require.Empty(f.T, errStr) | ||
|
||
var params slashing.Params | ||
err := f.Cdc.UnmarshalJSON([]byte(res), ¶ms) | ||
require.NoError(f.T, err) | ||
return params | ||
} |