Make integration test suites reusable by apps (#6711)
* WIP on refactoring new integration tests. * godocs * godocs * Fix ineff assign * Updates * Updates * fix test * refactor crisis, distr testsuites * fix import issue * refactor x/auth * refactor x/authz * refactor x/evidence * refactor x/feegrant * refactor x/genutil * refactor x/gov * refactor x/mint * refactor x/params * refactor x/{auth_vesting, slashing, staking} * fix lint * fix tests & lint * fix lint * fix tests * lint * lint * fix lint memory * add missing `norace` build flag * update feegrant cfg * fix lint Co-authored-by: atheesh <atheesh@vitwit.com> Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
This commit is contained in:
parent
5ea817a6fb
commit
3c65c3dacd
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 2
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,6 +1,4 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -31,7 +29,6 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||||
authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||||
authtest "github.com/cosmos/cosmos-sdk/x/auth/client/testutil"
|
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||||
|
@ -44,14 +41,14 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 2
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
kb := s.network.Validators[0].ClientCtx.Keyring
|
kb := s.network.Validators[0].ClientCtx.Keyring
|
||||||
_, _, err := kb.NewMnemonic("newAccount", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
|
_, _, err := kb.NewMnemonic("newAccount", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
|
||||||
|
@ -88,14 +85,15 @@ func (s *IntegrationTestSuite) TestCLIValidateSignatures() {
|
||||||
|
|
||||||
// write unsigned tx to file
|
// write unsigned tx to file
|
||||||
unsignedTx := testutil.WriteToNewTempFile(s.T(), res.String())
|
unsignedTx := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||||
res, err = authtest.TxSignExec(val.ClientCtx, val.Address, unsignedTx.Name())
|
res, err = TxSignExec(val.ClientCtx, val.Address, unsignedTx.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
signedTx, err := val.ClientCtx.TxConfig.TxJSONDecoder()(res.Bytes())
|
signedTx, err := val.ClientCtx.TxConfig.TxJSONDecoder()(res.Bytes())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), res.String())
|
signedTxFile := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||||
txBuilder, err := val.ClientCtx.TxConfig.WrapTxBuilder(signedTx)
|
txBuilder, err := val.ClientCtx.TxConfig.WrapTxBuilder(signedTx)
|
||||||
res, err = authtest.TxValidateSignaturesExec(val.ClientCtx, signedTxFile.Name())
|
s.Require().NoError(err)
|
||||||
|
_, err = TxValidateSignaturesExec(val.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
txBuilder.SetMemo("MODIFIED TX")
|
txBuilder.SetMemo("MODIFIED TX")
|
||||||
|
@ -104,7 +102,7 @@ func (s *IntegrationTestSuite) TestCLIValidateSignatures() {
|
||||||
|
|
||||||
modifiedTxFile := testutil.WriteToNewTempFile(s.T(), string(bz))
|
modifiedTxFile := testutil.WriteToNewTempFile(s.T(), string(bz))
|
||||||
|
|
||||||
res, err = authtest.TxValidateSignaturesExec(val.ClientCtx, modifiedTxFile.Name())
|
_, err = TxValidateSignaturesExec(val.ClientCtx, modifiedTxFile.Name())
|
||||||
s.Require().EqualError(err, "signatures validation failed")
|
s.Require().EqualError(err, "signatures validation failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,30 +121,30 @@ func (s *IntegrationTestSuite) TestCLISignBatch() {
|
||||||
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)
|
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||||
|
|
||||||
// sign-batch file - offline is set but account-number and sequence are not
|
// sign-batch file - offline is set but account-number and sequence are not
|
||||||
res, err := authtest.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--offline")
|
_, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--offline")
|
||||||
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")
|
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")
|
||||||
|
|
||||||
// sign-batch file
|
// sign-batch file
|
||||||
res, err = authtest.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
|
res, err := TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||||
|
|
||||||
// sign-batch file
|
// sign-batch file
|
||||||
res, err = authtest.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
res, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||||
|
|
||||||
// Sign batch malformed tx file.
|
// Sign batch malformed tx file.
|
||||||
malformedFile := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf("%smalformed", generatedStd))
|
malformedFile := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf("%smalformed", generatedStd))
|
||||||
res, err = authtest.TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
|
_, err = TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
|
|
||||||
// Sign batch malformed tx file signature only.
|
// Sign batch malformed tx file signature only.
|
||||||
res, err = authtest.TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
_, err = TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestCLISign_AminoJSON() {
|
func (s *IntegrationTestSuite) TestCLISignAminoJSON() {
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
val1 := s.network.Validators[0]
|
val1 := s.network.Validators[0]
|
||||||
txCfg := val1.ClientCtx.TxConfig
|
txCfg := val1.ClientCtx.TxConfig
|
||||||
|
@ -168,13 +166,13 @@ func (s *IntegrationTestSuite) TestCLISign_AminoJSON() {
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
// query account info
|
// query account info
|
||||||
queryResJSON, err := authtest.QueryAccountExec(val1.ClientCtx, val1.Address)
|
queryResJSON, err := QueryAccountExec(val1.ClientCtx, val1.Address)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
var account authtypes.AccountI
|
var account authtypes.AccountI
|
||||||
require.NoError(val1.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account))
|
require.NoError(val1.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account))
|
||||||
|
|
||||||
/**** test signature-only ****/
|
/**** test signature-only ****/
|
||||||
res, err := authtest.TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag,
|
res, err := TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag,
|
||||||
sigOnlyFlag, signModeAminoFlag)
|
sigOnlyFlag, signModeAminoFlag)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
checkSignatures(require, txCfg, res.Bytes(), valInfo.GetPubKey())
|
checkSignatures(require, txCfg, res.Bytes(), valInfo.GetPubKey())
|
||||||
|
@ -184,7 +182,7 @@ func (s *IntegrationTestSuite) TestCLISign_AminoJSON() {
|
||||||
require.Equal(account.GetSequence(), sigs[0].Sequence)
|
require.Equal(account.GetSequence(), sigs[0].Sequence)
|
||||||
|
|
||||||
/**** test full output ****/
|
/**** test full output ****/
|
||||||
res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, signModeAminoFlag)
|
res, err = TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, signModeAminoFlag)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
// txCfg.UnmarshalSignatureJSON can't unmarshal a fragment of the signature, so we create this structure.
|
// txCfg.UnmarshalSignatureJSON can't unmarshal a fragment of the signature, so we create this structure.
|
||||||
|
@ -199,14 +197,14 @@ func (s *IntegrationTestSuite) TestCLISign_AminoJSON() {
|
||||||
/**** test file output ****/
|
/**** test file output ****/
|
||||||
filenameSigned := filepath.Join(s.T().TempDir(), "test_sign_out.json")
|
filenameSigned := filepath.Join(s.T().TempDir(), "test_sign_out.json")
|
||||||
fileFlag := fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, filenameSigned)
|
fileFlag := fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, filenameSigned)
|
||||||
_, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, fileFlag, signModeAminoFlag)
|
_, err = TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, fileFlag, signModeAminoFlag)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
fContent, err := ioutil.ReadFile(filenameSigned)
|
fContent, err := ioutil.ReadFile(filenameSigned)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.Equal(res.String(), string(fContent))
|
require.Equal(res.String(), string(fContent))
|
||||||
|
|
||||||
/**** try to append to the previously signed transaction ****/
|
/**** try to append to the previously signed transaction ****/
|
||||||
res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
res, err = TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||||
sigOnlyFlag, signModeAminoFlag)
|
sigOnlyFlag, signModeAminoFlag)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
checkSignatures(require, txCfg, res.Bytes(), valInfo.GetPubKey(), valInfo.GetPubKey())
|
checkSignatures(require, txCfg, res.Bytes(), valInfo.GetPubKey(), valInfo.GetPubKey())
|
||||||
|
@ -217,12 +215,13 @@ func (s *IntegrationTestSuite) TestCLISign_AminoJSON() {
|
||||||
// account. Changing the file is too much hacking, because TxDecoder returns sdk.Tx, which doesn't
|
// account. Changing the file is too much hacking, because TxDecoder returns sdk.Tx, which doesn't
|
||||||
// provide functionality to check / manage `auth_info`.
|
// provide functionality to check / manage `auth_info`.
|
||||||
// Cases with different keys are are covered in unit tests of `tx.Sign`.
|
// Cases with different keys are are covered in unit tests of `tx.Sign`.
|
||||||
res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
res, err = TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||||
sigOnlyFlag, "--overwrite", signModeAminoFlag)
|
sigOnlyFlag, "--overwrite", signModeAminoFlag)
|
||||||
|
require.NoError(err)
|
||||||
checkSignatures(require, txCfg, res.Bytes(), valInfo.GetPubKey())
|
checkSignatures(require, txCfg, res.Bytes(), valInfo.GetPubKey())
|
||||||
|
|
||||||
/**** test flagAmino ****/
|
/**** test flagAmino ****/
|
||||||
res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
res, err = TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||||
"--amino=true", signModeAminoFlag)
|
"--amino=true", signModeAminoFlag)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
|
@ -393,23 +392,23 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||||
unsignedTxFile := testutil.WriteToNewTempFile(s.T(), finalGeneratedTx.String())
|
unsignedTxFile := testutil.WriteToNewTempFile(s.T(), finalGeneratedTx.String())
|
||||||
|
|
||||||
// Test validate-signatures
|
// Test validate-signatures
|
||||||
res, err := authtest.TxValidateSignaturesExec(val1.ClientCtx, unsignedTxFile.Name())
|
res, err := TxValidateSignaturesExec(val1.ClientCtx, unsignedTxFile.Name())
|
||||||
s.Require().EqualError(err, "signatures validation failed")
|
s.Require().EqualError(err, "signatures validation failed")
|
||||||
s.Require().True(strings.Contains(res.String(), fmt.Sprintf("Signers:\n 0: %v\n\nSignatures:\n\n", val1.Address.String())))
|
s.Require().True(strings.Contains(res.String(), fmt.Sprintf("Signers:\n 0: %v\n\nSignatures:\n\n", val1.Address.String())))
|
||||||
|
|
||||||
// Test sign
|
// Test sign
|
||||||
|
|
||||||
// Does not work in offline mode
|
// Does not work in offline mode
|
||||||
res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline")
|
_, err = TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline")
|
||||||
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")
|
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")
|
||||||
|
|
||||||
// But works offline if we set account number and sequence
|
// But works offline if we set account number and sequence
|
||||||
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||||
res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1")
|
_, err = TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1")
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Sign transaction
|
// Sign transaction
|
||||||
signedTx, err := authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name())
|
signedTx, err := TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
signedFinalTx, err := txCfg.TxJSONDecoder()(signedTx.Bytes())
|
signedFinalTx, err := txCfg.TxJSONDecoder()(signedTx.Bytes())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -425,7 +424,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx.String())
|
signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx.String())
|
||||||
|
|
||||||
// validate Signature
|
// validate Signature
|
||||||
res, err = authtest.TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
res, err = TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().True(strings.Contains(res.String(), "[OK]"))
|
s.Require().True(strings.Contains(res.String(), "[OK]"))
|
||||||
|
|
||||||
|
@ -440,14 +439,14 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||||
// Test broadcast
|
// Test broadcast
|
||||||
|
|
||||||
// Does not work in offline mode
|
// Does not work in offline mode
|
||||||
res, err = authtest.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name(), "--offline")
|
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name(), "--offline")
|
||||||
s.Require().EqualError(err, "cannot broadcast tx during offline mode")
|
s.Require().EqualError(err, "cannot broadcast tx during offline mode")
|
||||||
|
|
||||||
s.Require().NoError(s.network.WaitForNextBlock())
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
|
||||||
// Broadcast correct transaction.
|
// Broadcast correct transaction.
|
||||||
val1.ClientCtx.BroadcastMode = flags.BroadcastBlock
|
val1.ClientCtx.BroadcastMode = flags.BroadcastBlock
|
||||||
res, err = authtest.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
s.Require().NoError(s.network.WaitForNextBlock())
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
@ -510,18 +509,18 @@ func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() {
|
||||||
|
|
||||||
// Multisign, sign with one signature
|
// Multisign, sign with one signature
|
||||||
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||||
account1Signature, err := authtest.TxSignExec(val1.ClientCtx, account1.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
account1Signature, err := TxSignExec(val1.ClientCtx, account1.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
||||||
|
|
||||||
multiSigWith1Signature, err := authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name())
|
multiSigWith1Signature, err := TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Save tx to file
|
// Save tx to file
|
||||||
multiSigWith1SignatureFile := testutil.WriteToNewTempFile(s.T(), multiSigWith1Signature.String())
|
multiSigWith1SignatureFile := testutil.WriteToNewTempFile(s.T(), multiSigWith1Signature.String())
|
||||||
|
|
||||||
_, err = authtest.TxValidateSignaturesExec(val1.ClientCtx, multiSigWith1SignatureFile.Name())
|
_, err = TxValidateSignaturesExec(val1.ClientCtx, multiSigWith1SignatureFile.Name())
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,12 +539,12 @@ func (s *IntegrationTestSuite) TestCLIEncode() {
|
||||||
savedTxFile := testutil.WriteToNewTempFile(s.T(), normalGeneratedTx.String())
|
savedTxFile := testutil.WriteToNewTempFile(s.T(), normalGeneratedTx.String())
|
||||||
|
|
||||||
// Encode
|
// Encode
|
||||||
encodeExec, err := authtest.TxEncodeExec(val1.ClientCtx, savedTxFile.Name())
|
encodeExec, err := TxEncodeExec(val1.ClientCtx, savedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
trimmedBase64 := strings.Trim(encodeExec.String(), "\"\n")
|
trimmedBase64 := strings.Trim(encodeExec.String(), "\"\n")
|
||||||
|
|
||||||
// Check that the transaction decodes as expected
|
// Check that the transaction decodes as expected
|
||||||
decodedTx, err := authtest.TxDecodeExec(val1.ClientCtx, trimmedBase64)
|
decodedTx, err := TxDecodeExec(val1.ClientCtx, trimmedBase64)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
txCfg := val1.ClientCtx.TxConfig
|
txCfg := val1.ClientCtx.TxConfig
|
||||||
|
@ -616,28 +615,28 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
||||||
|
|
||||||
// Sign with account1
|
// Sign with account1
|
||||||
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||||
account1Signature, err := authtest.TxSignExec(val1.ClientCtx, account1.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
account1Signature, err := TxSignExec(val1.ClientCtx, account1.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
||||||
|
|
||||||
// Sign with account1
|
// Sign with account1
|
||||||
account2Signature, err := authtest.TxSignExec(val1.ClientCtx, account2.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
account2Signature, err := TxSignExec(val1.ClientCtx, account2.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String())
|
sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String())
|
||||||
|
|
||||||
multiSigWith2Signatures, err := authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
|
multiSigWith2Signatures, err := TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Write the output to disk
|
// Write the output to disk
|
||||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), multiSigWith2Signatures.String())
|
signedTxFile := testutil.WriteToNewTempFile(s.T(), multiSigWith2Signatures.String())
|
||||||
|
|
||||||
_, err = authtest.TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
_, err = TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
val1.ClientCtx.BroadcastMode = flags.BroadcastBlock
|
val1.ClientCtx.BroadcastMode = flags.BroadcastBlock
|
||||||
_, err = authtest.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
s.Require().NoError(s.network.WaitForNextBlock())
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
@ -662,7 +661,7 @@ func (s *IntegrationTestSuite) TestCLIMultisign() {
|
||||||
val1, multisigInfo.GetAddress(),
|
val1, multisigInfo.GetAddress(),
|
||||||
sdk.NewCoins(sendTokens),
|
sdk.NewCoins(sendTokens),
|
||||||
)
|
)
|
||||||
|
s.Require().NoError(err)
|
||||||
s.Require().NoError(s.network.WaitForNextBlock())
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
|
||||||
resp, err := bankcli.QueryBalancesExec(val1.ClientCtx, multisigInfo.GetAddress())
|
resp, err := bankcli.QueryBalancesExec(val1.ClientCtx, multisigInfo.GetAddress())
|
||||||
|
@ -693,33 +692,33 @@ func (s *IntegrationTestSuite) TestCLIMultisign() {
|
||||||
|
|
||||||
// Sign with account1
|
// Sign with account1
|
||||||
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||||
account1Signature, err := authtest.TxSignExec(val1.ClientCtx, account1.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
account1Signature, err := TxSignExec(val1.ClientCtx, account1.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
||||||
|
|
||||||
// Sign with account1
|
// Sign with account1
|
||||||
account2Signature, err := authtest.TxSignExec(val1.ClientCtx, account2.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
account2Signature, err := TxSignExec(val1.ClientCtx, account2.GetAddress(), multiGeneratedTxFile.Name(), "--multisig", multisigInfo.GetAddress().String())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String())
|
sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String())
|
||||||
|
|
||||||
// Does not work in offline mode.
|
// Does not work in offline mode.
|
||||||
_, err = authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), "--offline", sign1File.Name(), sign2File.Name())
|
_, err = TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), "--offline", sign1File.Name(), sign2File.Name())
|
||||||
s.Require().EqualError(err, fmt.Sprintf("couldn't verify signature for address %s", account1.GetAddress()))
|
s.Require().EqualError(err, fmt.Sprintf("couldn't verify signature for address %s", account1.GetAddress()))
|
||||||
|
|
||||||
val1.ClientCtx.Offline = false
|
val1.ClientCtx.Offline = false
|
||||||
multiSigWith2Signatures, err := authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
|
multiSigWith2Signatures, err := TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Write the output to disk
|
// Write the output to disk
|
||||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), multiSigWith2Signatures.String())
|
signedTxFile := testutil.WriteToNewTempFile(s.T(), multiSigWith2Signatures.String())
|
||||||
|
|
||||||
_, err = authtest.TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
_, err = TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
val1.ClientCtx.BroadcastMode = flags.BroadcastBlock
|
val1.ClientCtx.BroadcastMode = flags.BroadcastBlock
|
||||||
_, err = authtest.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
s.Require().NoError(s.network.WaitForNextBlock())
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
@ -734,6 +733,7 @@ func (s *IntegrationTestSuite) TestSignBatchMultisig() {
|
||||||
account2, err := val.ClientCtx.Keyring.Key("newAccount2")
|
account2, err := val.ClientCtx.Keyring.Key("newAccount2")
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
multisigInfo, err := val.ClientCtx.Keyring.Key("multi")
|
multisigInfo, err := val.ClientCtx.Keyring.Key("multi")
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Send coins from validator to multisig.
|
// Send coins from validator to multisig.
|
||||||
sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
|
sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
|
||||||
|
@ -764,20 +764,20 @@ func (s *IntegrationTestSuite) TestSignBatchMultisig() {
|
||||||
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)
|
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||||
|
|
||||||
// sign-batch file
|
// sign-batch file
|
||||||
res, err := authtest.TxSignBatchExec(val.ClientCtx, account1.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String())
|
res, err := TxSignBatchExec(val.ClientCtx, account1.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||||
// write sigs to file
|
// write sigs to file
|
||||||
file1 := testutil.WriteToNewTempFile(s.T(), res.String())
|
file1 := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||||
|
|
||||||
// sign-batch file with account2
|
// sign-batch file with account2
|
||||||
res, err = authtest.TxSignBatchExec(val.ClientCtx, account2.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String())
|
res, err = TxSignBatchExec(val.ClientCtx, account2.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||||
|
|
||||||
// write sigs to file2
|
// write sigs to file2
|
||||||
file2 := testutil.WriteToNewTempFile(s.T(), res.String())
|
file2 := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||||
res, err = authtest.TxMultiSignExec(val.ClientCtx, multisigInfo.GetName(), filename.Name(), file1.Name(), file2.Name())
|
_, err = TxMultiSignExec(val.ClientCtx, multisigInfo.GetName(), filename.Name(), file1.Name(), file2.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,6 +790,7 @@ func (s *IntegrationTestSuite) TestMultisignBatch() {
|
||||||
account2, err := val.ClientCtx.Keyring.Key("newAccount2")
|
account2, err := val.ClientCtx.Keyring.Key("newAccount2")
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
multisigInfo, err := val.ClientCtx.Keyring.Key("multi")
|
multisigInfo, err := val.ClientCtx.Keyring.Key("multi")
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Send coins from validator to multisig.
|
// Send coins from validator to multisig.
|
||||||
sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 1000)
|
sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 1000)
|
||||||
|
@ -819,26 +820,26 @@ func (s *IntegrationTestSuite) TestMultisignBatch() {
|
||||||
filename := testutil.WriteToNewTempFile(s.T(), strings.Repeat(generatedStd.String(), 3))
|
filename := testutil.WriteToNewTempFile(s.T(), strings.Repeat(generatedStd.String(), 3))
|
||||||
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)
|
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||||
|
|
||||||
queryResJSON, err := authtest.QueryAccountExec(val.ClientCtx, multisigInfo.GetAddress())
|
queryResJSON, err := QueryAccountExec(val.ClientCtx, multisigInfo.GetAddress())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
var account authtypes.AccountI
|
var account authtypes.AccountI
|
||||||
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account))
|
s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account))
|
||||||
|
|
||||||
// sign-batch file
|
// sign-batch file
|
||||||
res, err := authtest.TxSignBatchExec(val.ClientCtx, account1.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())))
|
res, err := TxSignBatchExec(val.ClientCtx, account1.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())))
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||||
// write sigs to file
|
// write sigs to file
|
||||||
file1 := testutil.WriteToNewTempFile(s.T(), res.String())
|
file1 := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||||
|
|
||||||
// sign-batch file with account2
|
// sign-batch file with account2
|
||||||
res, err = authtest.TxSignBatchExec(val.ClientCtx, account2.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())))
|
res, err = TxSignBatchExec(val.ClientCtx, account2.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())))
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||||
|
|
||||||
// multisign the file
|
// multisign the file
|
||||||
file2 := testutil.WriteToNewTempFile(s.T(), res.String())
|
file2 := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||||
res, err = authtest.TxMultiSignBatchExec(val.ClientCtx, filename.Name(), multisigInfo.GetName(), file1.Name(), file2.Name())
|
res, err = TxMultiSignBatchExec(val.ClientCtx, filename.Name(), multisigInfo.GetName(), file1.Name(), file2.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
signedTxs := strings.Split(strings.Trim(res.String(), "\n"), "\n")
|
signedTxs := strings.Split(strings.Trim(res.String(), "\n"), "\n")
|
||||||
|
|
||||||
|
@ -846,7 +847,7 @@ func (s *IntegrationTestSuite) TestMultisignBatch() {
|
||||||
for _, signedTx := range signedTxs {
|
for _, signedTx := range signedTxs {
|
||||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx)
|
signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx)
|
||||||
val.ClientCtx.BroadcastMode = flags.BroadcastBlock
|
val.ClientCtx.BroadcastMode = flags.BroadcastBlock
|
||||||
res, err = authtest.TxBroadcastExec(val.ClientCtx, signedTxFile.Name())
|
_, err = TxBroadcastExec(val.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NoError(s.network.WaitForNextBlock())
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
}
|
}
|
||||||
|
@ -878,7 +879,7 @@ func (s *IntegrationTestSuite) TestGetAccountCmd() {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
|
|
||||||
out, err := authtest.QueryAccountExec(clientCtx, tc.address)
|
out, err := QueryAccountExec(clientCtx, tc.address)
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
s.Require().NotEqual("internal", err.Error())
|
s.Require().NotEqual("internal", err.Error())
|
||||||
|
@ -905,7 +906,7 @@ func (s *IntegrationTestSuite) TestGetAccountsCmd() {
|
||||||
s.Require().NotEmpty(res.Accounts)
|
s.Require().NotEmpty(res.Accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetBroadcastCommand_OfflineFlag(t *testing.T) {
|
func TestGetBroadcastCommandOfflineFlag(t *testing.T) {
|
||||||
clientCtx := client.Context{}.WithOffline(true)
|
clientCtx := client.Context{}.WithOffline(true)
|
||||||
clientCtx = clientCtx.WithTxConfig(simapp.MakeTestEncodingConfig().TxConfig)
|
clientCtx = clientCtx.WithTxConfig(simapp.MakeTestEncodingConfig().TxConfig)
|
||||||
|
|
||||||
|
@ -916,7 +917,7 @@ func TestGetBroadcastCommand_OfflineFlag(t *testing.T) {
|
||||||
require.EqualError(t, cmd.Execute(), "cannot broadcast tx during offline mode")
|
require.EqualError(t, cmd.Execute(), "cannot broadcast tx during offline mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetBroadcastCommand_WithoutOfflineFlag(t *testing.T) {
|
func TestGetBroadcastCommandWithoutOfflineFlag(t *testing.T) {
|
||||||
clientCtx := client.Context{}
|
clientCtx := client.Context{}
|
||||||
txCfg := simapp.MakeTestEncodingConfig().TxConfig
|
txCfg := simapp.MakeTestEncodingConfig().TxConfig
|
||||||
clientCtx = clientCtx.WithTxConfig(txCfg)
|
clientCtx = clientCtx.WithTxConfig(txCfg)
|
||||||
|
@ -1019,7 +1020,7 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() {
|
||||||
unsignedTxFile := testutil.WriteToNewTempFile(s.T(), string(txJSON))
|
unsignedTxFile := testutil.WriteToNewTempFile(s.T(), string(txJSON))
|
||||||
|
|
||||||
// Sign the file with the unsignedTx.
|
// Sign the file with the unsignedTx.
|
||||||
signedTx, err := authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name())
|
signedTx, err := TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Remove the signerInfo's `public_key` field manually from the signedTx.
|
// Remove the signerInfo's `public_key` field manually from the signedTx.
|
||||||
|
@ -1037,14 +1038,14 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() {
|
||||||
|
|
||||||
// Broadcast tx, test that it shouldn't panic.
|
// Broadcast tx, test that it shouldn't panic.
|
||||||
val1.ClientCtx.BroadcastMode = flags.BroadcastSync
|
val1.ClientCtx.BroadcastMode = flags.BroadcastSync
|
||||||
out, err := authtest.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
out, err := TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
var res sdk.TxResponse
|
var res sdk.TxResponse
|
||||||
s.Require().NoError(val1.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res))
|
s.Require().NoError(val1.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &res))
|
||||||
s.Require().NotEqual(0, res.Code)
|
s.Require().NotEqual(0, res.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestSignWithMultiSigners_AminoJSON() {
|
func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() {
|
||||||
// test case:
|
// test case:
|
||||||
// Create a transaction with 2 messages which has to be signed with 2 different keys
|
// Create a transaction with 2 messages which has to be signed with 2 different keys
|
||||||
// Sign and append the signatures using the CLI with Amino signing mode.
|
// Sign and append the signatures using the CLI with Amino signing mode.
|
||||||
|
@ -1075,14 +1076,14 @@ func (s *IntegrationTestSuite) TestSignWithMultiSigners_AminoJSON() {
|
||||||
unsignedTxFile := testutil.WriteToNewTempFile(s.T(), string(txJSON))
|
unsignedTxFile := testutil.WriteToNewTempFile(s.T(), string(txJSON))
|
||||||
|
|
||||||
// Let val0 sign first the file with the unsignedTx.
|
// Let val0 sign first the file with the unsignedTx.
|
||||||
signedByVal0, err := authtest.TxSignExec(val0.ClientCtx, val0.Address, unsignedTxFile.Name(), "--overwrite", "--sign-mode=amino-json")
|
signedByVal0, err := TxSignExec(val0.ClientCtx, val0.Address, unsignedTxFile.Name(), "--overwrite", "--sign-mode=amino-json")
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
signedByVal0File := testutil.WriteToNewTempFile(s.T(), signedByVal0.String())
|
signedByVal0File := testutil.WriteToNewTempFile(s.T(), signedByVal0.String())
|
||||||
|
|
||||||
// Then let val1 sign the file with signedByVal0.
|
// Then let val1 sign the file with signedByVal0.
|
||||||
val1AccNum, val1Seq, err := val0.ClientCtx.AccountRetriever.GetAccountNumberSequence(val0.ClientCtx, val1.Address)
|
val1AccNum, val1Seq, err := val0.ClientCtx.AccountRetriever.GetAccountNumberSequence(val0.ClientCtx, val1.Address)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
signedTx, err := authtest.TxSignExec(
|
signedTx, err := TxSignExec(
|
||||||
val1.ClientCtx, val1.Address, signedByVal0File.Name(),
|
val1.ClientCtx, val1.Address, signedByVal0File.Name(),
|
||||||
"--offline", fmt.Sprintf("--account-number=%d", val1AccNum), fmt.Sprintf("--sequence=%d", val1Seq), "--sign-mode=amino-json",
|
"--offline", fmt.Sprintf("--account-number=%d", val1AccNum), fmt.Sprintf("--sequence=%d", val1Seq), "--sign-mode=amino-json",
|
||||||
)
|
)
|
||||||
|
@ -1090,7 +1091,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSigners_AminoJSON() {
|
||||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx.String())
|
signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx.String())
|
||||||
|
|
||||||
// Now let's try to send this tx.
|
// Now let's try to send this tx.
|
||||||
res, err := authtest.TxBroadcastExec(
|
res, err := TxBroadcastExec(
|
||||||
val0.ClientCtx,
|
val0.ClientCtx,
|
||||||
signedTxFile.Name(),
|
signedTxFile.Name(),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
|
@ -1120,7 +1121,3 @@ func (s *IntegrationTestSuite) createBankMsg(val *network.Validator, toAddr sdk.
|
||||||
flags = append(flags, extraFlags...)
|
flags = append(flags, extraFlags...)
|
||||||
return bankcli.MsgSendExec(val.ClientCtx, val.Address, toAddr, amount, flags...)
|
return bankcli.MsgSendExec(val.ClientCtx, val.Address, toAddr, amount, flags...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,10 +1,7 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
@ -23,14 +20,14 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -47,8 +44,8 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
"create a continuous vesting account": {
|
"create a continuous vesting account": {
|
||||||
args: []string{
|
args: []string{
|
||||||
|
@ -61,8 +58,8 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
respType: &sdk.TxResponse{},
|
|
||||||
expectedCode: 0,
|
expectedCode: 0,
|
||||||
|
respType: &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
"create a delayed vesting account": {
|
"create a delayed vesting account": {
|
||||||
args: []string{
|
args: []string{
|
||||||
|
@ -76,8 +73,8 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
respType: &sdk.TxResponse{},
|
|
||||||
expectedCode: 0,
|
expectedCode: 0,
|
||||||
|
respType: &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
"invalid address": {
|
"invalid address": {
|
||||||
args: []string{
|
args: []string{
|
||||||
|
@ -87,8 +84,8 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
|
||||||
},
|
},
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
respType: &sdk.TxResponse{},
|
|
||||||
expectedCode: 0,
|
expectedCode: 0,
|
||||||
|
respType: &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
"invalid coins": {
|
"invalid coins": {
|
||||||
args: []string{
|
args: []string{
|
||||||
|
@ -98,8 +95,8 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
|
||||||
},
|
},
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
respType: &sdk.TxResponse{},
|
|
||||||
expectedCode: 0,
|
expectedCode: 0,
|
||||||
|
respType: &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
"invalid end time": {
|
"invalid end time": {
|
||||||
args: []string{
|
args: []string{
|
||||||
|
@ -109,8 +106,8 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
|
||||||
},
|
},
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
respType: &sdk.TxResponse{},
|
|
||||||
expectedCode: 0,
|
expectedCode: 0,
|
||||||
|
respType: &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +130,3 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,6 +1,4 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -14,7 +12,6 @@ import (
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
||||||
|
|
||||||
authztestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/authz/types"
|
"github.com/cosmos/cosmos-sdk/x/authz/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,7 +21,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() {
|
||||||
grantee := s.grantee
|
grantee := s.grantee
|
||||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||||
|
|
||||||
_, err := authztestutil.ExecGrantAuthorization(
|
_, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -102,7 +99,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() {
|
||||||
grantee := s.grantee
|
grantee := s.grantee
|
||||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||||
|
|
||||||
_, err := authztestutil.ExecGrantAuthorization(
|
_, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
|
@ -1,10 +1,7 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
|
@ -25,8 +22,6 @@ import (
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||||
stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli"
|
stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli"
|
||||||
|
|
||||||
authztestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
|
|
||||||
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
|
||||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
|
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||||
)
|
)
|
||||||
|
@ -39,14 +34,14 @@ type IntegrationTestSuite struct {
|
||||||
grantee sdk.AccAddress
|
grantee sdk.AccAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
|
|
||||||
|
@ -88,8 +83,6 @@ func (s *IntegrationTestSuite) TearDownSuite() {
|
||||||
var typeMsgSend = bank.SendAuthorization{}.MethodName()
|
var typeMsgSend = bank.SendAuthorization{}.MethodName()
|
||||||
var typeMsgVote = "/cosmos.gov.v1beta1.Msg/Vote"
|
var typeMsgVote = "/cosmos.gov.v1beta1.Msg/Vote"
|
||||||
|
|
||||||
var commonFlags = []string{}
|
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
grantee := s.grantee
|
grantee := s.grantee
|
||||||
|
@ -169,8 +162,8 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
nil, 0,
|
nil, 0,
|
||||||
|
@ -186,7 +179,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
&sdk.TxResponse{}, 0,
|
&sdk.TxResponse{}, 0,
|
||||||
|
@ -202,7 +195,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
&sdk.TxResponse{}, 0,
|
&sdk.TxResponse{}, 0,
|
||||||
|
@ -218,7 +211,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
&sdk.TxResponse{}, 0,
|
&sdk.TxResponse{}, 0,
|
||||||
|
@ -234,7 +227,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
&sdk.TxResponse{}, 0,
|
&sdk.TxResponse{}, 0,
|
||||||
|
@ -276,7 +269,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
||||||
tc := tc
|
tc := tc
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
out, err := authztestutil.ExecGrantAuthorization(
|
out, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
tc.args,
|
tc.args,
|
||||||
)
|
)
|
||||||
|
@ -305,7 +298,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() {
|
||||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||||
|
|
||||||
// send-authorization
|
// send-authorization
|
||||||
_, err := authztestutil.ExecGrantAuthorization(
|
_, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -321,7 +314,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// generic-authorization
|
// generic-authorization
|
||||||
_, err = authztestutil.ExecGrantAuthorization(
|
_, err = ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -346,7 +339,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() {
|
||||||
{
|
{
|
||||||
"invalid grantee address",
|
"invalid grantee address",
|
||||||
[]string{
|
[]string{
|
||||||
"invlid grantee",
|
"invalid grantee",
|
||||||
typeMsgSend,
|
typeMsgSend,
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
|
fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
|
||||||
|
@ -419,7 +412,7 @@ func (s *IntegrationTestSuite) TestExecAuthorizationWithExpiration() {
|
||||||
grantee := s.grantee
|
grantee := s.grantee
|
||||||
tenSeconds := time.Now().Add(time.Second * time.Duration(10)).Unix()
|
tenSeconds := time.Now().Add(time.Second * time.Duration(10)).Unix()
|
||||||
|
|
||||||
_, err := authztestutil.ExecGrantAuthorization(
|
_, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -459,7 +452,7 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() {
|
||||||
grantee := s.grantee
|
grantee := s.grantee
|
||||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||||
|
|
||||||
_, err := authztestutil.ExecGrantAuthorization(
|
_, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -548,7 +541,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() {
|
||||||
grantee := s.grantee
|
grantee := s.grantee
|
||||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||||
|
|
||||||
_, err := authztestutil.ExecGrantAuthorization(
|
_, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -565,7 +558,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() {
|
||||||
tokens := sdk.NewCoins(
|
tokens := sdk.NewCoins(
|
||||||
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(12)),
|
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(12)),
|
||||||
)
|
)
|
||||||
normalGeneratedTx, err := bankcli.MsgSendExec(
|
normalGeneratedTx, err := banktestutil.MsgSendExec(
|
||||||
val.ClientCtx,
|
val.ClientCtx,
|
||||||
val.Address,
|
val.Address,
|
||||||
grantee,
|
grantee,
|
||||||
|
@ -633,7 +626,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||||
grantee := s.grantee
|
grantee := s.grantee
|
||||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||||
|
|
||||||
_, err := authztestutil.ExecGrantAuthorization(
|
_, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -643,7 +636,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -725,7 +718,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test delegate no spend-limit
|
// test delegate no spend-limit
|
||||||
_, err = authztestutil.ExecGrantAuthorization(
|
_, err = ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -734,7 +727,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -802,7 +795,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test delegating to denied validator
|
// test delegating to denied validator
|
||||||
_, err = authztestutil.ExecGrantAuthorization(
|
_, err = ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -812,7 +805,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -838,7 +831,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() {
|
||||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||||
|
|
||||||
// granting undelegate msg authorization
|
// granting undelegate msg authorization
|
||||||
_, err := authztestutil.ExecGrantAuthorization(
|
_, err := ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -848,7 +841,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -944,7 +937,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// grant undelegate authorization without limit
|
// grant undelegate authorization without limit
|
||||||
_, err = authztestutil.ExecGrantAuthorization(
|
_, err = ExecGrantAuthorization(
|
||||||
val,
|
val,
|
||||||
[]string{
|
[]string{
|
||||||
grantee.String(),
|
grantee.String(),
|
||||||
|
@ -953,7 +946,7 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, fmt.Sprintf("%s", val.ValAddress.String())),
|
fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -1020,7 +1013,3 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,15 +1,12 @@
|
||||||
package cli_test
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
@ -17,7 +14,6 @@ import (
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
"github.com/cosmos/cosmos-sdk/types/query"
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
"github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,15 +24,16 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
genesisState := s.cfg.GenesisState
|
||||||
genesisState := cfg.GenesisState
|
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
var bankGenesis types.GenesisState
|
var bankGenesis types.GenesisState
|
||||||
s.Require().NoError(cfg.Codec.UnmarshalJSON(genesisState[types.ModuleName], &bankGenesis))
|
s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[types.ModuleName], &bankGenesis))
|
||||||
|
|
||||||
bankGenesis.DenomMetadata = []types.Metadata{
|
bankGenesis.DenomMetadata = []types.Metadata{
|
||||||
{
|
{
|
||||||
|
@ -78,13 +75,12 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
bankGenesisBz, err := cfg.Codec.MarshalJSON(&bankGenesis)
|
bankGenesisBz, err := s.cfg.Codec.MarshalJSON(&bankGenesis)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
genesisState[types.ModuleName] = bankGenesisBz
|
genesisState[types.ModuleName] = bankGenesisBz
|
||||||
cfg.GenesisState = genesisState
|
s.cfg.GenesisState = genesisState
|
||||||
|
|
||||||
s.cfg = cfg
|
s.network = network.New(s.T(), s.cfg)
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err = s.network.WaitForHeight(1)
|
_, err = s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -199,7 +195,10 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() {
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
respType: &sdk.Coin{},
|
respType: &sdk.Coin{},
|
||||||
expected: &sdk.Coin{s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))},
|
expected: &sdk.Coin{
|
||||||
|
Denom: s.cfg.BondDenom,
|
||||||
|
Amount: s.cfg.StakingTokens.Add(sdk.NewInt(10)),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "total supply of a bogus denom",
|
name: "total supply of a bogus denom",
|
||||||
|
@ -209,7 +208,10 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() {
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
respType: &sdk.Coin{},
|
respType: &sdk.Coin{},
|
||||||
expected: &sdk.Coin{"foobar", sdk.ZeroInt()},
|
expected: &sdk.Coin{
|
||||||
|
Denom: "foobar",
|
||||||
|
Amount: sdk.ZeroInt(),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,9 +366,6 @@ func (s *IntegrationTestSuite) TestNewSendTxCmdGenOnly() {
|
||||||
|
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
|
|
||||||
ctx := context.Background()
|
|
||||||
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
|
|
||||||
|
|
||||||
from := val.Address
|
from := val.Address
|
||||||
to := val.Address
|
to := val.Address
|
||||||
amount := sdk.NewCoins(
|
amount := sdk.NewCoins(
|
||||||
|
@ -380,7 +379,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmdGenOnly() {
|
||||||
fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
|
fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
|
||||||
}
|
}
|
||||||
|
|
||||||
bz, err := banktestutil.MsgSendExec(clientCtx, from, to, amount, args...)
|
bz, err := MsgSendExec(clientCtx, from, to, amount, args...)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
tx, err := s.cfg.TxConfig.TxJSONDecoder()(bz.Bytes())
|
tx, err := s.cfg.TxConfig.TxJSONDecoder()(bz.Bytes())
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -399,8 +398,8 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||||
amount sdk.Coins
|
amount sdk.Coins
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -415,9 +414,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false,
|
false, 0, &sdk.TxResponse{},
|
||||||
&sdk.TxResponse{},
|
|
||||||
0,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"not enough fees",
|
"not enough fees",
|
||||||
|
@ -433,8 +430,8 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1))).String()),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
&sdk.TxResponse{},
|
|
||||||
sdkerrors.ErrInsufficientFee.ABCICode(),
|
sdkerrors.ErrInsufficientFee.ABCICode(),
|
||||||
|
&sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"not enough gas",
|
"not enough gas",
|
||||||
|
@ -451,8 +448,8 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||||
"--gas=10",
|
"--gas=10",
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
&sdk.TxResponse{},
|
|
||||||
sdkerrors.ErrOutOfGas.ABCICode(),
|
sdkerrors.ErrOutOfGas.ABCICode(),
|
||||||
|
&sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +459,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
|
|
||||||
bz, err := banktestutil.MsgSendExec(clientCtx, tc.from, tc.to, tc.amount, tc.args...)
|
bz, err := MsgSendExec(clientCtx, tc.from, tc.to, tc.amount, tc.args...)
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -476,8 +473,60 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
// TestBankMsgService does a basic test of whether or not service Msg's as defined
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
// in ADR 031 work in the most basic end-to-end case.
|
||||||
|
func (s *IntegrationTestSuite) TestBankMsgService() {
|
||||||
|
val := s.network.Validators[0]
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
from, to sdk.AccAddress
|
||||||
|
amount sdk.Coins
|
||||||
|
args []string
|
||||||
|
expectErr bool
|
||||||
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
|
rawLogContains string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"valid transaction",
|
||||||
|
val.Address,
|
||||||
|
val.Address,
|
||||||
|
sdk.NewCoins(
|
||||||
|
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)),
|
||||||
|
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)),
|
||||||
|
),
|
||||||
|
[]string{
|
||||||
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
&sdk.TxResponse{},
|
||||||
|
"/cosmos.bank.v1beta1.Msg/Send", // indicates we are using ServiceMsg and not a regular Msg
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
tc := tc
|
||||||
|
|
||||||
|
s.Run(tc.name, func() {
|
||||||
|
clientCtx := val.ClientCtx
|
||||||
|
|
||||||
|
bz, err := MsgSendExec(clientCtx, tc.from, tc.to, tc.amount, tc.args...)
|
||||||
|
if tc.expectErr {
|
||||||
|
s.Require().Error(err)
|
||||||
|
} else {
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(bz.Bytes(), tc.respType), bz.String())
|
||||||
|
txResp := tc.respType.(*sdk.TxResponse)
|
||||||
|
s.Require().Equal(tc.expectedCode, txResp.Code)
|
||||||
|
s.Require().Contains(txResp.RawLog, tc.rawLogContains)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCoin(denom string, amount sdk.Int) *sdk.Coin {
|
func NewCoin(denom string, amount sdk.Int) *sdk.Coin {
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,10 +1,7 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
@ -23,15 +20,14 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
@ -48,8 +44,8 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"missing module",
|
"missing module",
|
||||||
|
@ -60,7 +56,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"missing invariant route",
|
"missing invariant route",
|
||||||
|
@ -71,7 +67,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -82,7 +78,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +102,3 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,34 +1,32 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/testutil"
|
"github.com/cosmos/cosmos-sdk/testutil"
|
||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
testnet "github.com/cosmos/cosmos-sdk/testutil/network"
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
|
"github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
|
||||||
distrtestutil "github.com/cosmos/cosmos-sdk/x/distribution/client/testutil"
|
|
||||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IntegrationTestSuite struct {
|
type IntegrationTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
cfg testnet.Config
|
cfg network.Config
|
||||||
network *testnet.Network
|
network *network.Network
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetupTest creates a new network for _each_ integration test. We create a new
|
// SetupTest creates a new network for _each_ integration test. We create a new
|
||||||
|
@ -38,25 +36,21 @@ type IntegrationTestSuite struct {
|
||||||
func (s *IntegrationTestSuite) SetupTest() {
|
func (s *IntegrationTestSuite) SetupTest() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := testnet.DefaultConfig()
|
genesisState := s.cfg.GenesisState
|
||||||
genesisState := cfg.GenesisState
|
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
var mintData minttypes.GenesisState
|
var mintData minttypes.GenesisState
|
||||||
s.Require().NoError(cfg.Codec.UnmarshalJSON(genesisState[minttypes.ModuleName], &mintData))
|
s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[minttypes.ModuleName], &mintData))
|
||||||
|
|
||||||
inflation := sdk.MustNewDecFromStr("1.0")
|
inflation := sdk.MustNewDecFromStr("1.0")
|
||||||
mintData.Minter.Inflation = inflation
|
mintData.Minter.Inflation = inflation
|
||||||
mintData.Params.InflationMin = inflation
|
mintData.Params.InflationMin = inflation
|
||||||
mintData.Params.InflationMax = inflation
|
mintData.Params.InflationMax = inflation
|
||||||
|
|
||||||
mintDataBz, err := cfg.Codec.MarshalJSON(&mintData)
|
mintDataBz, err := s.cfg.Codec.MarshalJSON(&mintData)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
genesisState[minttypes.ModuleName] = mintDataBz
|
genesisState[minttypes.ModuleName] = mintDataBz
|
||||||
cfg.GenesisState = genesisState
|
s.cfg.GenesisState = genesisState
|
||||||
|
|
||||||
s.cfg = cfg
|
s.network = network.New(s.T(), s.cfg)
|
||||||
s.network = testnet.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err = s.network.WaitForHeight(1)
|
_, err = s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -134,7 +128,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
`{"rewards":[{"denom":"stake","amount":"232.260000000000000000"}]}`,
|
`{"rewards":[{"denom":"stake","amount":"1164.240000000000000000"}]}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text output",
|
"text output",
|
||||||
|
@ -145,7 +139,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
`rewards:
|
`rewards:
|
||||||
- amount: "232.260000000000000000"
|
- amount: "1164.240000000000000000"
|
||||||
denom: stake`,
|
denom: stake`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -197,7 +191,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorCommission() {
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
`{"commission":[{"denom":"stake","amount":"116.130000000000000000"}]}`,
|
`{"commission":[{"denom":"stake","amount":"464.520000000000000000"}]}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text output",
|
"text output",
|
||||||
|
@ -208,7 +202,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorCommission() {
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
`commission:
|
`commission:
|
||||||
- amount: "116.130000000000000000"
|
- amount: "464.520000000000000000"
|
||||||
denom: stake`,
|
denom: stake`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -345,7 +339,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||||
{
|
{
|
||||||
"json output",
|
"json output",
|
||||||
[]string{
|
[]string{
|
||||||
fmt.Sprintf("--%s=10", flags.FlagHeight),
|
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||||
addr.String(),
|
addr.String(),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
|
@ -355,7 +349,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||||
{
|
{
|
||||||
"json output (specific validator)",
|
"json output (specific validator)",
|
||||||
[]string{
|
[]string{
|
||||||
fmt.Sprintf("--%s=10", flags.FlagHeight),
|
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||||
addr.String(), valAddr.String(),
|
addr.String(), valAddr.String(),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
|
@ -366,7 +360,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||||
"text output",
|
"text output",
|
||||||
[]string{
|
[]string{
|
||||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||||
fmt.Sprintf("--%s=10", flags.FlagHeight),
|
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||||
addr.String(),
|
addr.String(),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
@ -383,7 +377,7 @@ total:
|
||||||
"text output (specific validator)",
|
"text output (specific validator)",
|
||||||
[]string{
|
[]string{
|
||||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||||
fmt.Sprintf("--%s=10", flags.FlagHeight),
|
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||||
addr.String(), valAddr.String(),
|
addr.String(), valAddr.String(),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
@ -458,8 +452,8 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() {
|
||||||
valAddr fmt.Stringer
|
valAddr fmt.Stringer
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid validator address",
|
"invalid validator address",
|
||||||
|
@ -470,7 +464,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -481,7 +475,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction (with commission)",
|
"valid transaction (with commission)",
|
||||||
|
@ -493,7 +487,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,10 +497,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
|
|
||||||
ctx := context.Background()
|
bz, err := MsgWithdrawDelegatorRewardExec(clientCtx, tc.valAddr, tc.args...)
|
||||||
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
|
|
||||||
|
|
||||||
bz, err := distrtestutil.MsgWithdrawDelegatorRewardExec(clientCtx, tc.valAddr, tc.args...)
|
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -527,8 +518,8 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"valid transaction (offline)",
|
"valid transaction (offline)",
|
||||||
|
@ -538,7 +529,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -548,7 +539,7 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,8 +571,8 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid withdraw address",
|
"invalid withdraw address",
|
||||||
|
@ -592,7 +583,7 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -603,7 +594,7 @@ func (s *IntegrationTestSuite) TestNewSetWithdrawAddrCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,8 +626,8 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid funding amount",
|
"invalid funding amount",
|
||||||
|
@ -647,7 +638,7 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -658,7 +649,7 @@ func (s *IntegrationTestSuite) TestNewFundCommunityPoolCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +683,9 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
|
||||||
"amount": "-343foocoin",
|
"amount": "-343foocoin",
|
||||||
"deposit": -324foocoin
|
"deposit": -324foocoin
|
||||||
}`
|
}`
|
||||||
|
|
||||||
invalidPropFile := testutil.WriteToNewTempFile(s.T(), invalidProp)
|
invalidPropFile := testutil.WriteToNewTempFile(s.T(), invalidProp)
|
||||||
|
|
||||||
validProp := fmt.Sprintf(`{
|
validProp := fmt.Sprintf(`{
|
||||||
"title": "Community Pool Spend",
|
"title": "Community Pool Spend",
|
||||||
"description": "Pay me some Atoms!",
|
"description": "Pay me some Atoms!",
|
||||||
|
@ -700,13 +693,14 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
|
||||||
"amount": "%s",
|
"amount": "%s",
|
||||||
"deposit": "%s"
|
"deposit": "%s"
|
||||||
}`, val.Address.String(), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)))
|
}`, val.Address.String(), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431)))
|
||||||
|
|
||||||
validPropFile := testutil.WriteToNewTempFile(s.T(), validProp)
|
validPropFile := testutil.WriteToNewTempFile(s.T(), validProp)
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid proposal",
|
"invalid proposal",
|
||||||
|
@ -717,7 +711,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
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()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -728,7 +722,7 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,7 +747,3 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,31 +1,30 @@
|
||||||
package cli_test
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
testnet "github.com/cosmos/cosmos-sdk/testutil/network"
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
"github.com/cosmos/cosmos-sdk/x/evidence/client/cli"
|
"github.com/cosmos/cosmos-sdk/x/evidence/client/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IntegrationTestSuite struct {
|
type IntegrationTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
cfg testnet.Config
|
cfg network.Config
|
||||||
network *testnet.Network
|
network *network.Network
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := testnet.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = testnet.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -36,10 +35,6 @@ func (s *IntegrationTestSuite) TearDownSuite() {
|
||||||
s.network.Cleanup()
|
s.network.Cleanup()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestGetQueryCmd() {
|
func (s *IntegrationTestSuite) TestGetQueryCmd() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 3
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,6 +1,4 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -33,6 +31,10 @@ type IntegrationTestSuite struct {
|
||||||
addedGrant types.FeeAllowanceGrant
|
addedGrant types.FeeAllowanceGrant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
|
@ -40,11 +42,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Skip("skipping test in unit-tests mode.")
|
s.T().Skip("skipping test in unit-tests mode.")
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 3
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -255,8 +253,8 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"wrong granter address",
|
"wrong granter address",
|
||||||
|
@ -269,7 +267,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"wrong grantee address",
|
"wrong grantee address",
|
||||||
|
@ -282,7 +280,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid basic fee grant",
|
"valid basic fee grant",
|
||||||
|
@ -295,7 +293,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid basic fee grant without spend limit",
|
"valid basic fee grant without spend limit",
|
||||||
|
@ -307,7 +305,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid basic fee grant without expiration",
|
"valid basic fee grant without expiration",
|
||||||
|
@ -320,7 +318,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid basic fee grant without spend-limit and expiration",
|
"valid basic fee grant without spend-limit and expiration",
|
||||||
|
@ -332,7 +330,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"try to add existed grant",
|
"try to add existed grant",
|
||||||
|
@ -345,7 +343,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 18,
|
false, 18, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid number of args(periodic fee grant)",
|
"invalid number of args(periodic fee grant)",
|
||||||
|
@ -360,7 +358,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"period mentioned and period limit omitted, invalid periodic grant",
|
"period mentioned and period limit omitted, invalid periodic grant",
|
||||||
|
@ -375,7 +373,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"period cannot be greater than the actual expiration(periodic fee grant)",
|
"period cannot be greater than the actual expiration(periodic fee grant)",
|
||||||
|
@ -391,7 +389,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid periodic fee grant",
|
"valid periodic fee grant",
|
||||||
|
@ -407,7 +405,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid periodic fee grant without spend-limit",
|
"valid periodic fee grant without spend-limit",
|
||||||
|
@ -422,7 +420,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid periodic fee grant without expiration",
|
"valid periodic fee grant without expiration",
|
||||||
|
@ -437,7 +435,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid periodic fee grant without spend-limit and expiration",
|
"valid periodic fee grant without spend-limit and expiration",
|
||||||
|
@ -451,7 +449,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,8 +489,8 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid grantee",
|
"invalid grantee",
|
||||||
|
@ -504,9 +502,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
true,
|
true, 0, nil,
|
||||||
nil,
|
|
||||||
0,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid grantee",
|
"invalid grantee",
|
||||||
|
@ -518,9 +514,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
true,
|
true, 0, nil,
|
||||||
nil,
|
|
||||||
0,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Non existed grant",
|
"Non existed grant",
|
||||||
|
@ -532,9 +526,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false,
|
false, 4, &sdk.TxResponse{},
|
||||||
&sdk.TxResponse{},
|
|
||||||
4,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Valid revoke",
|
"Valid revoke",
|
||||||
|
@ -546,9 +538,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
|
||||||
},
|
},
|
||||||
commonFlags...,
|
commonFlags...,
|
||||||
),
|
),
|
||||||
false,
|
false, 0, &sdk.TxResponse{},
|
||||||
&sdk.TxResponse{},
|
|
||||||
0,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +786,3 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package cli_test
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -52,6 +52,7 @@ func (s *IntegrationTestSuite) TestMigrateGenesis() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
tc := tc
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
genesisFile := testutil.WriteToNewTempFile(s.T(), tc.genesis)
|
genesisFile := testutil.WriteToNewTempFile(s.T(), tc.genesis)
|
||||||
jsonOutput, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cli.MigrateGenesisCmd(), []string{tc.target, genesisFile.Name()})
|
jsonOutput, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cli.MigrateGenesisCmd(), []string{tc.target, genesisFile.Name()})
|
|
@ -1,4 +1,4 @@
|
||||||
package cli_test
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -6,7 +6,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
@ -28,14 +27,14 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -91,7 +90,3 @@ func (s *IntegrationTestSuite) TestGenTxCmd() {
|
||||||
err = tx.ValidateBasic()
|
err = tx.ValidateBasic()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package cli_test
|
package testutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/testutil"
|
"github.com/cosmos/cosmos-sdk/testutil"
|
||||||
|
@ -87,6 +87,7 @@ func (s *IntegrationTestSuite) TestValidateGenesis() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
tc := tc
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
genesisFile := testutil.WriteToNewTempFile(s.T(), tc.genesis)
|
genesisFile := testutil.WriteToNewTempFile(s.T(), tc.genesis)
|
||||||
_, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cli.ValidateGenesisCmd(nil), []string{genesisFile.Name()})
|
_, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cli.ValidateGenesisCmd(nil), []string{genesisFile.Name()})
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,11 +1,8 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/testutil"
|
"github.com/cosmos/cosmos-sdk/testutil"
|
||||||
|
|
||||||
|
@ -19,7 +16,6 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||||
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,12 +26,13 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
s.cfg = network.DefaultConfig()
|
|
||||||
s.cfg.NumValidators = 1
|
|
||||||
|
|
||||||
s.network = network.New(s.T(), s.cfg)
|
s.network = network.New(s.T(), s.cfg)
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
|
@ -44,7 +41,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
|
|
||||||
// create a proposal with deposit
|
// create a proposal with deposit
|
||||||
_, err = govtestutil.MsgSubmitProposal(val.ClientCtx, val.Address.String(),
|
_, err = MsgSubmitProposal(val.ClientCtx, val.Address.String(),
|
||||||
"Text Proposal 1", "Where is the title!?", types.ProposalTypeText,
|
"Text Proposal 1", "Where is the title!?", types.ProposalTypeText,
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens).String()))
|
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens).String()))
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -52,18 +49,18 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// vote for proposal
|
// vote for proposal
|
||||||
_, err = govtestutil.MsgVote(val.ClientCtx, val.Address.String(), "1", "yes")
|
_, err = MsgVote(val.ClientCtx, val.Address.String(), "1", "yes")
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// create a proposal without deposit
|
// create a proposal without deposit
|
||||||
_, err = govtestutil.MsgSubmitProposal(val.ClientCtx, val.Address.String(),
|
_, err = MsgSubmitProposal(val.ClientCtx, val.Address.String(),
|
||||||
"Text Proposal 2", "Where is the title!?", types.ProposalTypeText)
|
"Text Proposal 2", "Where is the title!?", types.ProposalTypeText)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
_, err = s.network.WaitForHeight(1)
|
_, err = s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// create a proposal3 with deposit
|
// create a proposal3 with deposit
|
||||||
_, err = govtestutil.MsgSubmitProposal(val.ClientCtx, val.Address.String(),
|
_, err = MsgSubmitProposal(val.ClientCtx, val.Address.String(),
|
||||||
"Text Proposal 3", "Where is the title!?", types.ProposalTypeText,
|
"Text Proposal 3", "Where is the title!?", types.ProposalTypeText,
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens).String()))
|
fmt.Sprintf("--%s=%s", cli.FlagDeposit, sdk.NewCoin(s.cfg.BondDenom, types.DefaultMinDepositTokens).String()))
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -71,7 +68,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// vote for proposal3 as val
|
// vote for proposal3 as val
|
||||||
_, err = govtestutil.MsgVote(val.ClientCtx, val.Address.String(), "3", "yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05")
|
_, 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(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,8 +293,8 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid proposal (file)",
|
"invalid proposal (file)",
|
||||||
|
@ -307,7 +304,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid proposal",
|
"invalid proposal",
|
||||||
|
@ -319,7 +316,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction (file)",
|
"valid transaction (file)",
|
||||||
|
@ -330,7 +327,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -344,7 +341,7 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,7 +787,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() {
|
||||||
"vote for invalid proposal",
|
"vote for invalid proposal",
|
||||||
[]string{
|
[]string{
|
||||||
"10",
|
"10",
|
||||||
fmt.Sprintf("%s", "yes"),
|
"yes",
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
|
@ -802,7 +799,7 @@ func (s *IntegrationTestSuite) TestNewCmdVote() {
|
||||||
"valid vote",
|
"valid vote",
|
||||||
[]string{
|
[]string{
|
||||||
"1",
|
"1",
|
||||||
fmt.Sprintf("%s", "yes"),
|
"yes",
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
|
@ -850,7 +847,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() {
|
||||||
"vote for invalid proposal",
|
"vote for invalid proposal",
|
||||||
[]string{
|
[]string{
|
||||||
"10",
|
"10",
|
||||||
fmt.Sprintf("%s", "yes"),
|
"yes",
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
|
@ -862,7 +859,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() {
|
||||||
"valid vote",
|
"valid vote",
|
||||||
[]string{
|
[]string{
|
||||||
"1",
|
"1",
|
||||||
fmt.Sprintf("%s", "yes"),
|
"yes",
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
|
@ -874,7 +871,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() {
|
||||||
"invalid valid split vote string",
|
"invalid valid split vote string",
|
||||||
[]string{
|
[]string{
|
||||||
"1",
|
"1",
|
||||||
fmt.Sprintf("%s", "yes/0.6,no/0.3,abstain/0.05,no_with_veto/0.05"),
|
"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=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
|
@ -886,7 +883,7 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() {
|
||||||
"valid split vote",
|
"valid split vote",
|
||||||
[]string{
|
[]string{
|
||||||
"1",
|
"1",
|
||||||
fmt.Sprintf("%s", "yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05"),
|
"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=%s", flags.FlagFrom, val.Address.String()),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
|
@ -915,7 +912,3 @@ func (s *IntegrationTestSuite) TestNewCmdWeightedVote() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,18 +1,15 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||||
testnet "github.com/cosmos/cosmos-sdk/testutil/network"
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/mint/client/cli"
|
"github.com/cosmos/cosmos-sdk/x/mint/client/cli"
|
||||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||||
|
@ -21,32 +18,33 @@ import (
|
||||||
type IntegrationTestSuite struct {
|
type IntegrationTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
|
|
||||||
cfg testnet.Config
|
cfg network.Config
|
||||||
network *testnet.Network
|
network *network.Network
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := testnet.DefaultConfig()
|
genesisState := s.cfg.GenesisState
|
||||||
genesisState := cfg.GenesisState
|
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
var mintData minttypes.GenesisState
|
var mintData minttypes.GenesisState
|
||||||
s.Require().NoError(cfg.Codec.UnmarshalJSON(genesisState[minttypes.ModuleName], &mintData))
|
s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[minttypes.ModuleName], &mintData))
|
||||||
|
|
||||||
inflation := sdk.MustNewDecFromStr("1.0")
|
inflation := sdk.MustNewDecFromStr("1.0")
|
||||||
mintData.Minter.Inflation = inflation
|
mintData.Minter.Inflation = inflation
|
||||||
mintData.Params.InflationMin = inflation
|
mintData.Params.InflationMin = inflation
|
||||||
mintData.Params.InflationMax = inflation
|
mintData.Params.InflationMax = inflation
|
||||||
|
|
||||||
mintDataBz, err := cfg.Codec.MarshalJSON(&mintData)
|
mintDataBz, err := s.cfg.Codec.MarshalJSON(&mintData)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
genesisState[minttypes.ModuleName] = mintDataBz
|
genesisState[minttypes.ModuleName] = mintDataBz
|
||||||
cfg.GenesisState = genesisState
|
s.cfg.GenesisState = genesisState
|
||||||
|
|
||||||
s.cfg = cfg
|
s.network = network.New(s.T(), s.cfg)
|
||||||
s.network = testnet.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err = s.network.WaitForHeight(1)
|
_, err = s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -163,7 +161,3 @@ func (s *IntegrationTestSuite) TestGetCmdQueryAnnualProvisions() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,11 +1,8 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||||
|
@ -22,14 +19,14 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -81,7 +78,3 @@ value: "100"`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 1
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,11 +1,8 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
@ -25,16 +22,16 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
// SetupSuite executes bootstrapping logic before all the tests, i.e. once before
|
// SetupSuite executes bootstrapping logic before all the tests, i.e. once before
|
||||||
// the entire suite, start executing.
|
// the entire suite, start executing.
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
cfg := network.DefaultConfig()
|
s.network = network.New(s.T(), s.cfg)
|
||||||
cfg.NumValidators = 1
|
|
||||||
|
|
||||||
s.cfg = cfg
|
|
||||||
s.network = network.New(s.T(), cfg)
|
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -149,8 +146,8 @@ func (s *IntegrationTestSuite) TestNewUnjailTxCmd() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -160,7 +157,7 @@ func (s *IntegrationTestSuite) TestNewUnjailTxCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +181,3 @@ func (s *IntegrationTestSuite) TestNewUnjailTxCmd() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
|
@ -756,15 +756,15 @@ func (s *IntegrationTestSuite) TestQueryHistoricalInfoGRPC() {
|
||||||
resp, err := rest.GetRequest(tc.url)
|
resp, err := rest.GetRequest(tc.url)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
var historical_info types.QueryHistoricalInfoResponse
|
var historicalInfo types.QueryHistoricalInfoResponse
|
||||||
|
|
||||||
err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &historical_info)
|
err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, &historicalInfo)
|
||||||
|
|
||||||
if tc.error {
|
if tc.error {
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
} else {
|
} else {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(historical_info)
|
s.Require().NotNil(historicalInfo)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// +build norace
|
||||||
|
|
||||||
|
package testutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIntegrationTestSuite(t *testing.T) {
|
||||||
|
cfg := network.DefaultConfig()
|
||||||
|
cfg.NumValidators = 2
|
||||||
|
suite.Run(t, NewIntegrationTestSuite(cfg))
|
||||||
|
}
|
|
@ -1,6 +1,4 @@
|
||||||
// +build norace
|
package testutil
|
||||||
|
|
||||||
package cli_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -24,7 +22,6 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/types/query"
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
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/client/cli"
|
||||||
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/client/testutil"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,6 +32,10 @@ type IntegrationTestSuite struct {
|
||||||
network *network.Network
|
network *network.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||||
|
return &IntegrationTestSuite{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) SetupSuite() {
|
func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Log("setting up integration test suite")
|
s.T().Log("setting up integration test suite")
|
||||||
|
|
||||||
|
@ -42,8 +43,6 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
s.T().Skip("skipping test in unit-tests mode.")
|
s.T().Skip("skipping test in unit-tests mode.")
|
||||||
}
|
}
|
||||||
|
|
||||||
s.cfg = network.DefaultConfig()
|
|
||||||
s.cfg.NumValidators = 2
|
|
||||||
s.network = network.New(s.T(), s.cfg)
|
s.network = network.New(s.T(), s.cfg)
|
||||||
|
|
||||||
_, err := s.network.WaitForHeight(1)
|
_, err := s.network.WaitForHeight(1)
|
||||||
|
@ -56,7 +55,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
val2 := s.network.Validators[1]
|
val2 := s.network.Validators[1]
|
||||||
|
|
||||||
// redelegate
|
// redelegate
|
||||||
_, err = stakingtestutil.MsgRedelegateExec(
|
_, err = MsgRedelegateExec(
|
||||||
val.ClientCtx,
|
val.ClientCtx,
|
||||||
val.Address,
|
val.Address,
|
||||||
val.ValAddress,
|
val.ValAddress,
|
||||||
|
@ -68,7 +67,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||||
_, err = s.network.WaitForHeight(1)
|
_, err = s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// unbonding
|
// unbonding
|
||||||
_, err = stakingtestutil.MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbond)
|
_, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbond)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
_, err = s.network.WaitForHeight(1)
|
_, err = s.network.WaitForHeight(1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -106,8 +105,8 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid transaction (missing amount)",
|
"invalid transaction (missing amount)",
|
||||||
|
@ -125,7 +124,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid transaction (missing pubkey)",
|
"invalid transaction (missing pubkey)",
|
||||||
|
@ -144,7 +143,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"invalid transaction (missing moniker)",
|
"invalid transaction (missing moniker)",
|
||||||
|
@ -164,7 +163,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction",
|
"valid transaction",
|
||||||
|
@ -185,7 +184,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,11 +843,11 @@ func (s *IntegrationTestSuite) TestGetCmdQueryHistoricalInfo() {
|
||||||
if tc.error {
|
if tc.error {
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
} else {
|
} else {
|
||||||
var historical_info types.HistoricalInfo
|
var historicalInfo types.HistoricalInfo
|
||||||
|
|
||||||
err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &historical_info)
|
err = val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &historicalInfo)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(historical_info)
|
s.Require().NotNil(historicalInfo)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -938,8 +937,8 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"with no edit flag (since all are optional)",
|
"with no edit flag (since all are optional)",
|
||||||
|
@ -949,7 +948,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"with no edit flag (since all are optional)",
|
"with no edit flag (since all are optional)",
|
||||||
|
@ -959,7 +958,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"edit validator details",
|
"edit validator details",
|
||||||
|
@ -970,7 +969,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"edit validator identity",
|
"edit validator identity",
|
||||||
|
@ -981,7 +980,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"edit validator security-contact",
|
"edit validator security-contact",
|
||||||
|
@ -992,7 +991,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"edit validator website",
|
"edit validator website",
|
||||||
|
@ -1003,7 +1002,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"with all edit flags",
|
"with all edit flags",
|
||||||
|
@ -1017,7 +1016,7 @@ func (s *IntegrationTestSuite) TestNewCmdEditValidator() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1064,8 +1063,8 @@ func (s *IntegrationTestSuite) TestNewCmdDelegate() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"without delegate amount",
|
"without delegate amount",
|
||||||
|
@ -1076,7 +1075,7 @@ func (s *IntegrationTestSuite) TestNewCmdDelegate() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"without validator address",
|
"without validator address",
|
||||||
|
@ -1087,7 +1086,7 @@ func (s *IntegrationTestSuite) TestNewCmdDelegate() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction of delegate",
|
"valid transaction of delegate",
|
||||||
|
@ -1099,7 +1098,7 @@ func (s *IntegrationTestSuite) TestNewCmdDelegate() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1132,8 +1131,8 @@ func (s *IntegrationTestSuite) TestNewCmdRedelegate() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"without amount",
|
"without amount",
|
||||||
|
@ -1145,7 +1144,7 @@ func (s *IntegrationTestSuite) TestNewCmdRedelegate() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"with wrong source validator address",
|
"with wrong source validator address",
|
||||||
|
@ -1158,7 +1157,7 @@ func (s *IntegrationTestSuite) TestNewCmdRedelegate() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 4,
|
false, 4, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"with wrong destination validator address",
|
"with wrong destination validator address",
|
||||||
|
@ -1171,7 +1170,7 @@ func (s *IntegrationTestSuite) TestNewCmdRedelegate() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 39,
|
false, 39, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction of delegate",
|
"valid transaction of delegate",
|
||||||
|
@ -1185,7 +1184,7 @@ func (s *IntegrationTestSuite) TestNewCmdRedelegate() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,8 +1216,8 @@ func (s *IntegrationTestSuite) TestNewCmdUnbond() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType proto.Message
|
|
||||||
expectedCode uint32
|
expectedCode uint32
|
||||||
|
respType proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"Without unbond amount",
|
"Without unbond amount",
|
||||||
|
@ -1229,7 +1228,7 @@ func (s *IntegrationTestSuite) TestNewCmdUnbond() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Without validator address",
|
"Without validator address",
|
||||||
|
@ -1240,7 +1239,7 @@ func (s *IntegrationTestSuite) TestNewCmdUnbond() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
true, nil, 0,
|
true, 0, nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid transaction of unbond",
|
"valid transaction of unbond",
|
||||||
|
@ -1252,7 +1251,7 @@ func (s *IntegrationTestSuite) TestNewCmdUnbond() {
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||||
},
|
},
|
||||||
false, &sdk.TxResponse{}, 0,
|
false, 0, &sdk.TxResponse{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1316,6 +1315,7 @@ func (s *IntegrationTestSuite) TestBlockResults() {
|
||||||
|
|
||||||
// Create a HTTP rpc client.
|
// Create a HTTP rpc client.
|
||||||
rpcClient, err := http.New(val.RPCAddress, "/websocket")
|
rpcClient, err := http.New(val.RPCAddress, "/websocket")
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
// Loop until we find a block result with the correct validator updates.
|
// Loop until we find a block result with the correct validator updates.
|
||||||
// By experience, it happens around 2 blocks after `delHeight`.
|
// By experience, it happens around 2 blocks after `delHeight`.
|
||||||
|
@ -1345,7 +1345,3 @@ func (s *IntegrationTestSuite) TestBlockResults() {
|
||||||
s.network.WaitForNextBlock()
|
s.network.WaitForNextBlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationTestSuite(t *testing.T) {
|
|
||||||
suite.Run(t, new(IntegrationTestSuite))
|
|
||||||
}
|
|
Loading…
Reference in New Issue