fix(cli): treat a zero bounty payout as success, not failure#1614
Open
dalledajay-coder wants to merge 1 commit into
Open
fix(cli): treat a zero bounty payout as success, not failure#1614dalledajay-coder wants to merge 1 commit into
dalledajay-coder wants to merge 1 commit into
Conversation
payout_bounty returns a non-None int on success (0 when the pre-read bounty amount is unavailable) and None only on failure, but the payout-issue command checked the result for truthiness, so a successful zero-amount payout was reported as a failed transaction and exited non-zero. Check 'is not None' instead. Adds a regression test asserting a 0 return reports success and a None return still reports failure.
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
gitt admin payout-issuereports a successful payout as a failure wheneverpayout_bountyreturns0.payout_bountyreturns a non-None int on success (0when the pre-read bounty amount is unavailable) andNoneonly on failure, but the caller ingittensor/cli/issue_commands/admin.pyused a truthiness check (if result:), so a successful zero-amount payout printed "Payout failed." and exited 1 even though the transaction went through.This implements the caller-side fix @anderdc described when closing #1577: change the guard to
if result is not None:— one line in the caller, no change tocontract_client.py, no extra re-read on the success path.The sibling admin commands (
cancel-issue,set-owner,set-treasury,add-vali,remove-vali) are deliberately unchanged: their client methods all returnboolvia_exec_tx_bool, so truthiness is correct there.Related Issues
None — implements the correct fix spelled out in the closure of PR #1577.
Type of Change
Testing
Added
TestCliAdminPayoutResultHandlingintests/cli/test_cli_helpers.py, mocking the contract client on the existing CLI-runner path: apayout_bountyreturn of0must report success and exit 0, and a return ofNonemust still report failure and exit non-zero.Full local run on this branch:
uv run pytest— 962 passed;uv run ruff check .anduv run ruff format --check .— clean;uv run pyright— 0 errors, 0 warnings.Checklist