Skip to content

Commit 07180cc

Browse files
committed
revert
1 parent c8008a3 commit 07180cc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/e2e/gov/tx.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/cosmos/cosmos-sdk/testutil/network"
1616
sdk "github.com/cosmos/cosmos-sdk/types"
1717
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
18+
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
1819
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
1920
govclitestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
2021
"github.com/cosmos/cosmos-sdk/x/gov/types"
@@ -351,6 +352,14 @@ func (s *E2ETestSuite) TestNewCmdCancelProposal() {
351352
s.Run(tc.name, func() {
352353
cmd := cli.NewCmdCancelProposal()
353354
clientCtx := val.ClientCtx
355+
var balRes banktypes.QueryAllBalancesResponse
356+
var newBalance banktypes.QueryAllBalancesResponse
357+
if !tc.expectErr && tc.expectedCode == 0 {
358+
resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val.APIAddress, val.Address.String()))
359+
s.Require().NoError(err)
360+
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &balRes)
361+
s.Require().NoError(err)
362+
}
354363

355364
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
356365
if tc.expectErr {
@@ -359,6 +368,24 @@ func (s *E2ETestSuite) TestNewCmdCancelProposal() {
359368
s.Require().NoError(err)
360369
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String())
361370
s.Require().NoError(clitestutil.CheckTxCode(s.network, clientCtx, resp.TxHash, tc.expectedCode))
371+
372+
if !tc.expectErr && tc.expectedCode == 0 {
373+
resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val.APIAddress, val.Address.String()))
374+
s.Require().NoError(err)
375+
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &newBalance)
376+
s.Require().NoError(err)
377+
remainingAmount := v1.DefaultMinDepositTokens.Mul(
378+
v1.DefaultProposalCancelRatio.Mul(math.LegacyMustNewDecFromStr("100")).TruncateInt(),
379+
).Quo(math.NewIntFromUint64(100))
380+
381+
// new balance = old balance + remaining amount from proposal deposit - txFee (cancel proposal)
382+
txFee := math.NewInt(10)
383+
s.Require().True(
384+
newBalance.Balances.AmountOf(s.network.Config.BondDenom).Equal(
385+
balRes.Balances.AmountOf(s.network.Config.BondDenom).Add(remainingAmount).Sub(txFee),
386+
),
387+
)
388+
}
362389
}
363390
})
364391
}

0 commit comments

Comments
 (0)