fix(cli): admin payout-issue reports success even when payout_bounty loses the amount#846
Open
ebios-star wants to merge 1 commit intoentrius:testfrom
Open
Conversation
…loses the amount
`IssueCompetitionContractClient.payout_bounty` returns three values:
- a positive int → success with known amount
- 0 → success but the pre-payout `get_issue` couldn't reach the
chain (RPC flake / dropped websocket), so the function lost
track of the bounty even though the extrinsic succeeded
- None → extrinsic failed
`gitt admin payout-issue` collapsed cases 2 and 3 with `if result:` and
printed "Payout failed." — exiting non-zero — when the on-chain
state had actually paid out. Operators retried the call and hit the
contract's already-Completed revert, reinforcing the wrong belief.
The CLI already reads the issue once before submitting (line 139), so
when `payout_bounty` returns 0 we can fall back to that locally-known
bounty for the success message instead of mis-labelling the round as
a failure.
Use `result is not None` to gate success/failure, prefer the contract
client's amount when it's positive, and fall back to `issue.bounty_amount`
when it's 0. The contract_client API stays unchanged.
Add `TestAdminPayoutSuccessWithUnknownAmount` covering all three cases:
the 0-return success path, the None-return failure path, and the
positive-return path (forward-compatible with any future re-read).
Closes entrius#844.
Contributor
Author
|
@anderdc @LandynDev — friendly ping for review when you have a moment. Closes #844. Switched to Happy to rebase if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #844.
`IssueCompetitionContractClient.payout_bounty` returns three different values:
`gitt admin payout-issue` collapsed the last two cases with `if result:` and printed "Payout failed." — exiting non-zero — when the on-chain state had actually paid out. Operators retried the call and hit the contract's already-Completed revert, reinforcing the wrong belief.
The CLI already reads the issue once before submitting (line 139), so when `payout_bounty` returns `0` we can fall back to that locally-known bounty for the success message instead of mis-labelling the round as a failure.
After this change:
Related Issues
Closes #844.
Type of Change
Testing
Checklist