]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add test_claim_on_remote_sizeable_push_msat
authorAntoine Riard <ariard@student.42.fr>
Mon, 5 Nov 2018 01:31:49 +0000 (01:31 +0000)
committerAntoine Riard <ariard@student.42.fr>
Tue, 20 Nov 2018 01:42:52 +0000 (20:42 -0500)
Contrary to sizeable push_msat on local
commitment tx, the output go to a P2WPKH

src/ln/channelmanager.rs

index ee689d53205fbb2821218241a303298de8e58e03..916399023cdeeaf99e2a69557720979a453b84a0 100644 (file)
@@ -7710,6 +7710,38 @@ mod tests {
                check_spends!(spend_txn[0], node_txn[0].clone());
        }
 
+       #[test]
+       fn test_claim_on_remote_sizeable_push_msat() {
+               // Same test as precedent, just test on remote commitment tx, as per_commitment_point registration changes following you're funder/fundee and
+               // to_remote output is encumbered by a P2WPKH
+
+               let nodes = create_network(2);
+
+               let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 99000000);
+               nodes[0].node.force_close_channel(&chan.2);
+               let events = nodes[0].node.get_and_clear_pending_msg_events();
+               match events[0] {
+                       MessageSendEvent::BroadcastChannelUpdate { .. } => {},
+                       _ => panic!("Unexpected event"),
+               }
+               let node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
+               assert_eq!(node_txn.len(), 1);
+               check_spends!(node_txn[0], chan.3.clone());
+               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
+
+               let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
+               nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![node_txn[0].clone()] }, 0);
+               let events = nodes[1].node.get_and_clear_pending_msg_events();
+               match events[0] {
+                       MessageSendEvent::BroadcastChannelUpdate { .. } => {},
+                       _ => panic!("Unexpected event"),
+               }
+               let spend_txn = check_dynamic_output_p2wpkh!(nodes[1]);
+               assert_eq!(spend_txn.len(), 2);
+               assert_eq!(spend_txn[0], spend_txn[1]);
+               check_spends!(spend_txn[0], node_txn[0].clone());
+       }
+
        #[test]
        fn test_static_spendable_outputs_preimage_tx() {
                let nodes = create_network(2);