Skip to content

Commit 00b6c72

Browse files
authored
fix: add unhandled error for gov burn deposits and fix lint (#31)
* fix: add unhandled error for gov burn deposits and fix lint * handle tests errors * fix deprecated lints
1 parent 487ee69 commit 00b6c72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+127
-159
lines changed

simapp/app_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414
evidencetypes "cosmossdk.io/x/evidence/types"
1515
"cosmossdk.io/x/feegrant"
1616
_ "cosmossdk.io/x/feegrant/module" // import for side-effects
17-
18-
_ "cosmossdk.io/x/upgrade" // import for side-effects
17+
_ "cosmossdk.io/x/upgrade" // import for side-effects
1918
upgradetypes "cosmossdk.io/x/upgrade/types"
2019
upgrademodulev1 "cosmossdk.io/x/upgrade/types/module"
20+
2121
"github.com/cosmos/cosmos-sdk/runtime"
2222
runtimemodule "github.com/cosmos/cosmos-sdk/runtime/module"
2323
"github.com/cosmos/cosmos-sdk/types/module"

simapp/app_di.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
circuitkeeper "cosmossdk.io/x/circuit/keeper"
1212
evidencekeeper "cosmossdk.io/x/evidence/keeper"
1313
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
14-
1514
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
15+
1616
"github.com/cosmos/cosmos-sdk/baseapp"
1717
"github.com/cosmos/cosmos-sdk/client"
1818
clienthelpers "github.com/cosmos/cosmos-sdk/client/v2/helpers"

simapp/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"cosmossdk.io/log"
1919
"cosmossdk.io/x/evidence"
2020
feegrantmodule "cosmossdk.io/x/feegrant/module"
21-
2221
"cosmossdk.io/x/upgrade"
22+
2323
"github.com/cosmos/cosmos-sdk/baseapp"
2424
"github.com/cosmos/cosmos-sdk/runtime"
2525
"github.com/cosmos/cosmos-sdk/testutil/mock"

simapp/upgrades.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55

66
storetypes "cosmossdk.io/store/types"
77
circuittypes "cosmossdk.io/x/circuit/types"
8-
98
upgradetypes "cosmossdk.io/x/upgrade/types"
9+
1010
"github.com/cosmos/cosmos-sdk/types/module"
1111
)
1212

tests/e2e/gov/grpc.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,16 +415,16 @@ func (s *E2ETestSuite) TestGetParamsGRPC() {
415415
s.Require().Equal(params.Threshold, queryResp.Params.Threshold)
416416

417417
if tc.checkDeposit {
418-
s.Require().NotNil(queryResp.DepositParams)
419-
s.Require().Equal(params.MaxDepositPeriod, queryResp.DepositParams.MaxDepositPeriod)
418+
s.Require().NotNil(queryResp.DepositParams) //nolint:staticcheck // keep for backward compatibility
419+
s.Require().Equal(params.MaxDepositPeriod, queryResp.DepositParams.MaxDepositPeriod) //nolint:staticcheck // keep for backward compatibility
420420
}
421421
if tc.checkVoting {
422-
s.Require().NotNil(queryResp.VotingParams)
423-
s.Require().Equal(params.VotingPeriod, queryResp.VotingParams.VotingPeriod)
422+
s.Require().NotNil(queryResp.VotingParams) //nolint:staticcheck // keep for backward compatibility
423+
s.Require().Equal(params.VotingPeriod, queryResp.VotingParams.VotingPeriod) //nolint:staticcheck // keep for backward compatibility
424424
}
425425
if tc.checkTally {
426-
s.Require().NotNil(queryResp.TallyParams)
427-
s.Require().Equal(params.Threshold, queryResp.TallyParams.Threshold)
426+
s.Require().NotNil(queryResp.TallyParams) //nolint:staticcheck // keep for backward compatibility
427+
s.Require().Equal(params.Threshold, queryResp.TallyParams.Threshold) //nolint:staticcheck // keep for backward compatibility
428428
}
429429
}
430430
})

