@@ -7799,4 +7799,36 @@ mod tests {
7799
7799
let spend_tx = check_static_output ! ( events, nodes, 0 , 0 , 1 , 1 ) ;
7800
7800
check_spends ! ( spend_tx, node_txn[ 0 ] . clone( ) ) ;
7801
7801
}
7802
+
7803
+ #[ test]
7804
+ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx ( ) {
7805
+ let nodes = create_network ( 2 ) ;
7806
+
7807
+ // Create some initial channels
7808
+ let chan_1 = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
7809
+
7810
+ let payment_preimage = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , 3000000 ) . 0 ;
7811
+ let revoked_local_txn = nodes[ 0 ] . node . channel_state . lock ( ) . unwrap ( ) . by_id . iter ( ) . next ( ) . unwrap ( ) . 1 . last_local_commitment_txn . clone ( ) ;
7812
+ assert_eq ! ( revoked_local_txn[ 0 ] . input. len( ) , 1 ) ;
7813
+ assert_eq ! ( revoked_local_txn[ 0 ] . input[ 0 ] . previous_output. txid, chan_1. 3 . txid( ) ) ;
7814
+
7815
+ claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , payment_preimage) ;
7816
+
7817
+ let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
7818
+ nodes[ 1 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : vec ! [ revoked_local_txn[ 0 ] . clone( ) ] } , 1 ) ;
7819
+ let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
7820
+ match events[ 0 ] {
7821
+ MessageSendEvent :: BroadcastChannelUpdate { .. } => { } ,
7822
+ _ => panic ! ( "Unexpected event" ) ,
7823
+ }
7824
+ let mut node_txn = nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
7825
+ assert_eq ! ( node_txn. len( ) , 3 ) ;
7826
+ assert_eq ! ( node_txn. pop( ) . unwrap( ) , node_txn[ 0 ] ) ;
7827
+ assert_eq ! ( node_txn[ 0 ] . input. len( ) , 2 ) ;
7828
+ check_spends ! ( node_txn[ 0 ] , revoked_local_txn[ 0 ] . clone( ) ) ;
7829
+
7830
+ let events = nodes[ 1 ] . chan_monitor . simple_monitor . get_and_clear_pending_events ( ) ;
7831
+ let spend_tx = check_static_output ! ( events, nodes, 0 , 0 , 1 , 1 ) ;
7832
+ check_spends ! ( spend_tx, node_txn[ 0 ] . clone( ) ) ;
7833
+ }
7802
7834
}
0 commit comments