Fnn cli#28
Conversation
Merge pull request #15 from gpBlockchain/oneway_channel
There was a problem hiding this comment.
Pull request overview
Adds a Python test harness for the new fnn-cli binary (plus list_payments RPC) and expands devnet integration coverage for trampoline routing and one-way channels.
Changes:
- Add
framework/fnn_cli.pywrapper to runfnn-cliand parse JSON/YAML output. - Add devnet test suites for
fnn-cli(info/peer/channel/invoice/payment/graph) andlist_paymentsRPC behavior. - Extend trampoline routing + one-way channel integration tests and update
prepare.shto copyfnn-cliartifacts.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test_cases/fiber/devnet/trampoline_routing/test_allowTramponlieRouting.py | Refactors/expands trampoline routing scenarios (success + failure cases, extra sync helpers). |
| test_cases/fiber/devnet/one_way/test_oneway_channel.py | Adds more one-way channel behavior tests (directionality, restart, shutdown edge cases). |
| test_cases/fiber/devnet/fnn-cli/test_list_payments_rpc.py | Adds RPC-level tests for list_payments filtering/pagination/consistency. |
| test_cases/fiber/devnet/fnn-cli/test_cli_peer.py | Adds CLI peer command tests. |
| test_cases/fiber/devnet/fnn-cli/test_cli_payment.py | Adds CLI payment + list_payments tests (including dry-run). |
| test_cases/fiber/devnet/fnn-cli/test_cli_output_format.py | Adds CLI output format validation tests (json/yaml/raw). |
| test_cases/fiber/devnet/fnn-cli/test_cli_invoice.py | Adds CLI invoice lifecycle tests. |
| test_cases/fiber/devnet/fnn-cli/test_cli_info.py | Adds CLI node_info parity tests vs RPC. |
| test_cases/fiber/devnet/fnn-cli/test_cli_graph.py | Adds CLI graph query tests and parity checks vs RPC. |
| test_cases/fiber/devnet/fnn-cli/test_cli_channel.py | Adds CLI channel lifecycle tests. |
| test_cases/fiber/devnet/accept_channel/test_accept_channel.py | Removes an old commented-out/placeholder file. |
| prepare.sh | Copies fnn-cli debug/release binaries into download/fiber/current/. |
| framework/fnn_cli.py | New FnnCli subprocess wrapper used by the new CLI tests. |
| framework/fiber_rpc.py | Adds list_payments RPC method wrapper. |
| .github/workflows/fiber-fnn-cli.yml | New CI workflow to build fiber + run fnn-cli-focused test groups. |
| .cursor/skills/fiber-test/** | Adds internal reference docs for test patterns / concepts / API notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| str_map = { | ||
| "enabled": "--enabled", | ||
| "tlc_expiry_delta": "--tlc-expiry-delta", | ||
| "tlc_minimum_value": "--tlc-minimum-value", |
There was a problem hiding this comment.
update_channel() uses kwarg key tlc_minimum_value, but open_channel()/accept_channel() use tlc_min_value. This inconsistency makes the wrapper API error-prone (a caller passing tlc_min_value will be silently ignored). Consider standardizing on tlc_min_value (and optionally supporting tlc_minimum_value as a backward-compatible alias).
| str_map = { | |
| "enabled": "--enabled", | |
| "tlc_expiry_delta": "--tlc-expiry-delta", | |
| "tlc_minimum_value": "--tlc-minimum-value", | |
| # Normalize legacy/alias kwarg name for minimum TLC value | |
| if "tlc_minimum_value" in kwargs and "tlc_min_value" not in kwargs: | |
| kwargs["tlc_min_value"] = kwargs["tlc_minimum_value"] | |
| del kwargs["tlc_minimum_value"] | |
| str_map = { | |
| "enabled": "--enabled", | |
| "tlc_expiry_delta": "--tlc-expiry-delta", | |
| "tlc_min_value": "--tlc-min-value", |
| pytest.xfail( | ||
| "pending fix: receiver should validate preimage using invoice hash_algorithm " | ||
| f"(sha256), error={str(e)}" | ||
| ) |
There was a problem hiding this comment.
pytest.xfail() is triggered for any exception from wait_payment_state(), which can mask unrelated infra/test flakiness (timeouts, connectivity, topology issues) as an expected failure. It would be safer to only xfail when the caught error matches the known sha256/hash_algorithm validation issue, and re-raise otherwise (or use a conditional @pytest.mark.xfail with a strict reason).
| pytest.xfail( | |
| "pending fix: receiver should validate preimage using invoice hash_algorithm " | |
| f"(sha256), error={str(e)}" | |
| ) | |
| error_msg = str(e).lower() | |
| if "hash_algorithm" in error_msg or "sha256" in error_msg: | |
| pytest.xfail( | |
| "pending fix: receiver should validate preimage using invoice hash_algorithm " | |
| f"(sha256), error={str(e)}" | |
| ) | |
| raise |
| time.sleep(20) | ||
|
|
||
| channels_after = cli1.list_channels(include_closed=True) | ||
| found = False | ||
| for ch in channels_after["channels"]: | ||
| if ch["channel_id"] == channel_id: | ||
| found = True | ||
| assert "CLOSED" in ch["state"]["state_name"] or ch["state"][ | ||
| "state_name" | ||
| ] in ["SHUTTING_DOWN", "CLOSED"] |
There was a problem hiding this comment.
Using a fixed time.sleep(20) after shutdown_channel makes this test both slow and potentially flaky (close can legitimately take longer/shorter). Prefer waiting on a concrete condition (e.g., poll list_channels(include_closed=True) until the target channel_id reaches SHUTTING_DOWN/CLOSED, or use the existing wait_for_channel_state(..., include_closed=True, channel_id=...)).
| time.sleep(20) | |
| channels_after = cli1.list_channels(include_closed=True) | |
| found = False | |
| for ch in channels_after["channels"]: | |
| if ch["channel_id"] == channel_id: | |
| found = True | |
| assert "CLOSED" in ch["state"]["state_name"] or ch["state"][ | |
| "state_name" | |
| ] in ["SHUTTING_DOWN", "CLOSED"] | |
| # Wait until the channel is observed in a terminal state instead of using a fixed sleep. | |
| deadline = time.time() + 60 | |
| found = False | |
| while time.time() < deadline and not found: | |
| channels_after = cli1.list_channels(include_closed=True) | |
| for ch in channels_after["channels"]: | |
| if ch["channel_id"] == channel_id: | |
| state_name = ch["state"]["state_name"] | |
| if state_name in ["SHUTTING_DOWN", "CLOSED"] or "CLOSED" in state_name: | |
| found = True | |
| break | |
| if not found: | |
| time.sleep(1) |
| @@ -0,0 +1,268 @@ | |||
| name: fnn-cli test | |||
|
|
|||
There was a problem hiding this comment.
Why not add it directly to fiber test.yml?
| @@ -0,0 +1,181 @@ | |||
| # Fiber RPC API Reference | |||
| cd fiber | ||
| cargo build | ||
| cp target/debug/fnn ../download/fiber/current/fnn.debug | ||
| cp target/debug/fnn-cli ../download/fiber/current/fnn-cli.debug |
There was a problem hiding this comment.
| cp target/debug/fnn-cli ../download/fiber/current/fnn-cli.debug |
* Initial plan * Update fnn-cli and tests for peer_id → pubkey migration per issue #29 Co-authored-by: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com>
Fnn cli test