Skip to content

Commit 72c450e

Browse files
benthecarmanclaude
andcommitted
Fund LSP and third_party in one mining round
build_test_nodes was funding the LSP, mining 6 blocks, then funding the third-party node and mining another 6. The two fundings are independent — broadcast both txs first and confirm with one batch of 6 blocks. Drops one 6-block confirmation wait (~10s on this machine) per integration test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 56eafa8 commit 72c450e

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

orange-sdk/tests/test_utils.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,20 @@ fn create_third_party(uuid: Uuid, bitcoind: &Bitcoind) -> Arc<Node> {
243243
ldk_node
244244
}
245245

246-
async fn fund_node(node: &Node, bitcoind: &Bitcoind, electrsd: &ElectrsD) {
247-
let addr = node.onchain_payment().new_address().unwrap();
248-
let res =
249-
bitcoind.client.send_to_address(&addr, bitcoin::Amount::from_btc(1.0).unwrap()).unwrap();
250-
wait_for_tx(&electrsd.client, res.txid().unwrap()).await;
246+
/// Funds two nodes in one round so the 6-block confirmation only happens once.
247+
async fn fund_two_nodes(a: &Node, b: &Node, bitcoind: &Bitcoind, electrsd: &ElectrsD) {
248+
let addr_a = a.onchain_payment().new_address().unwrap();
249+
let addr_b = b.onchain_payment().new_address().unwrap();
250+
251+
let one_btc = bitcoin::Amount::from_btc(1.0).unwrap();
252+
let tx_a = bitcoind.client.send_to_address(&addr_a, one_btc).unwrap();
253+
let tx_b = bitcoind.client.send_to_address(&addr_b, one_btc).unwrap();
254+
255+
tokio::join!(
256+
wait_for_tx(&electrsd.client, tx_a.txid().unwrap()),
257+
wait_for_tx(&electrsd.client, tx_b.txid().unwrap()),
258+
);
259+
251260
generate_blocks(bitcoind, electrsd, 6).await;
252261
}
253262

@@ -301,10 +310,9 @@ async fn build_test_nodes() -> TestParams {
301310
let (bitcoind, electrsd) = create_bitcoind(test_id).await;
302311

303312
let lsp = create_lsp(test_id, &bitcoind);
304-
fund_node(&lsp, &bitcoind, &electrsd).await;
305313
let third_party = create_third_party(test_id, &bitcoind);
306314
let start_bal = third_party.list_balances().total_onchain_balance_sats;
307-
fund_node(&third_party, &bitcoind, &electrsd).await;
315+
fund_two_nodes(&lsp, &third_party, &bitcoind, &electrsd).await;
308316

309317
// wait for node to sync (needs blocking wait as we are not in async context here)
310318
let third = Arc::clone(&third_party);

0 commit comments

Comments
 (0)