lnd/itest
Alex Akselrod 05de72c669
itest: fix flake in multi-hop payments
To make this itest work reliably with multiple parallel SQL
transactions, we need to count both the settle and final HTLC
events. Otherwise, sometimes the final events from earlier
forwards are counted before the forward events from later
forwards, causing a miscount of the settle events. If we
expect both the settle and final event for each forward,
we don't miscount.
2025-01-28 18:22:11 +01:00
..
list_off_test.go itest+lntest: migrate lntemp to lntest 2023-02-23 21:56:09 +08:00
list_on_test.go itest: add basic invoice HTLC modifier integration test 2024-10-11 14:17:26 +02:00
lnd_amp_test.go channeldb: filter AMP state to relevant set IDs 2024-09-06 12:59:32 -07:00
lnd_channel_backup_test.go itest: remove unused param in chanRestoreViaRPC 2024-07-23 21:30:08 +08:00
lnd_channel_balance_test.go itest+lntest: migrate lntemp to lntest 2023-02-23 21:56:09 +08:00
lnd_channel_force_close_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_channel_funding_fund_max_test.go multi: update linter, fix new issues 2024-10-11 14:02:30 +02:00
lnd_channel_funding_utxo_selection_test.go multi: update linter, fix new issues 2024-10-11 14:02:30 +02:00
lnd_channel_graph_test.go lntest+itest: add new method CurrentHeight 2024-07-23 21:30:08 +08:00
lnd_channel_policy_test.go itest: add more tests related to inbound fees 2024-05-22 20:48:52 +02:00
lnd_coop_close_external_delivery_test.go itest: coop_close_with_external_delivery with p2tr 2024-10-30 14:16:37 +01:00
lnd_coop_close_with_htlcs_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_custom_features.go itest: add coverage for custom features 2023-05-04 10:42:17 -04:00
lnd_custom_message_test.go itest: move lnd_custom_{message => message_test}.go 2023-04-18 09:40:18 +02:00
lnd_estimate_route_fee_test.go itest: fix misuse of MineBlocks and replace it with 2024-07-23 21:30:08 +08:00
lnd_etcd_failover_test.go itest: add itest covering the leader healthcheck 2024-08-01 19:04:10 +02:00
lnd_forward_interceptor_test.go itest: add basic invoice HTLC modifier integration test 2024-10-11 14:17:26 +02:00
lnd_funding_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_hold_invoice_force_test.go lntest+itest: add new method CurrentHeight 2024-07-23 21:30:08 +08:00
lnd_hold_persistence_test.go itest+lntest: migrate lntemp to lntest 2023-02-23 21:56:09 +08:00
lnd_htlc_test.go itest+lntest: make sure states are cleaned when tests end 2023-03-15 00:01:40 +08:00
lnd_invoice_acceptor_test.go itest: add basic invoice HTLC modifier integration test 2024-10-11 14:17:26 +02:00
lnd_macaroons_test.go macaroons: reject unknown macaroon versions 2023-10-31 13:23:50 -07:00
lnd_max_channel_size_test.go itest+lntest: migrate lntemp to lntest 2023-02-23 21:56:09 +08:00
lnd_max_htlcs_test.go multi: add new config usestatusinitiated for the new payment status 2023-11-15 20:18:17 +08:00
lnd_misc_test.go itest: add testSendSelectedCoins to check selected utxos 2024-08-07 20:42:58 +08:00
lnd_mpp_test.go itest: fix misuse of MineBlocks and replace it with 2024-07-23 21:30:08 +08:00
lnd_multi-hop-error-propagation_test.go itest: multi part payments test fix. 2024-01-08 16:47:47 +01:00
lnd_multi-hop-payments_test.go itest: fix flake in multi-hop payments 2025-01-28 18:22:11 +01:00
lnd_multi-hop_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_network_test.go itest+lntest: use system wide unique ports everywhere 2024-03-18 16:13:39 +01:00
lnd_neutrino_test.go itest+lntest: migrate lntemp to lntest 2023-02-23 21:56:09 +08:00
lnd_no_etcd_dummy_failover_test.go itest: add itest covering the leader healthcheck 2024-08-01 19:04:10 +02:00
lnd_nonstd_sweep_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_onchain_test.go itest: fix misuse of MineBlocks and replace it with 2024-07-23 21:30:08 +08:00
lnd_open_channel_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_payment_test.go itest: add testSendToRouteFailHTLCTimeout to check SendToRouteV2 2024-08-07 22:17:58 +08:00
lnd_psbt_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_recovery_test.go itest: fix misuse of MineBlocks and replace it with 2024-07-23 21:30:08 +08:00
lnd_remote_signer_test.go itest: add new test to check BumpFee and PendingSweeps 2024-04-19 21:33:38 +08:00
lnd_res_handoff_test.go itest: fix misuse of MineBlocks and replace it with 2024-07-23 21:30:08 +08:00
lnd_rest_api_test.go lntest+itest: make Miner a private instance 2024-07-23 21:30:08 +08:00
lnd_revocation_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_route_blinding_test.go lnwallet+itest: fix PaymentDescriptor creation for blinded path htlc 2024-08-22 14:21:30 +02:00
lnd_routing_test.go itest: add dynamic scid alias routing test 2024-10-11 14:13:46 +02:00
lnd_rpc_middleware_interceptor_test.go itest+lntest: migrate lntemp to lntest 2023-02-23 21:56:09 +08:00
lnd_send_multi_path_payment_test.go itest: preparatory fee estimation changes 2024-03-05 09:24:27 +01:00
lnd_signer_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_single_hop_invoice_test.go itest+lntest: migrate lntemp to lntest 2023-02-23 21:56:09 +08:00
lnd_sweep_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_switch_test.go itest: cleanup channels for testSwitchOfflineDeliveryOutgoingOffline 2023-05-20 00:33:56 +08:00
lnd_taproot_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_test.go lntest+itest: add new method CurrentHeight 2024-07-23 21:30:08 +08:00
lnd_trackpayments_test.go routerrpc+itest: make sure TrackPayments is compatible 2023-11-15 20:18:21 +08:00
lnd_wallet_import_test.go itest+lntest: stop using pointer to chainhash.Hash 2024-10-21 13:26:09 +02:00
lnd_watchtower_test.go lntest+itest: finalize moving miner methods 2024-07-23 21:30:07 +08:00
lnd_wipe_fwdpkgs_test.go itest+lntest: fix itest re the new block driven behavior 2024-04-19 21:33:26 +08:00
lnd_wumbo_channels_test.go itest+lntest: migrate lntemp to lntest 2023-02-23 21:56:09 +08:00
lnd_zero_conf_test.go lntest+itest: add new method CurrentHeight 2024-07-23 21:30:08 +08:00
log_check_errors.sh multi: move itest out of lntest 2023-02-23 21:56:08 +08:00
log_substitutions.txt lntest/itest: adds tests for fundmax flag of cli:openchannel 2023-04-05 23:09:12 +02:00
README.md itest: add readme 2023-02-23 21:56:12 +08:00

