Skip to content

Fnn cli#28

Open
15168316096 wants to merge 20 commits intomainfrom
fnn-cli
Open

Fnn cli#28
15168316096 wants to merge 20 commits intomainfrom
fnn-cli

Conversation

@15168316096
Copy link
Copy Markdown
Collaborator

Fnn cli test

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py wrapper to run fnn-cli and parse JSON/YAML output.
  • Add devnet test suites for fnn-cli (info/peer/channel/invoice/payment/graph) and list_payments RPC behavior.
  • Extend trampoline routing + one-way channel integration tests and update prepare.sh to copy fnn-cli artifacts.

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.

Comment thread framework/fnn_cli.py
Comment on lines +165 to +168
str_map = {
"enabled": "--enabled",
"tlc_expiry_delta": "--tlc-expiry-delta",
"tlc_minimum_value": "--tlc-minimum-value",
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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",

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +119
pytest.xfail(
"pending fix: receiver should validate preimage using invoice hash_algorithm "
f"(sha256), error={str(e)}"
)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +72
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"]
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=...)).

Suggested change
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)

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,268 @@
name: fnn-cli test

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add it directly to fiber test.yml?

@@ -0,0 +1,181 @@
# Fiber RPC API Reference
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need upgrade

Comment thread prepare.sh
cd fiber
cargo build
cp target/debug/fnn ../download/fiber/current/fnn.debug
cp target/debug/fnn-cli ../download/fiber/current/fnn-cli.debug
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cp target/debug/fnn-cli ../download/fiber/current/fnn-cli.debug

15168316096 and others added 5 commits March 12, 2026 14:50
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants