cosmos-sdk/x/params/client/cli/tx_test.go
Alessio Treglia a940214a49
testutil cleanup and reorg (#6658)
Prepare migrating testing auxiliary functions from tests
to testutil.

Remove local duplicates on testutil.WriteToNewTempFile().

Always favor testutil.NewTestCaseDir() over ioutil.TempDir().

Add test cases for the testing auxiliary functions.
2020-07-09 14:21:20 +02:00

45 lines
987 B
Go

package cli
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/testutil"
"github.com/cosmos/cosmos-sdk/x/params/client/utils"
)
func TestParseProposal(t *testing.T) {
cdc := codec.New()
okJSON, cleanup := testutil.WriteToNewTempFile(t, `
{
"title": "Staking Param Change",
"description": "Update max validators",
"changes": [
{
"subspace": "staking",
"key": "MaxValidators",
"value": 1
}
],
"deposit": "1000stake"
}
`)
t.Cleanup(cleanup)
proposal, err := utils.ParseParamChangeProposalJSON(cdc, okJSON.Name())
require.NoError(t, err)
require.Equal(t, "Staking Param Change", proposal.Title)
require.Equal(t, "Update max validators", proposal.Description)
require.Equal(t, "1000stake", proposal.Deposit)
require.Equal(t, utils.ParamChangesJSON{
{
Subspace: "staking",
Key: "MaxValidators",
Value: []byte{0x31},
},
}, proposal.Changes)
}