Skip to content

Commit 477a5d2

Browse files
committed
feat(test): add interop test harness for CLN, LND, Eclair
Add a shared interop test framework with: - ExternalNode trait abstracting CLN, LND, and Eclair - Reusable scenario functions (channel lifecycle, payments, disconnect, splice, combo orchestrator with 16 disconnect×payment×close permutations) - Docker Compose and CI workflows for all three implementations - Single-function test pattern matching the original test_cln structure
1 parent eef5142 commit 477a5d2

23 files changed

Lines changed: 2880 additions & 333 deletions

.github/workflows/cln-integration.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,37 @@ jobs:
1616
- name: Install dependencies
1717
run: |
1818
sudo apt-get update -y
19-
sudo apt-get install -y socat
19+
sudo apt-get install -y socat jq
2020
2121
- name: Start bitcoind, electrs, and lightningd
2222
run: docker compose -p ldk-node -f tests/docker/docker-compose-cln.yml up -d
2323

24-
- name: Forward lightningd RPC socket
24+
- name: Wait for CLN and forward RPC socket
2525
run: |
26+
# Wait for CLN RPC socket to exist
27+
for i in $(seq 1 30); do
28+
if docker exec ldk-node-cln-1 test -S /root/.lightning/regtest/lightning-rpc 2>/dev/null; then
29+
echo "CLN RPC socket ready"
30+
break
31+
fi
32+
echo "Waiting for CLN RPC socket... ($i/30)"
33+
sleep 2
34+
done
35+
# Start socat forwarding
2636
docker exec ldk-node-cln-1 sh -c "socat -d -d TCP-LISTEN:9937,fork,reuseaddr UNIX-CONNECT:/root/.lightning/regtest/lightning-rpc&"
2737
socat -d -d UNIX-LISTEN:/tmp/lightning-rpc,reuseaddr,fork TCP:127.0.0.1:9937&
38+
sleep 1
39+
# Verify CLN actually responds to RPC
40+
for i in $(seq 1 15); do
41+
if echo '{"jsonrpc":"2.0","method":"getinfo","params":[],"id":1}' | socat - UNIX-CONNECT:/tmp/lightning-rpc 2>/dev/null | jq -e .result > /dev/null 2>&1; then
42+
echo "CLN RPC responding"
43+
exit 0
44+
fi
45+
echo "Waiting for CLN RPC response... ($i/15)"
46+
sleep 2
47+
done
48+
echo "ERROR: CLN RPC not responding"
49+
exit 1
2850
2951
- name: Run CLN integration tests
30-
run: RUSTFLAGS="--cfg cln_test" cargo test --test integration_tests_cln
52+
run: RUSTFLAGS="--cfg cln_test" cargo test --test integration_tests_cln -- --show-output --test-threads=1
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI Checks - Eclair Integration Tests
2+
3+
on: [push, pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
check-eclair:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Start bitcoind and electrs
17+
run: docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml up -d bitcoin electrs
18+
19+
- name: Wait for bitcoind to be healthy
20+
run: |
21+
for i in $(seq 1 30); do
22+
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
23+
echo "bitcoind is ready"
24+
exit 0
25+
fi
26+
echo "Waiting for bitcoind... ($i/30)"
27+
sleep 2
28+
done
29+
echo "ERROR: bitcoind not ready"
30+
exit 1
31+
32+
- name: Create wallets on bitcoind
33+
run: |
34+
docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass createwallet eclair
35+
docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml exec bitcoin bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass -rpcwallet=eclair getnewaddress
36+
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
37+
38+
- name: Start Eclair
39+
run: docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml up -d eclair
40+
41+
- name: Wait for Eclair to be ready
42+
run: |
43+
for i in $(seq 1 60); do
44+
if curl -sf -u :eclairpassword -X POST http://127.0.0.1:8080/getinfo > /dev/null 2>&1; then
45+
echo "Eclair is ready"
46+
exit 0
47+
fi
48+
echo "Waiting for Eclair... ($i/60)"
49+
sleep 5
50+
done
51+
echo "Eclair failed to start"
52+
docker compose -p ldk-node -f tests/docker/docker-compose-eclair.yml logs eclair
53+
exit 1
54+
55+
- name: Run Eclair integration tests
56+
run: RUSTFLAGS="--cfg eclair_test" cargo test --test integration_tests_eclair -- --show-output --test-threads=1

.github/workflows/lnd-integration.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,29 @@ jobs:
3333
fi
3434
3535
- name: Create temporary directory for LND data
36-
id: create-temp-dir
3736
run: echo "LND_DATA_DIR=$(mktemp -d)" >> $GITHUB_ENV
3837

3938
- name: Start bitcoind, electrs, and LND
4039
run: docker compose -p ldk-node -f tests/docker/docker-compose-lnd.yml up -d
4140
env:
4241
LND_DATA_DIR: ${{ env.LND_DATA_DIR }}
4342

44-
- name: Set permissions for LND data directory
45-
# In PR 4622 (https://github.com/lightningnetwork/lnd/pull/4622),
46-
# LND sets file permissions to 0700, preventing test code from accessing them.
47-
# This step ensures the test suite has the necessary permissions.
48-
run: sudo chmod -R 755 $LND_DATA_DIR
43+
- name: Wait for LND macaroon and set permissions
44+
run: |
45+
for i in $(seq 1 30); do
46+
if docker exec ldk-node-lnd test -f /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon 2>/dev/null; then
47+
echo "LND macaroon found"
48+
break
49+
fi
50+
echo "Waiting for LND macaroon... ($i/30)"
51+
sleep 2
52+
done
53+
sudo chmod -R 755 $LND_DATA_DIR
4954
env:
5055
LND_DATA_DIR: ${{ env.LND_DATA_DIR }}
5156

5257
- name: Run LND integration tests
5358
run: LND_CERT_PATH=$LND_DATA_DIR/tls.cert LND_MACAROON_PATH=$LND_DATA_DIR/data/chain/bitcoin/regtest/admin.macaroon
54-
RUSTFLAGS="--cfg lnd_test" cargo test --test integration_tests_lnd -- --exact --show-output
59+
RUSTFLAGS="--cfg lnd_test" cargo test --test integration_tests_lnd -- --show-output --test-threads=1
5560
env:
5661
LND_DATA_DIR: ${{ env.LND_DATA_DIR }}

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ check-cfg = [
125125
"cfg(tokio_unstable)",
126126
"cfg(cln_test)",
127127
"cfg(lnd_test)",
128+
"cfg(eclair_test)",
128129
"cfg(cycle_tests)",
129130
]
130131

0 commit comments

Comments
 (0)