Skip to content

Commit 516f8cb

Browse files
authored
Merge pull request #1046 from tnull/2026-08-fix-splice-ready-race
Wait for splice broadcasts before mining
2 parents 49bc676 + 1a6bc72 commit 516f8cb

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

tests/common/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,8 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
15391539
assert!(splice_out_sat > 500_000);
15401540
node_b.splice_out(&user_channel_id_b, node_a.node_id(), &addr_a, splice_out_sat).unwrap();
15411541

1542-
expect_splice_negotiated_event!(node_b, node_a.node_id());
1542+
let splice_out_txo = expect_splice_negotiated_event!(node_b, node_a.node_id());
1543+
wait_for_tx(electrsd, splice_out_txo.txid).await;
15431544

15441545
generate_blocks_and_wait(&bitcoind, electrsd, 6).await;
15451546
node_a.sync_wallets().unwrap();
@@ -1560,7 +1561,8 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
15601561
let splice_in_sat = splice_out_sat;
15611562
node_a.splice_in(&user_channel_id_a, node_b.node_id(), splice_in_sat).unwrap();
15621563

1563-
expect_splice_negotiated_event!(node_a, node_b.node_id());
1564+
let splice_in_txo = expect_splice_negotiated_event!(node_a, node_b.node_id());
1565+
wait_for_tx(electrsd, splice_in_txo.txid).await;
15641566

15651567
generate_blocks_and_wait(&bitcoind, electrsd, 6).await;
15661568
node_a.sync_wallets().unwrap();

tests/common/scenarios/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use electrsd::electrum_client::ElectrumApi;
2323
use ldk_node::{Event, Node};
2424

2525
use super::external_node::ExternalNode;
26-
use super::{generate_blocks_and_wait, premine_and_distribute_funds};
26+
use super::{generate_blocks_and_wait, premine_and_distribute_funds, wait_for_tx};
2727

2828
#[derive(Debug, Clone, Copy)]
2929
pub(crate) enum Side {
@@ -240,7 +240,8 @@ pub(crate) async fn splice_in_scenario<E: ElectrumApi>(
240240
.await;
241241
let ext_node_id = peer.get_node_id().await.unwrap();
242242
node.splice_in(&user_ch, ext_node_id, 500_000).unwrap();
243-
expect_splice_negotiated_event!(node, ext_node_id);
243+
let splice_txo = expect_splice_negotiated_event!(node, ext_node_id);
244+
wait_for_tx(electrs, splice_txo.txid).await;
244245
generate_blocks_and_wait(bitcoind, electrs, 6).await;
245246
sync_wallets_with_retry(node).await;
246247
expect_channel_ready_event!(node, ext_node_id);

tests/integration_tests_rust.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,7 @@ async fn splice_channel() {
20432043
// Node B contributed to this splice, so wait for its funding broadcast to be classified before
20442044
// syncing — otherwise a sync racing the broadcaster's queue records a generic on-chain payment.
20452045
wait_for_classified_funding_payment(&node_b, txo.txid).await;
2046+
wait_for_tx(&electrsd.client, txo.txid).await;
20462047

20472048
generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await;
20482049

@@ -2102,6 +2103,7 @@ async fn splice_channel() {
21022103
// Node A contributed to this splice, so wait for its funding broadcast to be classified before
21032104
// syncing — otherwise a sync racing the broadcaster's queue records a generic on-chain payment.
21042105
wait_for_classified_funding_payment(&node_a, txo.txid).await;
2106+
wait_for_tx(&electrsd.client, txo.txid).await;
21052107

21062108
generate_blocks_and_wait(&bitcoind.client, &electrsd.client, 6).await;
21072109

0 commit comments

Comments
 (0)