Skip to content

Commit 69cef7b

Browse files
author
Antoine Riard
committed
Add test_claim_on_remote_revoked_sizeable_push_msat
1 parent 7687e02 commit 69cef7b

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/ln/channelmanager.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7637,7 +7637,7 @@ mod tests {
76377637
}
76387638

76397639
macro_rules! check_dynamic_output_p2wpkh {
7640-
($node: expr) => {
7640+
($node: expr, $expected: expr) => {
76417641
{
76427642
let events = $node.chan_monitor.simple_monitor.get_and_clear_pending_events();
76437643
let mut txn = Vec::new();
@@ -7673,7 +7673,7 @@ mod tests {
76737673
spend_tx.input[0].witness.push(remotepubkey.serialize().to_vec());
76747674
txn.push(spend_tx);
76757675
},
7676-
_ => panic!("Unexpected event"),
7676+
_ => { if $expected == true {} else { panic!("Unexpected event")}},
76777677
}
76787678
}
76797679
},
@@ -7786,12 +7786,39 @@ mod tests {
77867786
MessageSendEvent::BroadcastChannelUpdate { .. } => {},
77877787
_ => panic!("Unexpected event"),
77887788
}
7789-
let spend_txn = check_dynamic_output_p2wpkh!(nodes[1]);
7789+
let spend_txn = check_dynamic_output_p2wpkh!(nodes[1], false);
77907790
assert_eq!(spend_txn.len(), 2);
77917791
assert_eq!(spend_txn[0], spend_txn[1]);
77927792
check_spends!(spend_txn[0], node_txn[0].clone());
77937793
}
77947794

7795+
#[test]
7796+
fn test_claim_on_remote_revoked_sizeable_push_msat() {
7797+
// Same test as precedent, just test on remote revoked commitment tx, as per_commitment_point registration changes following you're funder/fundee and
7798+
// to_remote output is encumbered by a P2WPKH
7799+
7800+
let nodes = create_network(2);
7801+
7802+
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 59000000);
7803+
let payment_preimage = route_payment(&nodes[0], &vec!(&nodes[1])[..], 3000000).0;
7804+
let revoked_local_txn = nodes[0].node.channel_state.lock().unwrap().by_id.get(&chan.2).unwrap().last_local_commitment_txn.clone();
7805+
assert_eq!(revoked_local_txn[0].input.len(), 1);
7806+
assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan.3.txid());
7807+
7808+
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage);
7809+
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
7810+
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
7811+
let events = nodes[1].node.get_and_clear_pending_msg_events();
7812+
match events[0] {
7813+
MessageSendEvent::BroadcastChannelUpdate { .. } => {},
7814+
_ => panic!("Unexpected event"),
7815+
}
7816+
let spend_txn = check_dynamic_output_p2wpkh!(nodes[1], true);
7817+
assert_eq!(spend_txn.len(), 2);
7818+
assert_eq!(spend_txn[0], spend_txn[1]);
7819+
check_spends!(spend_txn[0], revoked_local_txn[0].clone());
7820+
}
7821+
77957822
#[test]
77967823
fn test_static_spendable_outputs_preimage_tx() {
77977824
let nodes = create_network(2);

0 commit comments

Comments
 (0)