--validate-signatures should not be a flag of the sign command
as the operation performed (transaction signatures verification)
is logically distinct.
cli_test is and has always been an horrible name for package
directory as it's very much Go anti-idiomatic - _test is the
suffix used by test packages, not directories. Plus, CLI test
cases can and should live alongside other testcases that don't
require binaries to be built beforehand. Thus:
x/module/client/cli_test/*.go -> x/module/client/cli/
Test files that require sim{cli,d} shall be tagged with // +build cli_test
With regard to cli test auxiliary functions, they should live in:
x/module/client/testutil/
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
// +build cli_test
|
|
|
|
package cli_test
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
tmtypes "github.com/tendermint/tendermint/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/tests/cli"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/x/distribution/client/testutil"
|
|
"github.com/cosmos/cosmos-sdk/x/mint"
|
|
)
|
|
|
|
func TestCLIWithdrawRewards(t *testing.T) {
|
|
t.Parallel()
|
|
f := cli.InitFixtures(t)
|
|
|
|
genesisState := f.GenesisState()
|
|
inflationMin := sdk.MustNewDecFromStr("1.0")
|
|
var mintData mint.GenesisState
|
|
f.Cdc.UnmarshalJSON(genesisState[mint.ModuleName], &mintData)
|
|
mintData.Minter.Inflation = inflationMin
|
|
mintData.Params.InflationMin = inflationMin
|
|
mintData.Params.InflationMax = sdk.MustNewDecFromStr("1.0")
|
|
mintDataBz, err := f.Cdc.MarshalJSON(mintData)
|
|
require.NoError(t, err)
|
|
genesisState[mint.ModuleName] = mintDataBz
|
|
|
|
genFile := filepath.Join(f.SimdHome, "config", "genesis.json")
|
|
genDoc, err := tmtypes.GenesisDocFromFile(genFile)
|
|
require.NoError(t, err)
|
|
genDoc.AppState, err = f.Cdc.MarshalJSON(genesisState)
|
|
require.NoError(t, genDoc.SaveAs(genFile))
|
|
|
|
// start simd server
|
|
proc := f.SDStart()
|
|
t.Cleanup(func() { proc.Stop(false) })
|
|
|
|
fooAddr := f.KeyAddress(cli.KeyFoo)
|
|
rewards := testutil.QueryRewards(f, fooAddr)
|
|
require.Equal(t, 1, len(rewards.Rewards))
|
|
require.NotNil(t, rewards.Total)
|
|
|
|
fooVal := sdk.ValAddress(fooAddr)
|
|
success := testutil.TxWithdrawRewards(f, fooVal, fooAddr.String(), "-y")
|
|
require.True(t, success)
|
|
|
|
rewards = testutil.QueryRewards(f, fooAddr)
|
|
require.Equal(t, 1, len(rewards.Rewards))
|
|
|
|
require.Nil(t, rewards.Total)
|
|
f.Cleanup()
|
|
}
|