Skip to content

Commit 08162bf

Browse files
author
Antoine Riard
committed
Add test_claim_on_remote_sizeable_push_msat
Contrary to sizeable push_msat on local commitment tx, the output go to a P2WPKH
1 parent 36518b7 commit 08162bf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/ln/channelmanager.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7728,6 +7728,38 @@ mod tests {
77287728
check_spends!(spend_txn[0], node_txn[0].clone());
77297729
}
77307730

7731+
#[test]
7732+
fn test_claim_on_remote_sizeable_push_msat() {
7733+
// Same test as precedent, just test on remote commitment tx, as per_commitment_point registration changes following you're funder/fundee and
7734+
// to_remote output is encumbered by a P2WPKH
7735+
7736+
let nodes = create_network(2);
7737+
7738+
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 99000000);
7739+
nodes[0].node.force_close_channel(&chan.2);
7740+
let events = nodes[0].node.get_and_clear_pending_msg_events();
7741+
match events[0] {
7742+
MessageSendEvent::BroadcastChannelUpdate { .. } => {},
7743+
_ => panic!("Unexpected event"),
7744+
}
7745+
let node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
7746+
assert_eq!(node_txn.len(), 1);
7747+
check_spends!(node_txn[0], chan.3.clone());
7748+
assert_eq!(node_txn[0].output.len(), 2); // We can't force trimming of to_remote output as channel_reserve_satoshis block us to do so at channel opening
7749+
7750+
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
7751+
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![node_txn[0].clone()] }, 0);
7752+
let events = nodes[1].node.get_and_clear_pending_msg_events();
7753+
match events[0] {
7754+
MessageSendEvent::BroadcastChannelUpdate { .. } => {},
7755+
_ => panic!("Unexpected event"),
7756+
}
7757+
let spend_txn = check_dynamic_output!(nodes[1]);
7758+
assert_eq!(spend_txn.len(), 2);
7759+
assert_eq!(spend_txn[0], spend_txn[1]);
7760+
check_spends!(spend_txn[0], node_txn[0].clone());
7761+
}
7762+
77317763
#[test]
77327764
fn test_static_spendable_outputs_preimage_tx() {
77337765
let nodes = create_network(2);

0 commit comments

Comments
 (0)