Skip to content

Commit ab9a98f

Browse files
Antoine RiardTheBlueMatt
authored andcommitted
Add test_claim_on_remote_revoked_sizeable_push_msat
1 parent 546bd37 commit ab9a98f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/ln/channelmanager.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7756,6 +7756,36 @@ mod tests {
77567756
check_spends!(spend_txn[0], node_txn[0].clone());
77577757
}
77587758

7759+
#[test]
7760+
fn test_claim_on_remote_revoked_sizeable_push_msat() {
7761+
// Same test as previous, just test on remote revoked commitment tx, as per_commitment_point registration changes following you're funder/fundee and
7762+
// to_remote output is encumbered by a P2WPKH
7763+
7764+
let nodes = create_network(2);
7765+
7766+
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 59000000);
7767+
let payment_preimage = route_payment(&nodes[0], &vec!(&nodes[1])[..], 3000000).0;
7768+
let revoked_local_txn = nodes[0].node.channel_state.lock().unwrap().by_id.get(&chan.2).unwrap().last_local_commitment_txn.clone();
7769+
assert_eq!(revoked_local_txn[0].input.len(), 1);
7770+
assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan.3.txid());
7771+
7772+
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage);
7773+
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
7774+
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
7775+
let events = nodes[1].node.get_and_clear_pending_msg_events();
7776+
match events[0] {
7777+
MessageSendEvent::BroadcastChannelUpdate { .. } => {},
7778+
_ => panic!("Unexpected event"),
7779+
}
7780+
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
7781+
let spend_txn = check_spendable_outputs!(nodes[1], 1);
7782+
assert_eq!(spend_txn.len(), 4);
7783+
assert_eq!(spend_txn[0], spend_txn[2]); // to_remote output on revoked remote commitment_tx
7784+
check_spends!(spend_txn[0], revoked_local_txn[0].clone());
7785+
assert_eq!(spend_txn[1], spend_txn[3]); // to_local output on local commitment tx
7786+
check_spends!(spend_txn[1], node_txn[0].clone());
7787+
}
7788+
77597789
#[test]
77607790
fn test_static_spendable_outputs_preimage_tx() {
77617791
let nodes = create_network(2);

0 commit comments

Comments
 (0)