Integration Test

itest is a package that houses the integration tests made for lnd. This package builds test cases using the test framework lntest.

Add New Tests

To add a new test case, create a TestFunc and add it in list_on_test.go. Ideally, the Name should just be the snake case of the name used in TestFunc without the leading test and underscores. For instance, to test lnd's exporting channel backup, we have,

{
		Name:     "export channel backup",
		TestFunc: testExportChannelBackup,
}

The place to put the code of the TestFunc is case-specific. itest package has loosely defined a list of files to test different functionalities of lnd. The new test needs to be put into one of these files, otherwise, a new file needs to be created.

Run Tests

Run a single test case

To run a single test case, use make itest icase=$case, where case is the name defined in list_on_test.go, with spaces replaced with underscores(_).

# Run `testListChannels`.
make itest icase=list_channels

Run multiple test cases

There are two ways to run multiple test cases. One way is to use make itest icase=$cases, where cases has the format cases='(case|case|...)'. The case is the name defined in list_on_test.go, with spaces replaced with underscores(_).

# Run `testListChannels` and `testListAddresses` together.
make itest icase='(list_channels|list_addresses)'

Another way to run multiple cases is similar to how Go runs its tests - by simple regex matching. For instance, the following command will run three cases since they all start with the word list,

# Run `testListChannels`, `testListAddresses`, and `testListPayments` together.
make itest icase=list

Run all tests

To run all tests, use make itest without icase flag.

# Run all test cases.
make itest

Run tests in parallel

To run tests in parallel, use make itest-parallel. This command takes two special arguments,

  • tranches, specifies the number of parts the test cases will be split into.
  • parallel, specifies the number of threads to run in parallel. This value must be smaller than or equal to tranches.
# Split the tests into 4 parts, and run them using 2 threads.
make itest-parallel tranches=4 parallel=2

By default, itest-parallel splits the tests into 4 parts and uses 4 threads to run each of them.

Additional arguments

For both make itest and make itest-parallel, the following arguments are allowed,

  • timeout, specifies the timeout value used in testing.
  • dbbackend, specifies the database backend. Must be bbolt, etcd, or postgres, default to bbolt.
  • backend, specifies the chain backend to be used. Must be one of,
    • btcd, the default value.
    • neutrino
    • bitcoind
    • bitcoind notxindex
    • bitcoind rpcpolling
# Run a single test case using bitcoind as the chain backend and etcd as the
# database backend, with a timeout of 5 minutes.
make itest icase=list_channels backend=bitcoind dbbackend=etcd timeout=5m

# Run all test cases in parallel, using bitcoind notxindex as the chain backend
# and etcd as the database backend, with a timeout of 60 minutes for each
# parallel.
make itest-parallel backend="bitcoind notxindex" dbbackend=etcd timeout=60m