tests/integration/gov/genesis_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func TestImportExportQueues(t *testing.T) {
173173
assert.Assert(t, proposal2.Status == v1.StatusVotingPeriod)
174174

175175
macc := s2.GovKeeper.GetGovernanceAccount(ctx2)
176-
assert.DeepEqual(t, sdk.Coins(minDeposit), s2.BankKeeper.GetAllBalances(ctx2, macc.GetAddress()))
176+
assert.DeepEqual(t, minDeposit, s2.BankKeeper.GetAllBalances(ctx2, macc.GetAddress()))
177177

178178
// Run the endblocker. Check to make sure that proposal1 is removed from state, and proposal2 is finished VotingPeriod.
179179
err = gov.EndBlocker(ctx2, s2.GovKeeper)

tests/integration/gov/keeper/tally_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) {
9090
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
9191
assert.Assert(t, ok)
9292
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
93+
assert.NilError(t, err)
9394

9495
assert.Assert(t, passes)
9596
assert.Assert(t, burnDeposits == false)
@@ -118,7 +119,7 @@ func TestTallyOnlyValidators51No(t *testing.T) {
118119
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
119120
assert.Assert(t, ok)
120121
passes, burnDeposits, _, _, err := f.govKeeper.Tally(ctx, proposal)
121-
122+
assert.NilError(t, err)
122123
assert.Assert(t, passes == false)
123124
assert.Assert(t, burnDeposits == false)
124125
}
@@ -145,6 +146,7 @@ func TestTallyOnlyValidators51Yes(t *testing.T) {
145146
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
146147
assert.Assert(t, ok)
147148
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
149+
assert.NilError(t, err)
148150

149151
assert.Assert(t, !passes) // only validators doesn't pass quorum
150152
assert.Assert(t, burnDeposits == false)
@@ -173,7 +175,9 @@ func TestTallyOnlyValidatorsAbstain(t *testing.T) {
173175

174176
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
175177
assert.Assert(t, ok)
178+
176179
passes, burnDeposits, participation, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
180+
assert.NilError(t, err)
177181

178182
assert.Assert(t, !passes)
179183
assert.Assert(t, burnDeposits == false)
@@ -204,6 +208,7 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
204208
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
205209
assert.Assert(t, ok)
206210
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
211+
assert.NilError(t, err)
207212

208213
assert.Assert(t, passes == false)
209214
assert.Assert(t, burnDeposits == false)
@@ -233,6 +238,7 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
233238
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
234239
assert.Assert(t, ok)
235240
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
241+
assert.NilError(t, err)
236242

237243
assert.Assert(t, passes == false)
238244
assert.Assert(t, burnDeposits == false)
@@ -272,6 +278,7 @@ func TestTallyDelgatorOverride(t *testing.T) {
272278
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
273279
assert.Assert(t, ok)
274280
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
281+
assert.NilError(t, err)
275282

276283
assert.Assert(t, passes == false)
277284
assert.Assert(t, burnDeposits == false)
@@ -310,6 +317,7 @@ func TestTallyDelgatorInheritDisabled(t *testing.T) {
310317
proposal, err = f.govKeeper.Proposals.Get(ctx, proposalID)
311318
assert.NilError(t, err)
312319
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
320+
assert.NilError(t, err)
313321

314322
assert.Assert(t, !passes) // vote not inherited, proposal not passing
315323
assert.Assert(t, burnDeposits == false)
@@ -353,6 +361,7 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) {
353361
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
354362
assert.Assert(t, ok)
355363
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
364+
assert.NilError(t, err)
356365

357366
assert.Assert(t, passes == false)
358367
assert.Assert(t, burnDeposits == false)
@@ -397,6 +406,7 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) {
397406
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
398407
assert.Assert(t, ok)
399408
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
409+
assert.NilError(t, err)
400410

401411
assert.Assert(t, passes == false)
402412
assert.Assert(t, burnDeposits == false)
@@ -443,6 +453,7 @@ func TestTallyJailedValidator(t *testing.T) {
443453
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
444454
assert.Assert(t, ok)
445455
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
456+
assert.NilError(t, err)
446457

447458
assert.Assert(t, passes)
448459
assert.Assert(t, burnDeposits == false)
@@ -479,6 +490,7 @@ func TestTallyValidatorMultipleDelegations(t *testing.T) {
479490
proposal, ok := f.govKeeper.Proposals.Get(ctx, proposalID)
480491
assert.Assert(t, ok)
481492
passes, burnDeposits, _, tallyResults, err := f.govKeeper.Tally(ctx, proposal)
493+
assert.NilError(t, err)
482494

483495
assert.Assert(t, passes)
484496
assert.Assert(t, burnDeposits == false)

x/gov/abci.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error {
233233
} else {
234234
err = keeper.RefundAndDeleteDeposits(ctx, proposal.Id)
235235
}
236+
if err != nil {
237+
return false, err
238+
}
236239

237240
if err = keeper.ActiveProposalsQueue.Remove(ctx, collections.Join(*proposal.VotingEndTime, proposal.Id)); err != nil {
238241
return false, err

x/gov/client/cli/query.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/cosmos/cosmos-sdk/client"
1010
"github.com/cosmos/cosmos-sdk/client/flags"
1111
"github.com/cosmos/cosmos-sdk/version"
12-
1312
"github.com/cosmos/cosmos-sdk/x/gov/types"
1413
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
1514
)
@@ -50,7 +49,7 @@ $ %s query gov quorums
5049
),
5150
),
5251
Args: cobra.NoArgs,
53-
RunE: func(cmd *cobra.Command, args []string) error {
52+
RunE: func(cmd *cobra.Command, _ []string) error {
5453
clientCtx, err := client.GetClientQueryContext(cmd)
5554
if err != nil {
5655
return err
@@ -88,7 +87,7 @@ $ %s query gov min-deposit
8887
version.AppName,
8988
),
9089
),
91-
RunE: func(cmd *cobra.Command, args []string) error {
90+
RunE: func(cmd *cobra.Command, _ []string) error {
9291
clientCtx, err := client.GetClientTxContext(cmd)
9392
if err != nil {
9493
return err
@@ -124,7 +123,7 @@ $ %s query gov min-initial-deposit
124123
version.AppName,
125124
),
126125
),
127-
RunE: func(cmd *cobra.Command, args []string) error {
126+
RunE: func(cmd *cobra.Command, _ []string) error {
128127
clientCtx, err := client.GetClientTxContext(cmd)
129128
if err != nil {
130129
return err
@@ -160,7 +159,7 @@ $ %s query gov participation
160159
),
161160
),
162161
Args: cobra.NoArgs,
163-
RunE: func(cmd *cobra.Command, args []string) error {
162+
RunE: func(cmd *cobra.Command, _ []string) error {
164163
clientCtx, err := client.GetClientQueryContext(cmd)
165164
if err != nil {
166165
return err

x/gov/client/utils/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
sdk "github.com/cosmos/cosmos-sdk/types"
88
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
99
"github.com/cosmos/cosmos-sdk/x/gov/types"
10-
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
10+
"github.com/cosmos/cosmos-sdk/x/gov/types/v1"
1111
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
1212
)
1313

0 commit comments

Comments
 (0)