refactor!: remove broadcast mode block (#12659)

This commit is contained in:
Julien Robert
2022-09-23 15:16:31 +00:00
committed by GitHub
parent 6cbb587e18
commit df40c0a9d1
62 changed files with 893 additions and 937 deletions
@@ -30,9 +30,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *IntegrationTestSuite) TearDownSuite() {
@@ -134,7 +132,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code)
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
@@ -212,7 +210,7 @@ func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code)
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
next, err := s.network.WaitForHeight(height + 1)
+1 -3
View File
@@ -88,9 +88,7 @@ func (s *EndToEndTestSuite) SetupSuite() {
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *EndToEndTestSuite) TearDownSuite() {
@@ -55,8 +55,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
s.queryClient = tmservice.NewServiceClient(s.network.Validators[0].ClientCtx)
}
+8 -10
View File
@@ -3,14 +3,13 @@ package crisis
import (
"fmt"
"github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/suite"
"github.com/cosmos/cosmos-sdk/client/flags"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/crisis/client/cli"
"github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/suite"
)
type IntegrationTestSuite struct {
@@ -31,8 +30,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *IntegrationTestSuite) TearDownSuite() {
@@ -56,7 +54,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() {
"", "total-supply",
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -67,18 +65,18 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() {
"bank", "",
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
},
{
"valid transaction",
"valid traclientCtx.Codec.UnmarshalJSON(out.Bytes(), nsaction",
[]string{
"bank", "total-supply",
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -100,7 +98,7 @@ func (s *IntegrationTestSuite) TestNewMsgVerifyInvariantTxCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code)
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -1,7 +1,7 @@
//go:build e2e
// +build e2e
package testutil
package distribution
import (
"testing"
+1 -2
View File
@@ -28,8 +28,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *IntegrationTestSuite) TearDownSuite() {
+14 -15
View File
@@ -56,8 +56,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
val := s.network.Validators[0]
granter := val.Address
@@ -81,7 +80,7 @@ func (s *IntegrationTestSuite) createGrant(granter, grantee sdk.Address) {
clientCtx := val.ClientCtx
commonFlags := []string{
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()),
}
@@ -103,8 +102,8 @@ func (s *IntegrationTestSuite) createGrant(granter, grantee sdk.Address) {
_, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *IntegrationTestSuite) TearDownSuite() {
@@ -248,6 +247,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGrantee() {
} else {
s.Require().NoError(err)
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.resp), out.String())
s.Require().Len(tc.resp.Allowances, tc.expectLength)
}
})
@@ -321,7 +321,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
s.Require().NoError(err)
commonFlags := []string{
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
}
@@ -599,7 +599,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -612,7 +612,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
clientCtx := val.ClientCtx
commonFlags := []string{
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
}
@@ -706,7 +706,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -727,7 +727,7 @@ func (s *IntegrationTestSuite) TestTxWithFeeGrant() {
grantee := sdk.AccAddress(pub.Address())
commonFlags := []string{
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
}
@@ -749,8 +749,7 @@ func (s *IntegrationTestSuite) TestTxWithFeeGrant() {
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
testcases := []struct {
name string
@@ -818,7 +817,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() {
clientCtx := val.ClientCtx
commonFlags := []string{
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()),
}
@@ -891,7 +890,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -982,7 +981,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() {
s.Require().NoError(err)
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
})
}
}
+1 -2
View File
@@ -37,8 +37,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *IntegrationTestSuite) TearDownSuite() {
@@ -1,7 +1,7 @@
//go:build e2e
// +build e2e
package testutil
package gov
import (
"testing"
@@ -20,7 +20,11 @@ func TestIntegrationTestSuite(t *testing.T) {
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
suite.Run(t, testutil.NewIntegrationTestSuite(cfg))
}
func TestDepositTestSuite(t *testing.T) {
cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
cfg.NumValidators = 1
genesisState := v1.DefaultGenesisState()
maxDepPeriod := time.Duration(15) * time.Second
votingPeriod := time.Duration(5) * time.Second
+22 -19
View File
@@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/testutil/cli"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/group"
client "github.com/cosmos/cosmos-sdk/x/group/client/cli"
@@ -54,7 +54,7 @@ func (s *IntegrationTestSuite) TestQueryGroupInfo() {
s.Run(tc.name, func() {
cmd := client.QueryGroupInfoCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -78,7 +78,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
require := s.Require()
cmd := client.QueryGroupsByAdminCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, []string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
require.NoError(err)
var groups group.QueryGroupsByAdminResponse
@@ -86,7 +86,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
require.Len(groups.Groups, 1)
cmd = client.QueryGroupMembersCmd()
out, err = cli.ExecTestCLICmd(clientCtx, cmd, []string{fmt.Sprintf("%d", groups.Groups[0].Id), fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{fmt.Sprintf("%d", groups.Groups[0].Id), fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
require.NoError(err)
var members group.QueryGroupMembersResponse
@@ -133,7 +133,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
tc := tc
s.Run(tc.name, func() {
cmd := client.QueryGroupsByMemberCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
require.Contains(out.String(), tc.expectErrMsg)
} else {
@@ -194,7 +194,7 @@ func (s *IntegrationTestSuite) TestQueryGroupMembers() {
s.Run(tc.name, func() {
cmd := client.QueryGroupMembersCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -260,7 +260,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByAdmin() {
s.Run(tc.name, func() {
cmd := client.QueryGroupsByAdminCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -314,7 +314,7 @@ func (s *IntegrationTestSuite) TestQueryGroupPolicyInfo() {
s.Run(tc.name, func() {
cmd := client.QueryGroupPolicyInfoCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -388,7 +388,7 @@ func (s *IntegrationTestSuite) TestQueryGroupPoliciesByGroup() {
s.Run(tc.name, func() {
cmd := client.QueryGroupPoliciesByGroupCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -464,7 +464,7 @@ func (s *IntegrationTestSuite) TestQueryGroupPoliciesByAdmin() {
s.Run(tc.name, func() {
cmd := client.QueryGroupPoliciesByAdminCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -522,7 +522,7 @@ func (s *IntegrationTestSuite) TestQueryProposal() {
s.Run(tc.name, func() {
cmd := client.QueryProposalCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -578,7 +578,7 @@ func (s *IntegrationTestSuite) TestQueryProposalsByGroupPolicy() {
s.Run(tc.name, func() {
cmd := client.QueryProposalsByGroupPolicyCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -628,7 +628,7 @@ func (s *IntegrationTestSuite) TestQueryVoteByProposalVoter() {
s.Run(tc.name, func() {
cmd := client.QueryVoteByProposalVoterCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -684,7 +684,7 @@ func (s *IntegrationTestSuite) TestQueryVotesByProposal() {
s.Run(tc.name, func() {
cmd := client.QueryVotesByProposalCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -747,7 +747,7 @@ func (s *IntegrationTestSuite) TestQueryVotesByVoter() {
s.Run(tc.name, func() {
cmd := client.QueryVotesByVoterCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
@@ -772,12 +772,12 @@ func (s *IntegrationTestSuite) TestTallyResult() {
commonFlags := []string{
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
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()),
}
// create a proposal
out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgSubmitProposalCmd(),
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, client.MsgSubmitProposalCmd(),
append(
[]string{
s.createCLIProposal(
@@ -792,7 +792,10 @@ func (s *IntegrationTestSuite) TestTallyResult() {
var txResp sdk.TxResponse
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
s.Require().Equal(uint32(0), txResp.Code, out.String())
txResp, err = clitestutil.GetTxResponse(s.network, clientCtx, txResp.TxHash)
s.Require().NoError(err)
s.Require().Equal(txResp.Code, uint32(0), out.String())
proposalID := s.getProposalIDFromTxResponse(txResp)
testCases := []struct {
@@ -860,7 +863,7 @@ func (s *IntegrationTestSuite) TestTallyResult() {
s.Run(tc.name, func() {
cmd := client.QueryTallyResultCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
s.Require().Contains(out.String(), tc.expectErrMsg)
} else {
+248 -181
View File
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -47,8 +47,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *IntegrationTestSuite) TearDownSuite() {
+5 -8
View File
@@ -80,13 +80,10 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.cfg.GenesisState = genesisState
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
s.initAccount()
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *IntegrationTestSuite) TearDownSuite() {
@@ -99,7 +96,7 @@ func (s *IntegrationTestSuite) TestCLITxSend() {
args := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, OwnerName),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
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()),
}
testCases := []struct {
@@ -135,7 +132,7 @@ func (s *IntegrationTestSuite) TestCLITxSend() {
var txResp sdk.TxResponse
s.Require().NoError(err)
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -152,7 +149,7 @@ func (s *IntegrationTestSuite) initAccount() {
args := []string{
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
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()),
}
+4 -4
View File
@@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
)
type EndToEndTestSuite struct {
@@ -35,8 +36,7 @@ func (s *EndToEndTestSuite) SetupSuite() {
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
}
// TearDownSuite performs cleanup logic after all the tests, i.e. once after the
@@ -159,7 +159,7 @@ func (s *EndToEndTestSuite) TestNewUnjailTxCmd() {
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()),
},
false, 0, &sdk.TxResponse{},
false, slashingtypes.ErrValidatorNotJailed.ABCICode(), &sdk.TxResponse{},
},
}
@@ -178,7 +178,7 @@ func (s *EndToEndTestSuite) TestNewUnjailTxCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
+68 -59
View File
@@ -48,9 +48,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
unbond, err := sdk.ParseCoinNormalized("10stake")
s.Require().NoError(err)
@@ -71,24 +69,24 @@ func (s *IntegrationTestSuite) SetupSuite() {
var txRes sdk.TxResponse
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes))
s.Require().Equal(uint32(0), txRes.Code)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
unbondingAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))
// unbonding the amount
out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbondingAmount)
s.Require().NoError(err)
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes))
s.Require().Equal(uint32(0), txRes.Code)
// unbonding the amount
out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbondingAmount)
s.Require().NoError(err)
s.Require().NoError(err)
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes))
s.Require().Equal(uint32(0), txRes.Code)
err = s.network.WaitForNextBlock()
// unbonding the amount
out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbondingAmount)
s.Require().NoError(err)
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes))
s.Require().Equal(uint32(0), txRes.Code)
s.Require().NoError(s.network.WaitForNextBlock())
// unbonding the amount
out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbondingAmount)
s.Require().NoError(err)
s.Require().NoError(err)
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes))
s.Require().Equal(uint32(0), txRes.Code)
s.Require().NoError(s.network.WaitForNextBlock())
}
func (s *IntegrationTestSuite) TearDownSuite() {
@@ -117,10 +115,11 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
val.Address,
newAddr,
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
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()),
)
require.NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
testCases := []struct {
name string
@@ -142,7 +141,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
fmt.Sprintf("--%s=1", cli.FlagMinSelfDelegation),
fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -161,7 +160,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
fmt.Sprintf("--%s=1", cli.FlagMinSelfDelegation),
fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -181,7 +180,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
fmt.Sprintf("--%s=1", cli.FlagMinSelfDelegation),
fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -202,7 +201,7 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
fmt.Sprintf("--%s=1", cli.FlagMinSelfDelegation),
fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -223,19 +222,25 @@ func (s *IntegrationTestSuite) TestNewCreateValidatorCmd() {
require.NoError(err, "test: %s\noutput: %s", tc.name, out.String())
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType)
require.NoError(err, out.String(), "test: %s, output\n:", tc.name, out.String())
s.Require().NoError(s.network.WaitForNextBlock())
txResp := tc.respType.(*sdk.TxResponse)
require.Equal(tc.expectedCode, txResp.Code,
"test: %s, output\n:", tc.name, out.String())
txRespHash := tc.respType.(*sdk.TxResponse)
txResp, err := clitestutil.GetTxResponse(s.network, clientCtx, txRespHash.TxHash)
s.Require().NoError(err)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
var hadEvent bool
events := txResp.Logs[0].GetEvents()
for i := 0; i < len(events); i++ {
if events[i].GetType() == "create_validator" {
attributes := events[i].GetAttributes()
require.Equal(attributes[1].Value, "100stake")
hadEvent = true
break
}
}
s.Require().True(hadEvent)
}
})
}
@@ -975,7 +980,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() {
[]string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, "with wrong from address"),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -985,7 +990,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() {
[]string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -996,7 +1001,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() {
fmt.Sprintf("--details=%s", details),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1007,7 +1012,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() {
fmt.Sprintf("--identity=%s", identity),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1018,7 +1023,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() {
fmt.Sprintf("--security-contact=%s", securityContact),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1029,7 +1034,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() {
fmt.Sprintf("--website=%s", website),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1043,7 +1048,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() {
fmt.Sprintf("--website=%s", website),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1065,7 +1070,7 @@ func (s *IntegrationTestSuite) TestNewEditValidatorCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -1087,10 +1092,11 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() {
val.Address,
newAddr,
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
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()),
)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
testCases := []struct {
name string
@@ -1105,7 +1111,7 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() {
val.ValAddress.String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -1116,7 +1122,7 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -1128,7 +1134,7 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1150,7 +1156,7 @@ func (s *IntegrationTestSuite) TestNewDelegateCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -1174,7 +1180,7 @@ func (s *IntegrationTestSuite) TestNewRedelegateCmd() {
val2.ValAddress.String(), // dst-validator-addr
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -1187,7 +1193,7 @@ func (s *IntegrationTestSuite) TestNewRedelegateCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), // amount
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 3, &sdk.TxResponse{},
@@ -1200,7 +1206,7 @@ func (s *IntegrationTestSuite) TestNewRedelegateCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(), // amount
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 31, &sdk.TxResponse{},
@@ -1214,7 +1220,7 @@ func (s *IntegrationTestSuite) TestNewRedelegateCmd() {
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=%d", flags.FlagGas, 300000),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1236,7 +1242,7 @@ func (s *IntegrationTestSuite) TestNewRedelegateCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -1258,7 +1264,7 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() {
val.ValAddress.String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -1269,7 +1275,7 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -1281,7 +1287,7 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1303,7 +1309,7 @@ func (s *IntegrationTestSuite) TestNewUnbondCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -1324,7 +1330,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() {
[]string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -1335,7 +1341,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() {
val.ValAddress.String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -1347,7 +1353,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
true, 0, nil,
@@ -1360,7 +1366,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() {
sdk.NewInt(10000).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, sdkerrors.ErrNotFound.ABCICode(), &sdk.TxResponse{},
@@ -1372,7 +1378,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10000)).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, sdkerrors.ErrInvalidRequest.ABCICode(), &sdk.TxResponse{},
@@ -1384,7 +1390,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5)).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
false, 0, &sdk.TxResponse{},
@@ -1422,7 +1428,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() {
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
txResp := tc.respType.(*sdk.TxResponse)
s.Require().Equal(tc.expectedCode, txResp.Code, out.String())
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, txResp.TxHash, tc.expectedCode))
}
})
}
@@ -1448,10 +1454,11 @@ func (s *IntegrationTestSuite) TestBlockResults() {
val.Address,
newAddr,
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
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()),
)
require.NoError(err)
require.NoError(s.network.WaitForNextBlock())
// Use CLI to create a delegation from the new account to validator `val`.
delHeight, err := s.network.LatestHeight()
@@ -1462,10 +1469,11 @@ func (s *IntegrationTestSuite) TestBlockResults() {
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150)).String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
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()),
})
require.NoError(err)
require.NoError(s.network.WaitForNextBlock())
// Create a HTTP rpc client.
rpcClient, err := http.New(val.RPCAddress, "/websocket")
@@ -1511,12 +1519,13 @@ func (s *IntegrationTestSuite) TestEditValidatorMoniker() {
val.ValAddress.String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", cli.FlagEditMoniker, moniker),
fmt.Sprintf("--%s=https://newvalidator.io", cli.FlagWebsite),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
})
require.NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
queryCmd := cli.GetCmdQueryValidator()
res, err := clitestutil.ExecTestCLICmd(
@@ -1532,18 +1541,18 @@ func (s *IntegrationTestSuite) TestEditValidatorMoniker() {
val.ValAddress.String(),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=https://newvalidator.io", cli.FlagWebsite),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
})
require.NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
res, err = clitestutil.ExecTestCLICmd(
val.ClientCtx, queryCmd,
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
)
require.NoError(err)
require.NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &result))
require.Equal(result.GetMoniker(), moniker)
}
@@ -13,7 +13,7 @@ import (
var commonArgs = []string{
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()),
}
+4 -9
View File
@@ -59,9 +59,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.Require().NoError(err)
val := s.network.Validators[0]
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
s.queryClient = tx.NewServiceClient(val.ClientCtx)
@@ -520,9 +518,7 @@ func (s IntegrationTestSuite) TestBroadcastTx_GRPC() {
}{
{"nil request", nil, true, "request cannot be nil"},
{"empty request", &tx.BroadcastTxRequest{}, true, "invalid empty tx"},
{"no mode", &tx.BroadcastTxRequest{
TxBytes: txBytes,
}, true, "supported types: sync, async, block"},
{"no mode", &tx.BroadcastTxRequest{TxBytes: txBytes}, true, "supported types: sync, async"},
{"valid request", &tx.BroadcastTxRequest{
Mode: tx.BroadcastMode_BROADCAST_MODE_SYNC,
TxBytes: txBytes,
@@ -559,7 +555,7 @@ func (s IntegrationTestSuite) TestBroadcastTx_GRPCGateway() {
expErrMsg string
}{
{"empty request", &tx.BroadcastTxRequest{}, true, "invalid empty tx"},
{"no mode", &tx.BroadcastTxRequest{TxBytes: txBytes}, true, "supported types: sync, async, block"},
{"no mode", &tx.BroadcastTxRequest{TxBytes: txBytes}, true, "supported types: sync, async"},
{"valid request", &tx.BroadcastTxRequest{
Mode: tx.BroadcastMode_BROADCAST_MODE_SYNC,
TxBytes: txBytes,
@@ -605,8 +601,7 @@ func (s *IntegrationTestSuite) TestSimMultiSigTx() {
_, err = kr.SaveMultisig("multi", multi)
s.Require().NoError(err)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
s.Require().NoError(s.network.WaitForNextBlock())
multisigRecord, err := val1.ClientCtx.Keyring.Key("multi")
s.Require().NoError(err)