Skip to content

test(sdk/python): add Click CliRunner test suite for the SDK CLI (bounty #17181) - #8661

Open
czfygc wants to merge 1 commit into
Scottcjn:mainfrom
czfygc:test/sdk-cli-17181
Open

czfygc wants to merge 1 commit into
Scottcjn:mainfrom
czfygc:test/sdk-cli-17181

Conversation

@czfygc

@czfygc czfygc commented Nov 11, 2026

Copy link
Copy Markdown

Add a full pytest suite for the Python SDK Click CLI (sdk/python/rustchain_sdk/cli.py) — the CLI is the command users copy from the README and until now had zero tests.

Closes none (public bounty rustchain-bounties#17181, RTC for the fix — see that issue for payout rules).

Command → test mapping (sdk/python/tests/test_cli.py, 80 tests / 75 passed / 5 xfailed locally)

CLI command / option Test(s)
rustchain --help / --version / group --help TestGlobalHelpAndVersion
wallet create (12/24 words, --json, help) TestWalletCreate
wallet balance <addr> (--json, --node, missing arg, connection/HTTP/non-JSON, help) TestWalletBalance
wallet send <from> <to> <amt> (--fee, --seed, --json, --node, amount serialization, address mismatch, missing seed, abc/negative/zero amounts, help) TestWalletSend, TestWalletSendAmountSerialization
node (healthy/unhealthy, --json, --node, conn/HTTP, help) TestNodeStatus
epoch (--json, --node, conn, help) TestEpochInfo
miners list (empty/non-empty, --json, --node, conn, help, miners --help) TestMinersList
attest <addr> (--json, challenge/no-challenge, mismatch, missing seed, conn/HTTP, --node, help) TestAttest
No-traceback leakage on error paths TestNoTracebackLeakage
Input validation (address format, words type, missing args) TestInputValidation

Regression tests (per #17181)

Issue Status here Test(s)
#8564 (decimal amount rejected, type=int) xfail(strict=True) — in-flight fix by others TestRegression8564
#8565 (README example rustchain node status vs CLI rustchain node) Verified docs-bug; test documents TestRegression8565
#8566 (attest --json returns status without executing) xfail(strict=True) — asserts expected behavior (challenge+submit called), flips on fix TestRegression8566, TestAttest::test_attest_json_outputs_status_and_returns
#8580 (balance prints 0 RTC) xfail(strict=True) — regression test sits at the canonical-parsing layer; documented why the class-level mock cannot reach it TestRegression8580
#8618 (float money representation) xfail(strict=True) — expects the fixed representation TestRegression8618

Notes

  • No live network: HTTP is fully mocked (stdlib unittest.mock, AsyncMock on RustChainClient).
  • --json outputs are json.loads'd and key-checked; human outputs assert key figures.
  • Assertions are real (no exit_code in (0,1,2)), error paths assert stderr messages and no tracebacks.
  • git status: only sdk/python/tests/test_cli.py, sdk/python/requirements-dev.txt, .github/workflows/sdk-python.yml added.
  • CI: the repo had no sdk/python job; this adds one minimal workflow (.github/workflows/sdk-python.yml) running the suite on pushes/PRs touching sdk/python/**.
  • Verified locally on Windows + Python 3.12 (pytest 9.2.0): 75 passed, 5 xfailed, matching this description.

DCO: committed with git commit -s. No source files were modified.

…nty #17181)

Signed-off-by: czfygc <209356221+czfygc@users.noreply.github.com>
@czfygc
czfygc requested a review from Scottcjn as a code owner November 11, 2026 10:25
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) ci size/XL PR: 500+ lines labels Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR is quite large (XL). Consider splitting into smaller, focused PRs for faster review. Large PRs take longer to review and have higher risk of issues.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) ci size/XL PR: 500+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant