Skip to content

itest: port custom channel tests from lightning-terminal#2001

Open
darioAnongba wants to merge 8 commits intomainfrom
test/custom_channels_move
Open

itest: port custom channel tests from lightning-terminal#2001
darioAnongba wants to merge 8 commits intomainfrom
test/custom_channels_move

Conversation

@darioAnongba
Copy link
Contributor

@darioAnongba darioAnongba commented Feb 19, 2026

Ports all custom channel test functions and helper functions from lightning-terminal/itest into taproot-assets/itest/custom_channels, so custom channel integration tests can run natively in taproot-assets without depending on lightning-terminal.

  • Port the tests functions into individual files (e.g., core_test.go, grouped_asset_test.go, liquidity_test.go, etc.) alongside the existing large_test.go from test: custom channel itests #1986.
  • Enhance IntegratedNode with waitForTapd() and chain-sync polling in fetchNodeInfo()
  • Improve EnsureConnected() with retry logic for startup errors
  • Export OracleHarness for use by custom channel oracle/decode-invoice tests

Run with: make itest-cc (all) or make itest-cc cccase=large (single test).

@gemini-code-assist
Copy link

Summary of Changes

Hello @darioAnongba, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the integration testing framework for Taproot Assets custom channels. By migrating the test suite from lightning-terminal directly into taproot-assets, it streamlines the development process and reduces external dependencies. The changes also introduce robustness improvements to the test harness, ensuring that nodes are properly synchronized and connected before test execution, leading to more stable and reliable integration tests for critical channel functionality.

Highlights

  • Test Suite Migration: Ported 22 custom channel test functions and approximately 90 helper functions from lightning-terminal/itest to taproot-assets/itest/custom_channels, enabling native execution within taproot-assets.
  • Test Organization: Organized the ported tests into individual files (e.g., core_test.go, grouped_asset_test.go) for better modularity and readability.
  • Harness Enhancements: Enhanced the IntegratedNode with waitForTapd() and chain-sync polling in fetchNodeInfo() for improved test setup reliability.
  • Connection Stability: Improved EnsureConnected() with retry logic to handle transient startup errors during node connections.
  • API Export: Exported OracleHarness to allow its use by custom channel oracle/decode-invoice tests, increasing reusability.
  • RPC Server Readiness: Implemented ensureReady checks in various tapd RPC methods to prevent calls before the server is fully initialized, particularly in the integrated lnd+tapd binary.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • itest/custom_channels/balance_consistency_test.go
    • Added a new test file to verify balance consistency during channel operations.
  • itest/custom_channels/core_test.go
    • Added a new test file for core custom channel functionality, including multi-hop payments and channel lifecycle management.
  • itest/custom_channels/custom_channels_test.go
    • Added multiple new custom channel test cases to the test suite, including grouped asset, liquidity, pathfinding, and strict forwarding tests.
    • Added logic to create log directories for miner and chain backend cleanup.
    • Modified test execution to tear down all nodes between test cases to prevent resource accumulation.
  • itest/custom_channels/decode_invoice_test.go
    • Added a new test file for decoding asset invoices, including scenarios with custom price oracles and decimal displays.
  • itest/custom_channels/force_close_test.go
    • Added a new test file to test force close scenarios, including asset sweeping and on-chain transfers.
  • itest/custom_channels/forward_bandwidth_test.go
    • Added a new test file to test forward bandwidth edge cases, including scenarios with depleted asset liquidity and small payment amounts.
  • itest/custom_channels/group_tranches_force_close_test.go
    • Added a new test file to test force closing channels with multiple tranches of grouped assets.
  • itest/custom_channels/group_tranches_htlc_force_close_test.go
    • Added a new test file to test force closing channels with multiple tranches of grouped assets and pending HTLCs.
  • itest/custom_channels/grouped_asset_test.go
    • Added a new test file for custom channels using grouped assets, covering various payment and channel management scenarios.
  • itest/custom_channels/helpers.go
    • Added numerous helper functions for payment, HTLC events, channel balance assertions, spendable balance assertions, and force close scenarios.
    • Ensured peers are connected before channel close and fund calls to prevent transient disconnection errors.
    • Adjusted delta tolerance for require.InDelta in defaultCoOpCloseBalanceCheck.
    • Introduced itestNode and multiRfqNodes structs and related helper functions for complex network topologies.
  • itest/custom_channels/htlc_force_close_test.go
    • Added new test files for HTLC force close scenarios, including both single-shard and MPP payments.
  • itest/custom_channels/liquidity_test.go
    • Added new test files for liquidity edge cases in custom channels, covering scenarios like insufficient sats, dust HTLCs, and large asset invoices.
  • itest/custom_channels/multi_channel_pathfinding_test.go
    • Added a new test file to verify correct pathfinding when multiple asset channels exist between the same pair of nodes.
  • itest/custom_channels/multi_rfq_test.go
    • Added a new test file for multi-RFQ functionality, testing payment splitting across multiple asset channels for both sending and receiving.
  • itest/custom_channels/oracle_pricing_test.go
    • Added a new test file to test payments through asset channels using an external RPC price oracle with a buy/sell spread.
  • itest/custom_channels/self_payment_test.go
    • Added a new test file to test self-payment over asset channels, routing payments through a combination of BTC and asset channels.
  • itest/custom_channels/single_asset_multi_input_test.go
    • Added a new test file to verify funding a channel using multiple inputs from the same asset.
  • itest/custom_channels/strict_forwarding_test.go
    • Added a new test file to test strict forwarding behavior, ensuring correct rejection of mismatched payment types (sats to asset invoice, assets to BTC invoice).
  • itest/custom_channels/vars.go
    • Increased ccShortTimeout from 5 to 10 seconds.
    • Changed debuglevel for lndArgsTemplate from trace,BTCN=info to warn to reduce log verbosity.
    • Added new lnrpc.PaymentFailureReason variables for common payment failure reasons.
    • Added burnAddr and assetBurnConfirmationText constants.
  • itest/integrated_harness.go
    • Added FeeServiceURL field to IntegratedNetworkHarness to support external fee estimation services.
    • Modified NewNode to pass FeeServiceURL to lnd arguments if configured.
    • Improved EnsureConnected with retry logic for transient startup errors and explicit handling of 'already connected' messages.
  • itest/integrated_node.go
    • Modified fetchNodeInfo to wait for SyncedToChain status before returning.
    • Added waitForTapd method to poll tapd's GetInfo until the tapd subsystem is fully initialized and responsive.
  • itest/oracle_harness.go
    • Renamed oracleHarness to OracleHarness and exported its methods (newOracleHarness to NewOracleHarness, setPrice to SetPrice, start to Start, stop to Stop) for broader use.
  • itest/rfq_forwards_test.go
    • Updated calls to newOracleHarness and its methods to use the newly exported OracleHarness and its public methods.
  • itest/rfq_test.go
    • Updated calls to newOracleHarness, setPrice, start, and stop to use the newly exported OracleHarness and its public methods.
  • rpcserver/rpcserver.go
    • Added ErrServerNotReady and ensureReady function to prevent RPC calls before the tapd RPC server has been fully initialized.
    • Integrated ensureReady checks into GetInfo, MintAsset, FinalizeBatch, ListAssets, ListBalances, SubscribeReceiveEvents, SubscribeSendEvents, SubscribeMintEvents, and FundChannel RPC methods to improve stability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request ports a large number of custom channel integration tests from lightning-terminal, which is a significant and valuable effort. The changes also include several improvements to the test harness and RPC server robustness, such as adding retry logic and readiness checks, which will enhance test stability. My review focuses on the newly added test code. I've identified a recurring pattern of using hardcoded 'magic numbers' for balance adjustments in tests, likely to account for rounding errors. While the accompanying comments sometimes mention this, the tests would be more maintainable and less brittle if these adjustments were either explained in more detail or replaced with delta assertions. I've also noted a few misleading comments that should be clarified.

@coveralls
Copy link

coveralls commented Feb 19, 2026

Pull Request Test Coverage Report for Build 22369821846

