Skip to content

Commit 62bf391

Browse files
committed
Add Eclair interop test for zero-fee-commitments
Co-Authored-By: HAL 9000
1 parent 10b3030 commit 62bf391

3 files changed

Lines changed: 71 additions & 3 deletions

File tree

.github/workflows/0fc-integration.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,54 @@ jobs:
4747
- name: Test with 0FC enabled
4848
run: |
4949
RUSTFLAGS="--cfg no_download --cfg cycle_tests --cfg tokio_unstable --cfg zero_fee_commitment_tests" cargo test -- --test-threads=1
50+
eclair-interop-test:
51+
timeout-minutes: 60
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
57+
- name: Start bitcoind and electrs
58+
run: docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml up -d bitcoin electrs
59+
60+
- name: Wait for bitcoind to be healthy
61+
run: |
62+
for i in $(seq 1 30); do
63+
if docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass getblockchaininfo > /dev/null 2>&1; then
64+
echo "bitcoind is ready"
65+
exit 0
66+
fi
67+
echo "Waiting for bitcoind... ($i/30)"
68+
sleep 2
69+
done
70+
echo "ERROR: bitcoind not ready"
71+
exit 1
72+
73+
- name: Create wallets on bitcoind
74+
run: |
75+
docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass createwallet eclair
76+
docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass -rpcwallet=eclair getnewaddress
77+
docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass createwallet ldk_node_test
78+
79+
- name: Start Eclair with 0FC enabled
80+
env:
81+
ECLAIR_EXTRA_JAVA_OPTS: "-Declair.features.zero_fee_commitments=optional"
82+
run: docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml up -d eclair
83+
84+
- name: Wait for Eclair to be ready
85+
run: |
86+
for i in $(seq 1 60); do
87+
if curl -sf -u :eclairpassword -X POST http://127.0.0.1:8080/getinfo > /dev/null 2>&1; then
88+
echo "Eclair is ready"
89+
exit 0
90+
fi
91+
echo "Waiting for Eclair... ($i/60)"
92+
sleep 5
93+
done
94+
echo "Eclair failed to start"
95+
docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml logs eclair
96+
exit 1
97+
98+
- name: Run Eclair 0FC integration tests
99+
run: |
100+
RUSTFLAGS="--cfg eclair_test --cfg zero_fee_commitment_tests" cargo test --test integration_tests_eclair -- --show-output --test-threads=1

tests/common/scenarios/mod.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use std::time::Duration;
2020
use bitcoin::Amount;
2121
use electrsd::corepc_node::Client as BitcoindClient;
2222
use electrsd::electrum_client::ElectrumApi;
23+
#[cfg(zero_fee_commitment_tests)]
24+
use ldk_node::ReserveType;
2325
use ldk_node::{Event, Node};
2426

2527
use super::external_node::ExternalNode;
@@ -87,15 +89,15 @@ pub(crate) async fn wait_for_htlcs_settled(
8789
panic!("HTLCs did not settle on {} channel {} within 15s", peer.name(), ext_channel_id);
8890
}
8991

90-
/// Build a fresh LDK node configured for interop tests. Uses electrum at the
92+
/// Build a fresh LDK node configured for interop tests. Uses esplora at the
9193
/// docker-compose default port and bumps sync timeouts for combo stress.
9294
pub(crate) fn setup_ldk_node() -> Node {
9395
let config = crate::common::random_config();
9496
let mut builder = ldk_node::Builder::from_config(config.node_config);
95-
let mut sync_config = ldk_node::config::ElectrumSyncConfig::default();
97+
let mut sync_config = ldk_node::config::EsploraSyncConfig::default();
9698
sync_config.timeouts_config.onchain_wallet_sync_timeout_secs = 180;
9799
sync_config.timeouts_config.lightning_wallet_sync_timeout_secs = 120;
98-
builder.set_chain_source_electrum("tcp://127.0.0.1:50001".to_string(), Some(sync_config));
100+
builder.set_chain_source_esplora("http://127.0.0.1:3002".to_string(), Some(sync_config));
99101
let node = builder.build(config.node_entropy).unwrap();
100102
node.start().unwrap();
101103
node
@@ -164,6 +166,20 @@ pub(crate) async fn basic_channel_cycle_scenario<E: ElectrumApi>(
164166
)
165167
.await;
166168

169+
#[cfg(zero_fee_commitment_tests)]
170+
{
171+
let ext_node_id = peer.get_node_id().await.unwrap();
172+
let channel = node
173+
.list_channels()
174+
.into_iter()
175+
.find(|channel| channel.user_channel_id == user_ch)
176+
.expect("opened channel should be listed");
177+
assert_eq!(channel.counterparty.node_id, ext_node_id);
178+
assert!(channel.counterparty.features.supports_anchor_zero_fee_commitments());
179+
assert_eq!(channel.feerate_sat_per_1000_weight, 0);
180+
assert_eq!(channel.reserve_type, Some(ReserveType::Adaptive));
181+
}
182+
167183
payment::send_bolt11_to_peer(node, peer, 10_000_000, "basic-send").await;
168184
payment::receive_bolt11_payment(node, peer, 10_000_000).await;
169185

tests/docker/docker-compose-eclair.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,5 @@ services:
7777
-Declair.bitcoind.zmqtx=tcp://127.0.0.1:28333
7878
-Declair.features.keysend=optional
7979
-Declair.on-chain-fees.confirmation-priority.funding=slow
80+
${ECLAIR_EXTRA_JAVA_OPTS:-}
8081
-Declair.printToConsole

0 commit comments

Comments
 (0)