refactor: x/bank integration and e2e tests (#12779)
* retain x/bank integration tests * Move bank end to end tests * refactor: move bank e2e tests and move common code to testutil/cli/cmd.go * refactor x/bank integration tests to remove simapp dep
This commit is contained in:
parent
f002e54d26
commit
0f7e56c6f9
@ -1,14 +1,13 @@
|
||||
//go:build e2e
|
||||
// +build e2e
|
||||
|
||||
package testutil
|
||||
package client
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
@ -16,5 +15,5 @@ import (
|
||||
func TestIntegrationTestSuite(t *testing.T) {
|
||||
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
|
||||
cfg.NumValidators = 1
|
||||
suite.Run(t, testutil.NewIntegrationTestSuite(cfg))
|
||||
suite.Run(t, NewEndToEndTestSuite(cfg))
|
||||
}
|
||||
@ -1,11 +1,12 @@
|
||||
package testutil
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/rest"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -14,7 +15,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() {
|
||||
func (s *EndToEndTestSuite) TestTotalSupplyGRPCHandler() {
|
||||
val := s.network.Validators[0]
|
||||
baseURL := val.APIAddress
|
||||
|
||||
@ -100,7 +101,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestDenomMetadataGRPCHandler() {
|
||||
func (s *EndToEndTestSuite) TestDenomMetadataGRPCHandler() {
|
||||
val := s.network.Validators[0]
|
||||
baseURL := val.APIAddress
|
||||
|
||||
@ -225,7 +226,7 @@ func (s *IntegrationTestSuite) TestDenomMetadataGRPCHandler() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestBalancesGRPCHandler() {
|
||||
func (s *EndToEndTestSuite) TestBalancesGRPCHandler() {
|
||||
val := s.network.Validators[0]
|
||||
baseURL := val.APIAddress
|
||||
|
||||
@ -1,15 +1,18 @@
|
||||
package testutil
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
@ -20,18 +23,18 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
type EndToEndTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
cfg network.Config
|
||||
network *network.Network
|
||||
}
|
||||
|
||||
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||
return &IntegrationTestSuite{cfg: cfg}
|
||||
func NewEndToEndTestSuite(cfg network.Config) *EndToEndTestSuite {
|
||||
return &EndToEndTestSuite{cfg: cfg}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupSuite() {
|
||||
func (s *EndToEndTestSuite) SetupSuite() {
|
||||
s.T().Log("setting up integration test suite")
|
||||
|
||||
genesisState := s.cfg.GenesisState
|
||||
@ -90,12 +93,12 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
func (s *EndToEndTestSuite) TearDownSuite() {
|
||||
s.T().Log("tearing down integration test suite")
|
||||
s.network.Cleanup()
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetBalancesCmd() {
|
||||
func (s *EndToEndTestSuite) TestGetBalancesCmd() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
testCases := []struct {
|
||||
@ -166,7 +169,7 @@ func (s *IntegrationTestSuite) TestGetBalancesCmd() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() {
|
||||
func (s *EndToEndTestSuite) TestGetCmdQueryTotalSupply() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
testCases := []struct {
|
||||
@ -238,7 +241,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
func (s *EndToEndTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
testCases := []struct {
|
||||
@ -365,7 +368,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestNewSendTxCmdGenOnly() {
|
||||
func (s *EndToEndTestSuite) TestNewSendTxCmdGenOnly() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
clientCtx := val.ClientCtx
|
||||
@ -383,14 +386,14 @@ func (s *IntegrationTestSuite) TestNewSendTxCmdGenOnly() {
|
||||
fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
|
||||
}
|
||||
|
||||
bz, err := MsgSendExec(clientCtx, from, to, amount, args...)
|
||||
bz, err := clitestutil.MsgSendExec(clientCtx, from, to, amount, args...)
|
||||
s.Require().NoError(err)
|
||||
tx, err := s.cfg.TxConfig.TxJSONDecoder()(bz.Bytes())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal([]sdk.Msg{types.NewMsgSend(from, to, amount)}, tx.GetMsgs())
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestNewSendTxCmdDryRun() {
|
||||
func (s *EndToEndTestSuite) TestNewSendTxCmdDryRun() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
clientCtx := val.ClientCtx
|
||||
@ -412,7 +415,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmdDryRun() {
|
||||
r, w, _ := os.Pipe()
|
||||
os.Stderr = w
|
||||
|
||||
_, err := MsgSendExec(clientCtx, from, to, amount, args...)
|
||||
_, err := clitestutil.MsgSendExec(clientCtx, from, to, amount, args...)
|
||||
s.Require().NoError(err)
|
||||
|
||||
w.Close()
|
||||
@ -422,7 +425,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmdDryRun() {
|
||||
s.Require().Regexp("gas estimate: [0-9]+", string(out))
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||
func (s *EndToEndTestSuite) TestNewSendTxCmd() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
testCases := []struct {
|
||||
@ -510,7 +513,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||
s.Run(tc.name, func() {
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
bz, err := MsgSendExec(clientCtx, tc.from, tc.to, tc.amount, tc.args...)
|
||||
bz, err := clitestutil.MsgSendExec(clientCtx, tc.from, tc.to, tc.amount, tc.args...)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
} else {
|
||||
@ -524,7 +527,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestNewMultiSendTxCmd() {
|
||||
func (s *EndToEndTestSuite) TestNewMultiSendTxCmd() {
|
||||
val := s.network.Validators[0]
|
||||
testAddr := sdk.AccAddress("cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5")
|
||||
|
||||
@ -663,3 +666,15 @@ func NewCoin(denom string, amount math.Int) *sdk.Coin {
|
||||
coin := sdk.NewCoin(denom, amount)
|
||||
return &coin
|
||||
}
|
||||
|
||||
func MsgMultiSendExec(clientCtx client.Context, from sdk.AccAddress, to []sdk.AccAddress, amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{from.String()}
|
||||
for _, addr := range to {
|
||||
args = append(args, addr.String())
|
||||
}
|
||||
|
||||
args = append(args, amount.String())
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.NewMultiSendTxCmd(), args)
|
||||
}
|
||||
1698
tests/integration/bank/keeper/keeper_test.go
Normal file
1698
tests/integration/bank/keeper/keeper_test.go
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,11 +2,14 @@ package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
cli2 "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||
)
|
||||
|
||||
// ExecTestCLICmd builds the client context, mocks the output and executes the command.
|
||||
@ -25,3 +28,17 @@ func ExecTestCLICmd(clientCtx client.Context, cmd *cobra.Command, extraArgs []st
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func MsgSendExec(clientCtx client.Context, from, to, amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{from.String(), to.String(), amount.String()}
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return ExecTestCLICmd(clientCtx, cli.NewSendTxCmd(), args)
|
||||
}
|
||||
|
||||
func QueryBalancesExec(clientCtx client.Context, address fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{address.String(), fmt.Sprintf("--%s=json", cli2.OutputFlag)}
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return ExecTestCLICmd(clientCtx, cli.GetBalancesCmd(), args)
|
||||
}
|
||||
|
||||
@ -35,7 +35,6 @@ import (
|
||||
authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
|
||||
@ -737,7 +736,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(0, len(sigs))
|
||||
|
||||
resp, err := bankcli.QueryBalancesExec(val1.ClientCtx, val1.Address)
|
||||
resp, err := clitestutil.QueryBalancesExec(val1.ClientCtx, val1.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var balRes banktypes.QueryAllBalancesResponse
|
||||
@ -799,7 +798,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||
s.Require().True(strings.Contains(res.String(), "[OK]"))
|
||||
|
||||
// Ensure foo has right amount of funds
|
||||
resp, err = bankcli.QueryBalancesExec(val1.ClientCtx, val1.Address)
|
||||
resp, err = clitestutil.QueryBalancesExec(val1.ClientCtx, val1.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = val1.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
@ -822,7 +821,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// Ensure destiny account state
|
||||
resp, err = bankcli.QueryBalancesExec(val1.ClientCtx, addr)
|
||||
resp, err = clitestutil.QueryBalancesExec(val1.ClientCtx, addr)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = val1.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
@ -830,7 +829,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||
s.Require().Equal(sendTokens.Amount, balRes.Balances.AmountOf(s.cfg.BondDenom))
|
||||
|
||||
// Ensure origin account state
|
||||
resp, err = bankcli.QueryBalancesExec(val1.ClientCtx, val1.Address)
|
||||
resp, err = clitestutil.QueryBalancesExec(val1.ClientCtx, val1.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = val1.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
@ -862,7 +861,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() {
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// Generate multisig transaction.
|
||||
multiGeneratedTx, err := bankcli.MsgSendExec(
|
||||
multiGeneratedTx, err := clitestutil.MsgSendExec(
|
||||
val1.ClientCtx,
|
||||
addr,
|
||||
val1.Address,
|
||||
@ -948,7 +947,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
||||
|
||||
addr, err := multisigRecord.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
resp, err := bankcli.QueryBalancesExec(val1.ClientCtx, addr)
|
||||
resp, err := clitestutil.QueryBalancesExec(val1.ClientCtx, addr)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var balRes banktypes.QueryAllBalancesResponse
|
||||
@ -968,7 +967,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
||||
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
resp, err = bankcli.QueryBalancesExec(val1.ClientCtx, addr)
|
||||
resp, err = clitestutil.QueryBalancesExec(val1.ClientCtx, addr)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = val1.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
@ -977,7 +976,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
||||
s.Require().Equal(sendTokens.Amount, diff.AmountOf(s.cfg.BondDenom))
|
||||
|
||||
// Generate multisig transaction.
|
||||
multiGeneratedTx, err := bankcli.MsgSendExec(
|
||||
multiGeneratedTx, err := clitestutil.MsgSendExec(
|
||||
val1.ClientCtx,
|
||||
addr,
|
||||
val1.Address,
|
||||
@ -1050,7 +1049,7 @@ func (s *IntegrationTestSuite) TestSignWithMultisig() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Generate a transaction for testing --multisig with an address not in the keyring.
|
||||
multisigTx, err := bankcli.MsgSendExec(
|
||||
multisigTx, err := clitestutil.MsgSendExec(
|
||||
val1.ClientCtx,
|
||||
val1.Address,
|
||||
val1.Address,
|
||||
@ -1102,7 +1101,7 @@ func (s *IntegrationTestSuite) TestCLIMultisign() {
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
resp, err := bankcli.QueryBalancesExec(val1.ClientCtx, addr)
|
||||
resp, err := clitestutil.QueryBalancesExec(val1.ClientCtx, addr)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var balRes banktypes.QueryAllBalancesResponse
|
||||
@ -1111,7 +1110,7 @@ func (s *IntegrationTestSuite) TestCLIMultisign() {
|
||||
s.Require().True(sendTokens.Amount.Equal(balRes.Balances.AmountOf(s.cfg.BondDenom)))
|
||||
|
||||
// Generate multisig transaction.
|
||||
multiGeneratedTx, err := bankcli.MsgSendExec(
|
||||
multiGeneratedTx, err := clitestutil.MsgSendExec(
|
||||
val1.ClientCtx,
|
||||
addr,
|
||||
val1.Address,
|
||||
@ -1189,7 +1188,7 @@ func (s *IntegrationTestSuite) TestSignBatchMultisig() {
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
generatedStd, err := bankcli.MsgSendExec(
|
||||
generatedStd, err := clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
addr,
|
||||
val.Address,
|
||||
@ -1251,7 +1250,7 @@ func (s *IntegrationTestSuite) TestMultisignBatch() {
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
generatedStd, err := bankcli.MsgSendExec(
|
||||
generatedStd, err := clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
addr,
|
||||
val.Address,
|
||||
@ -1559,7 +1558,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() {
|
||||
require.Equal(uint32(0), txRes.Code, txRes.RawLog)
|
||||
|
||||
// Make sure the addr1's balance got funded.
|
||||
queryResJSON, err := bankcli.QueryBalancesExec(val0.ClientCtx, addr1)
|
||||
queryResJSON, err := clitestutil.QueryBalancesExec(val0.ClientCtx, addr1)
|
||||
require.NoError(err)
|
||||
var queryRes banktypes.QueryAllBalancesResponse
|
||||
err = val0.ClientCtx.Codec.UnmarshalJSON(queryResJSON.Bytes(), &queryRes)
|
||||
@ -1891,11 +1890,11 @@ func (s *IntegrationTestSuite) createBankMsg(val *network.Validator, toAddr sdk.
|
||||
}
|
||||
|
||||
flags = append(flags, extraFlags...)
|
||||
return bankcli.MsgSendExec(val.ClientCtx, val.Address, toAddr, amount, flags...)
|
||||
return clitestutil.MsgSendExec(val.ClientCtx, val.Address, toAddr, amount, flags...)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) getBalances(clientCtx client.Context, addr sdk.AccAddress, denom string) math.Int {
|
||||
resp, err := bankcli.QueryBalancesExec(clientCtx, addr)
|
||||
resp, err := clitestutil.QueryBalancesExec(clientCtx, addr)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var balRes banktypes.QueryAllBalancesResponse
|
||||
|
||||
@ -19,6 +19,7 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/rest"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
@ -30,7 +31,6 @@ import (
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
authtest "github.com/cosmos/cosmos-sdk/x/auth/client/testutil"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
@ -66,7 +66,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.queryClient = tx.NewServiceClient(val.ClientCtx)
|
||||
|
||||
// Create a new MsgSend tx from val to itself.
|
||||
out, err := bankcli.MsgSendExec(
|
||||
out, err := cli.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
val.Address,
|
||||
@ -83,7 +83,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &s.txRes))
|
||||
s.Require().Equal(uint32(0), s.txRes.Code, s.txRes)
|
||||
|
||||
out, err = bankcli.MsgSendExec(
|
||||
out, err = cli.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
val.Address,
|
||||
@ -616,7 +616,7 @@ func (s *IntegrationTestSuite) TestSimMultiSigTx() {
|
||||
|
||||
// Send coins from validator to multisig.
|
||||
coins := sdk.NewInt64Coin(s.cfg.BondDenom, 15)
|
||||
_, err = bankcli.MsgSendExec(
|
||||
_, err = cli.MsgSendExec(
|
||||
val1.ClientCtx,
|
||||
val1.Address,
|
||||
addr,
|
||||
@ -632,7 +632,7 @@ func (s *IntegrationTestSuite) TestSimMultiSigTx() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Generate multisig transaction.
|
||||
multiGeneratedTx, err := bankcli.MsgSendExec(
|
||||
multiGeneratedTx, err := cli.MsgSendExec(
|
||||
val1.ClientCtx,
|
||||
addr,
|
||||
val1.Address,
|
||||
|
||||
@ -16,7 +16,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
|
||||
@ -146,7 +145,7 @@ func (s *IntegrationTestSuite) createAccount(uid string) sdk.AccAddress {
|
||||
func (s *IntegrationTestSuite) msgSendExec(grantee sdk.AccAddress) {
|
||||
val := s.network.Validators[0]
|
||||
// Send some funds to the new account.
|
||||
out, err := banktestutil.MsgSendExec(
|
||||
out, err := clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
grantee,
|
||||
@ -850,7 +849,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() {
|
||||
tokens := sdk.NewCoins(
|
||||
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(12)),
|
||||
)
|
||||
normalGeneratedTx, err := banktestutil.MsgSendExec(
|
||||
normalGeneratedTx, err := clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
grantee,
|
||||
@ -962,7 +961,7 @@ func (s *IntegrationTestSuite) TestExecSendAuthzWithAllowList() {
|
||||
sdk.NewCoin("stake", sdk.NewInt(12)),
|
||||
)
|
||||
|
||||
validGeneratedTx, err := banktestutil.MsgSendExec(
|
||||
validGeneratedTx, err := clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
allowedAddr,
|
||||
@ -975,7 +974,7 @@ func (s *IntegrationTestSuite) TestExecSendAuthzWithAllowList() {
|
||||
s.Require().NoError(err)
|
||||
execMsg := testutil.WriteToNewTempFile(s.T(), validGeneratedTx.String())
|
||||
|
||||
invalidGeneratedTx, err := banktestutil.MsgSendExec(
|
||||
invalidGeneratedTx, err := clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
notAllowedAddr,
|
||||
|
||||
@ -1,39 +1 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||
)
|
||||
|
||||
func MsgSendExec(clientCtx client.Context, from, to, amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{from.String(), to.String(), amount.String()}
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, bankcli.NewSendTxCmd(), args)
|
||||
}
|
||||
|
||||
func MsgMultiSendExec(clientCtx client.Context, from sdk.AccAddress, to []sdk.AccAddress, amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{from.String()}
|
||||
for _, addr := range to {
|
||||
args = append(args, addr.String())
|
||||
}
|
||||
|
||||
args = append(args, amount.String())
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, bankcli.NewMultiSendTxCmd(), args)
|
||||
}
|
||||
|
||||
func QueryBalancesExec(clientCtx client.Context, address fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{address.String(), fmt.Sprintf("--%s=json", cli.OutputFlag)}
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, bankcli.GetBalancesCmd(), args)
|
||||
}
|
||||
|
||||
@ -4,17 +4,17 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/testutil"
|
||||
stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type WithdrawAllTestSuite struct {
|
||||
@ -60,7 +60,7 @@ func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() {
|
||||
require.NoError(err)
|
||||
|
||||
newAddr := sdk.AccAddress(pubkey.Address())
|
||||
_, err = banktestutil.MsgSendExec(
|
||||
_, err = clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
newAddr,
|
||||
|
||||
@ -19,7 +19,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
client "github.com/cosmos/cosmos-sdk/x/group/client/cli"
|
||||
@ -73,7 +72,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
account := sdk.AccAddress(pk.Address())
|
||||
_, err = banktestutil.MsgSendExec(
|
||||
_, err = cli.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
account,
|
||||
@ -2481,7 +2480,7 @@ func (s *IntegrationTestSuite) createAccounts(quantity int) []string {
|
||||
account := sdk.AccAddress(pk.Address())
|
||||
accounts[i-1] = account.String()
|
||||
|
||||
_, err = banktestutil.MsgSendExec(
|
||||
_, err = cli.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
account,
|
||||
@ -2552,7 +2551,7 @@ func (s *IntegrationTestSuite) createGroupThresholdPolicyWithBalance(adminAddres
|
||||
|
||||
addr, err := sdk.AccAddressFromBech32(groupPolicyAddress)
|
||||
s.Require().NoError(err)
|
||||
_, err = banktestutil.MsgSendExec(clientCtx, val.Address, addr,
|
||||
_, err = cli.MsgSendExec(clientCtx, val.Address, addr,
|
||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(tokens))),
|
||||
s.commonFlags...,
|
||||
)
|
||||
|
||||
@ -6,10 +6,9 @@ import (
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/nft"
|
||||
)
|
||||
|
||||
@ -161,6 +160,6 @@ func (s *IntegrationTestSuite) initAccount() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
amount := sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200)))
|
||||
_, err = banktestutil.MsgSendExec(ctx, val.Address, s.owner, amount, args...)
|
||||
_, err = cli.MsgSendExec(ctx, val.Address, s.owner, amount, args...)
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
@ -113,7 +112,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
|
||||
require.NoError(err)
|
||||
|
||||
newAddr := sdk.AccAddress(pub.Address())
|
||||
_, err = banktestutil.MsgSendExec(
|
||||
_, err = clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
newAddr,
|
||||
@ -1083,7 +1082,7 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() {
|
||||
|
||||
newAddr := sdk.AccAddress(pub.Address())
|
||||
|
||||
_, err = banktestutil.MsgSendExec(
|
||||
_, err = clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
newAddr,
|
||||
@ -1444,7 +1443,7 @@ func (s *IntegrationTestSuite) TestBlockResults() {
|
||||
newAddr := sdk.AccAddress(pub.Address())
|
||||
|
||||
// Send some funds to the new account.
|
||||
_, err = banktestutil.MsgSendExec(
|
||||
_, err = clitestutil.MsgSendExec(
|
||||
val.ClientCtx,
|
||||
val.Address,
|
||||
newAddr,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user