-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 | ||
} |