Skip to content

Commit e487cdd

Browse files
committed
f Require cooperative close on both nodes
Ensure the full-cycle assertion covers both channel parties. Co-Authored-By: HAL 9000
1 parent 3eb2b3b commit e487cdd

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

tests/common/mod.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,28 @@ fn assert_any_node_has_onchain_tx_type<F: Fn(&TransactionType) -> bool + Copy>(
436436
panic!("Expected on-chain payment with tx_type {}; observed {:?}", tx_type_name, observed);
437437
}
438438

439+
fn assert_all_nodes_have_onchain_tx_type<F: Fn(&TransactionType) -> bool + Copy>(
440+
nodes: &[(&str, &TestNode)], tx_type_name: &str, predicate: F,
441+
) {
442+
if nodes.iter().all(|(_, node)| has_onchain_tx_type(node, predicate)) {
443+
return;
444+
}
445+
446+
let observed: Vec<String> = nodes
447+
.iter()
448+
.flat_map(|(name, node)| {
449+
node.list_payments().into_iter().filter_map(move |payment| match payment.kind {
450+
PaymentKind::Onchain { tx_type, .. } => Some(format!("{}:{:?}", name, tx_type)),
451+
_ => None,
452+
})
453+
})
454+
.collect();
455+
panic!(
456+
"Expected all nodes to have on-chain payment with tx_type {}; observed {:?}",
457+
tx_type_name, observed
458+
);
459+
}
460+
439461
async fn settle_force_close_balance<E: ElectrumApi>(
440462
node: &TestNode, counterparty_node_id: PublicKey, peer_node: &TestNode,
441463
bitcoind: &BitcoindClient, electrsd: &E,
@@ -1625,7 +1647,7 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
16251647
|tx_type| matches!(tx_type, TransactionType::Sweep { .. }),
16261648
);
16271649
} else {
1628-
assert_any_node_has_onchain_tx_type(
1650+
assert_all_nodes_have_onchain_tx_type(
16291651
&[("node_a", &node_a), ("node_b", &node_b)],
16301652
"CooperativeClose",
16311653
|tx_type| matches!(tx_type, TransactionType::CooperativeClose { .. }),

0 commit comments

Comments
 (0)