Details

  • 16 of 1468 (1.09%) changed or added relevant lines in 5 files are covered.
  • 290 unchanged lines in 23 files lost coverage.
  • Overall coverage increased (+7.0%) to 54.449%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rpcserver/rpcserver.go 12 32 37.5%
itest/integrated_harness.go 0 35 0.0%
itest/integrated_node.go 0 36 0.0%
itest/custom_channels/helpers.go 0 1361 0.0%
Files with Coverage Reduction New Missed Lines %
fn/context_guard.go 1 91.94%
asset/group_key.go 2 72.15%
itest/integrated_harness.go 2 0.0%
tapdb/addrs.go 2 76.56%
tapdb/assets_common.go 2 79.07%
tapdb/migrations.go 2 76.82%
tapdb/universe.go 2 80.81%
proof/verifier.go 3 86.62%
tapdb/sqlc/db_custom.go 3 70.83%
tapgarden/planter.go 3 80.26%
Totals Coverage Status
Change from base Build 22301885749: 7.0%
Covered Lines: 67298
Relevant Lines: 123599

💛 - Coveralls

@darioAnongba darioAnongba moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Feb 19, 2026
@darioAnongba darioAnongba force-pushed the test/custom_channels_move branch 5 times, most recently from bb64829 to c0cbbb7 Compare February 26, 2026 12:38
Add infrastructure for running custom channel integration tests in
parallel across multiple tranches, matching the pattern used by the
standard integration tests.
@darioAnongba darioAnongba force-pushed the test/custom_channels_move branch from c0cbbb7 to 3de9a62 Compare February 26, 2026 13:28
@darioAnongba darioAnongba marked this pull request as ready for review February 26, 2026 13:41
@darioAnongba darioAnongba force-pushed the test/custom_channels_move branch 3 times, most recently from c274bcb to 2c032ac Compare February 26, 2026 17:58
Add CI jobs to build and run custom channel integration tests.

Currently configured for 1 job x 1 tranche (1 test ported). To scale
when more tests are ported, increase NUM_CC_ITEST_JOBS and
CC_ITEST_PARALLELISM env vars and expand the matrix.tranche array.
Export OracleHarness and its methods (NewOracleHarness, SetPrice,
Start, Stop) so the custom_channels subpackage can use the same mock
price oracle server for oracle pricing and decode invoice tests.
Improve the integrated test infrastructure to support the full suite
of ported custom channel tests.
@darioAnongba darioAnongba force-pushed the test/custom_channels_move branch 2 times, most recently from 314f64c to 35d7c8b Compare February 26, 2026 22:25
@jtobin jtobin linked an issue Feb 27, 2026 that may be closed by this pull request
8 tasks
Copy link
Member

@jtobin jtobin left a comment

Choose a reason for hiding this comment

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

LGTM. 👍 👍 Made a few comments on some stuff that obviously already existed in LiT, but which could stand to be fixed here (mainly the s/erin/fabia thing).

I'm observing some force close flakes when running locally and remember you mentioning you saw some of these as well. I don't think it's a blocker to merge, though. Would be nice to be rid of flakes now, but better to figure them out afterwards if need be.

@darioAnongba darioAnongba force-pushed the test/custom_channels_move branch from 35d7c8b to b1b5b63 Compare February 27, 2026 10:26
@darioAnongba darioAnongba force-pushed the test/custom_channels_move branch 6 times, most recently from 889fb5c to d932ccd Compare February 27, 2026 14:56
Port all 22 custom channel test functions from lightning-terminal into
the taproot-assets itest/custom_channels subpackage. Each test lives
in its own file.
RFQ quote expiry timestamps are expressed as Unix seconds (truncated),
while the invoice expiry timestamp was computed with nanosecond
precision. This sub-second mismatch caused valid quotes — whose expiry
lands on the same second as the invoice expiry — to be rejected with
"no quotes with sufficient expiry".

Truncate the invoice expiry timestamp to second precision before
comparing it against quote expiry times.
@darioAnongba darioAnongba force-pushed the test/custom_channels_move branch from d932ccd to b3cf8f7 Compare February 27, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

[feature]: Own custom_channels itests in taproot-assets (decouple from LiT)

3 participants