508 lines
16 KiB
Go
508 lines
16 KiB
Go
package testutil
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/testutil"
|
|
|
|
"github.com/cosmos/gogoproto/proto"
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
|
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
|
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
|
)
|
|
|
|
type IntegrationTestSuite struct {
|
|
suite.Suite
|
|
|
|
cfg network.Config
|
|
network *network.Network
|
|
}
|
|
|
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
|
return &IntegrationTestSuite{cfg: cfg}
|
|
}
|
|
|
|
func (s *IntegrationTestSuite) SetupSuite() {
|
|
s.T().Log("setting up integration test suite")
|
|
|
|
var err error
|
|
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(s.network.WaitForNextBlock())
|
|
|
|
val := s.network.Validators[0]
|
|
|
|
// create a proposal with deposit
|
|
_, err = MsgSubmitLegacyProposal(val.ClientCtx, val.Address.String(),
|
|
"Text Proposal 1", "Where is the title!?", v1beta1.ProposalTypeText,
|
|
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens).String()))
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(s.network.WaitForNextBlock())
|
|
|
|
// vote for proposal
|
|
_, err = MsgVote(val.ClientCtx, val.Address.String(), "1", "yes")
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(s.network.WaitForNextBlock())
|
|
|
|
// create a proposal without deposit
|
|
_, err = MsgSubmitLegacyProposal(val.ClientCtx, val.Address.String(),
|
|
"Text Proposal 2", "Where is the title!?", v1beta1.ProposalTypeText)
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(s.network.WaitForNextBlock())
|
|
|
|
// create a proposal3 with deposit
|
|
_, err = MsgSubmitLegacyProposal(val.ClientCtx, val.Address.String(),
|
|
"Text Proposal 3", "Where is the title!?", v1beta1.ProposalTypeText,
|
|
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens).String()))
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(s.network.WaitForNextBlock())
|
|
|
|
// vote for proposal3 as val
|
|
_, err = MsgVote(val.ClientCtx, val.Address.String(), "3", "yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05")
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(s.network.WaitForNextBlock())
|
|
}
|
|
|
|
func (s *IntegrationTestSuite) TearDownSuite() {
|
|
s.T().Log("tearing down integration test suite")
|
|
s.network.Cleanup()
|
|
}
|
|
|
|
func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
|
|
val := s.network.Validators[0]
|
|
|
|
// Create a legacy proposal JSON, make sure it doesn't pass this new CLI
|
|
// command.
|
|
invalidProp := `{
|
|
"title": "",
|
|
"description": "Where is the title!?",
|
|
"type": "Text",
|
|
"deposit": "-324foocoin"
|
|
}`
|
|
invalidPropFile := testutil.WriteToNewTempFile(s.T(), invalidProp)
|
|
defer invalidPropFile.Close()
|
|
|
|
// Create a valid new proposal JSON.
|
|
propMetadata := []byte{42}
|
|
validProp := fmt.Sprintf(`
|
|
{
|
|
"messages": [
|
|
{
|
|
"@type": "/cosmos.gov.v1.MsgExecLegacyContent",
|
|
"authority": "%s",
|
|
"content": {
|
|
"@type": "/cosmos.gov.v1beta1.TextProposal",
|
|
"title": "My awesome title",
|
|
"description": "My awesome description"
|
|
}
|
|
}
|
|
],
|
|
"metadata": "%s",
|
|
"deposit": "%s"
|
|
}`, authtypes.NewModuleAddress(types.ModuleName), base64.StdEncoding.EncodeToString(propMetadata), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)))
|
|
validPropFile := testutil.WriteToNewTempFile(s.T(), validProp)
|
|
defer validPropFile.Close()
|
|
|
|
testCases := []struct {
|
|
name string
|
|
args []string
|
|
expectErr bool
|
|
expectedCode uint32
|
|
respType proto.Message
|
|
}{
|
|
{
|
|
"invalid proposal",
|
|
[]string{
|
|
invalidPropFile.Name(),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
true, 0, nil,
|
|
},
|
|
{
|
|
"valid proposal",
|
|
[]string{
|
|
validPropFile.Name(),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0, &sdk.TxResponse{},
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
tc := tc
|
|
|
|
s.Run(tc.name, func() {
|
|
cmd := cli.NewCmdSubmitProposal()
|
|
clientCtx := val.ClientCtx
|
|
|
|
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
|
if tc.expectErr {
|
|
s.Require().Error(err)
|
|
} else {
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
|
|
txResp := tc.respType.(*sdk.TxResponse)
|
|
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() {
|
|
val := s.network.Validators[0]
|
|
invalidProp := `{
|
|
"title": "",
|
|
"description": "Where is the title!?",
|
|
"type": "Text",
|
|
"deposit": "-324foocoin"
|
|
}`
|
|
invalidPropFile := testutil.WriteToNewTempFile(s.T(), invalidProp)
|
|
defer invalidPropFile.Close()
|
|
validProp := fmt.Sprintf(`{
|
|
"title": "Text Proposal",
|
|
"description": "Hello, World!",
|
|
"type": "Text",
|
|
"deposit": "%s"
|
|
}`, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)))
|
|
validPropFile := testutil.WriteToNewTempFile(s.T(), validProp)
|
|
defer validPropFile.Close()
|
|
|
|
testCases := []struct {
|
|
name string
|
|
args []string
|
|
expectErr bool
|
|
expectedCode uint32
|
|
respType proto.Message
|
|
}{
|
|
{
|
|
"invalid proposal (file)",
|
|
[]string{
|
|
fmt.Sprintf("--%s=%s", cli.FlagProposal, invalidPropFile.Name()), //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
true, 0, nil,
|
|
},
|
|
{
|
|
"invalid proposal",
|
|
[]string{
|
|
fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription), //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
|
fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
|
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
true, 0, nil,
|
|
},
|
|
{
|
|
"valid transaction (file)",
|
|
//nolint:staticcheck // we are intentionally using a deprecated flag here.
|
|
[]string{
|
|
fmt.Sprintf("--%s=%s", cli.FlagProposal, validPropFile.Name()),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0, &sdk.TxResponse{},
|
|
},
|
|
{
|
|
"valid transaction",
|
|
[]string{
|
|
fmt.Sprintf("--%s='Text Proposal'", cli.FlagTitle), //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
|
fmt.Sprintf("--%s='Where is the title!?'", cli.FlagDescription), //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
|
fmt.Sprintf("--%s=%s", cli.FlagProposalType, v1beta1.ProposalTypeText), //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
|
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)).String()),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0, &sdk.TxResponse{},
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
tc := tc
|
|
|
|
s.Run(tc.name, func() {
|
|
cmd := cli.NewCmdSubmitLegacyProposal()
|
|
clientCtx := val.ClientCtx
|
|
|
|
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
|
if tc.expectErr {
|
|
s.Require().Error(err)
|
|
} else {
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
|
|
txResp := tc.respType.(*sdk.TxResponse)
|
|
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func (s *IntegrationTestSuite) TestNewCmdDeposit() {
|
|
val := s.network.Validators[0]
|
|
|
|
testCases := []struct {
|
|
name string
|
|
args []string
|
|
expectErr bool
|
|
expectedCode uint32
|
|
}{
|
|
{
|
|
"without proposal id",
|
|
[]string{
|
|
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
true, 0,
|
|
},
|
|
{
|
|
"without deposit amount",
|
|
[]string{
|
|
"1",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
true, 0,
|
|
},
|
|
{
|
|
"deposit on non existing proposal",
|
|
[]string{
|
|
"10",
|
|
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 2,
|
|
},
|
|
{
|
|
"deposit on non existing proposal",
|
|
[]string{
|
|
"1",
|
|
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), // 10stake
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
tc := tc
|
|
var resp sdk.TxResponse
|
|
|
|
s.Run(tc.name, func() {
|
|
cmd := cli.NewCmdDeposit()
|
|
clientCtx := val.ClientCtx
|
|
|
|
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
|
if tc.expectErr {
|
|
s.Require().Error(err)
|
|
} else {
|
|
s.Require().NoError(err)
|
|
|
|
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String())
|
|
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, tc.expectedCode))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func (s *IntegrationTestSuite) TestNewCmdVote() {
|
|
val := s.network.Validators[0]
|
|
|
|
testCases := []struct {
|
|
name string
|
|
args []string
|
|
expectErr bool
|
|
expectedCode uint32
|
|
}{
|
|
{
|
|
"invalid vote",
|
|
[]string{},
|
|
true, 0,
|
|
},
|
|
{
|
|
"vote for invalid proposal",
|
|
[]string{
|
|
"10",
|
|
"yes",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--metadata=%s", "AQ=="),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 2,
|
|
},
|
|
{
|
|
"valid vote",
|
|
[]string{
|
|
"1",
|
|
"yes",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0,
|
|
},
|
|
{
|
|
"valid vote with metadata",
|
|
[]string{
|
|
"1",
|
|
"yes",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--metadata=%s", "AQ=="),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
tc := tc
|
|
s.Run(tc.name, func() {
|
|
cmd := cli.NewCmdVote()
|
|
clientCtx := val.ClientCtx
|
|
var txResp sdk.TxResponse
|
|
|
|
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
|
|
|
if tc.expectErr {
|
|
s.Require().Error(err)
|
|
} else {
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
|
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func (s *IntegrationTestSuite) TestNewCmdWeightedVote() {
|
|
val := s.network.Validators[0]
|
|
|
|
testCases := []struct {
|
|
name string
|
|
args []string
|
|
expectErr bool
|
|
expectedCode uint32
|
|
}{
|
|
{
|
|
"invalid vote",
|
|
[]string{},
|
|
true, 0,
|
|
},
|
|
{
|
|
"vote for invalid proposal",
|
|
[]string{
|
|
"10",
|
|
"yes",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 2,
|
|
},
|
|
{
|
|
"valid vote",
|
|
[]string{
|
|
"1",
|
|
"yes",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0,
|
|
},
|
|
{
|
|
"valid vote with metadata",
|
|
[]string{
|
|
"1",
|
|
"yes",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--metadata=%s", "AQ=="),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0,
|
|
},
|
|
{
|
|
"invalid valid split vote string",
|
|
[]string{
|
|
"1",
|
|
"yes/0.6,no/0.3,abstain/0.05,no_with_veto/0.05",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
true, 0,
|
|
},
|
|
{
|
|
"valid split vote",
|
|
[]string{
|
|
"1",
|
|
"yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05",
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
|
},
|
|
false, 0,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
tc := tc
|
|
s.Run(tc.name, func() {
|
|
cmd := cli.NewCmdWeightedVote()
|
|
clientCtx := val.ClientCtx
|
|
var txResp sdk.TxResponse
|
|
|
|
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
|
|
|
if tc.expectErr {
|
|
s.Require().Error(err)
|
|
} else {
|
|
s.Require().NoError(err)
|
|
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
|
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
|
|
}
|
|
})
|
|
}
|
|
}
|