-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(x/gov): deposits in simulations #18336
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -322,7 +322,12 @@ func SimulateMsgDeposit( | |
return simtypes.NoOpMsg(types.ModuleName, TypeMsgDeposit, "unable to generate proposalID"), nil, nil | ||
} | ||
|
||
deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address, false, false) | ||
p, err := k.Proposals.Get(ctx, proposalID) | ||
if err != nil { | ||
return simtypes.NoOpMsg(types.ModuleName, TypeMsgDeposit, "unable to get proposal"), nil, err | ||
} | ||
|
||
deposit, skip, err := randomDeposit(r, ctx, ak, bk, k, simAccount.Address, false, p.Expedited) | ||
switch { | ||
case skip: | ||
return simtypes.NoOpMsg(types.ModuleName, TypeMsgDeposit, "skip deposit"), nil, nil | ||
|
@@ -592,7 +597,6 @@ func randomDeposit( | |
return nil, false, err | ||
} | ||
amount = amount.Add(minAmount) | ||
amount = amount.MulRaw(3) // 3x what's required // TODO: this is a hack, we need to be able to calculate the correct amount using params | ||
|
||
if amount.GT(spendableBalance) || amount.LT(threshold) { | ||
return nil, true, nil | ||
Comment on lines
597
to
602
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error handling here is good, it checks for errors and handles them appropriately. However, the error messages could be more descriptive to provide more context about the error. For example, instead of "unable to generate deposit", you could say "unable to generate deposit in randomDeposit function". This would make it easier to debug if an error occurs. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling here is good, it checks for errors and handles them appropriately. However, the error messages could be more descriptive to provide more context about the error. For example, instead of "unable to generate proposalID", you could say "unable to generate proposalID in SimulateMsgDeposit function". This would make it easier to debug if an error occurs.