@@ -3584,44 +3584,46 @@ mod tests {
3584
3584
3585
3585
nodes[ 1 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : vec ! [ revoked_local_txn[ 0 ] . clone( ) ] } , 200 ) ;
3586
3586
let node_txn = nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
3587
- assert_eq ! ( node_txn. len( ) , 10 ) ; // ChannelManager : 2, ChannelMontitor: 8 (2 revocation htlc tx, 1 local commitment tx + 1 htlc timeout tx) * 2 (block-rescan)
3587
+ assert_eq ! ( node_txn. len( ) , 12 ) ; // ChannelManager : 2, ChannelMontitor: 8 (1 standard revoked output, 2 revocation htlc tx, 1 local commitment tx + 1 htlc timeout tx) * 2 (block-rescan)
3588
3588
3589
- assert_eq ! ( node_txn[ 0 ] , node_txn[ 6 ] ) ;
3590
- assert_eq ! ( node_txn[ 1 ] , node_txn[ 7 ] ) ;
3591
- assert_eq ! ( node_txn[ 2 ] , node_txn[ 8 ] ) ;
3592
- assert_eq ! ( node_txn[ 3 ] , node_txn[ 9 ] ) ;
3593
- assert_eq ! ( node_txn[ 2 ] , node_txn[ 4 ] ) ; //local commitment tx + htlc timeout tx broadcated by ChannelManger
3594
- assert_eq ! ( node_txn[ 3 ] , node_txn[ 5 ] ) ;
3589
+ assert_eq ! ( node_txn[ 0 ] , node_txn[ 7 ] ) ;
3590
+ assert_eq ! ( node_txn[ 1 ] , node_txn[ 8 ] ) ;
3591
+ assert_eq ! ( node_txn[ 2 ] , node_txn[ 9 ] ) ;
3592
+ assert_eq ! ( node_txn[ 3 ] , node_txn[ 10 ] ) ;
3593
+ assert_eq ! ( node_txn[ 4 ] , node_txn[ 11 ] ) ;
3594
+ assert_eq ! ( node_txn[ 3 ] , node_txn[ 5 ] ) ; //local commitment tx + htlc timeout tx broadcated by ChannelManger
3595
+ assert_eq ! ( node_txn[ 4 ] , node_txn[ 6 ] ) ;
3595
3596
3596
3597
assert_eq ! ( node_txn[ 0 ] . input. len( ) , 1 ) ;
3597
3598
assert_eq ! ( node_txn[ 1 ] . input. len( ) , 1 ) ;
3599
+ assert_eq ! ( node_txn[ 2 ] . input. len( ) , 1 ) ;
3598
3600
3599
3601
let mut revoked_tx_map = HashMap :: new ( ) ;
3600
3602
revoked_tx_map. insert ( revoked_local_txn[ 0 ] . txid ( ) , revoked_local_txn[ 0 ] . clone ( ) ) ;
3601
3603
node_txn[ 0 ] . verify ( & revoked_tx_map) . unwrap ( ) ;
3602
3604
node_txn[ 1 ] . verify ( & revoked_tx_map) . unwrap ( ) ;
3605
+ node_txn[ 2 ] . verify ( & revoked_tx_map) . unwrap ( ) ;
3603
3606
3604
- let witness_script_1 = node_txn[ 0 ] . clone ( ) . input [ 0 ] . witness . pop ( ) . unwrap ( ) ;
3605
- let witness_script_2 = node_txn[ 1 ] . clone ( ) . input [ 0 ] . witness . pop ( ) . unwrap ( ) ;
3606
- if witness_script_1. len ( ) > 133 {
3607
- assert_eq ! ( witness_script_1. len( ) , 138 ) ;
3608
- assert_eq ! ( witness_script_2. len( ) , 133 ) ;
3609
- } else {
3610
- assert_eq ! ( witness_script_1. len( ) , 133 ) ;
3611
- assert_eq ! ( witness_script_2. len( ) , 138 ) ;
3612
- }
3607
+ let mut witness_lens = BTreeSet :: new ( ) ;
3608
+ witness_lens. insert ( node_txn[ 0 ] . input [ 0 ] . witness . clone ( ) . pop ( ) . unwrap ( ) . len ( ) ) ;
3609
+ witness_lens. insert ( node_txn[ 1 ] . input [ 0 ] . witness . clone ( ) . pop ( ) . unwrap ( ) . len ( ) ) ;
3610
+ witness_lens. insert ( node_txn[ 2 ] . input [ 0 ] . witness . clone ( ) . pop ( ) . unwrap ( ) . len ( ) ) ;
3611
+ assert_eq ! ( witness_lens. len( ) , 3 ) ;
3612
+ assert_eq ! ( * witness_lens. iter( ) . skip( 0 ) . next( ) . unwrap( ) , 77 ) ; // revoked to_local
3613
+ assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , 133 ) ; // revoked offered HTLC
3614
+ assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , 138 ) ; // revoked received HTLC
3613
3615
3614
3616
let mut funding_tx_map = HashMap :: new ( ) ;
3615
3617
funding_tx_map. insert ( chan_1. 3 . txid ( ) , chan_1. 3 . clone ( ) ) ;
3616
- node_txn[ 2 ] . verify ( & funding_tx_map) . unwrap ( ) ;
3617
- assert_eq ! ( node_txn[ 2 ] . input. len( ) , 1 ) ;
3618
-
3618
+ node_txn[ 3 ] . verify ( & funding_tx_map) . unwrap ( ) ;
3619
3619
assert_eq ! ( node_txn[ 3 ] . input. len( ) , 1 ) ;
3620
- let witness_script = node_txn[ 3 ] . clone ( ) . input [ 0 ] . witness . pop ( ) . unwrap ( ) ;
3620
+
3621
+ assert_eq ! ( node_txn[ 4 ] . input. len( ) , 1 ) ;
3622
+ let witness_script = node_txn[ 4 ] . input [ 0 ] . witness . clone ( ) . pop ( ) . unwrap ( ) ;
3621
3623
assert_eq ! ( witness_script. len( ) , 133 ) ; //Spending an offered htlc output
3622
- assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . previous_output. txid, node_txn[ 2 ] . txid( ) ) ;
3623
- assert_ne ! ( node_txn[ 3 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 0 ] . previous_output. txid) ;
3624
- assert_ne ! ( node_txn[ 3 ] . input[ 0 ] . previous_output. txid, node_txn[ 1 ] . input[ 0 ] . previous_output. txid) ;
3624
+ assert_eq ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 3 ] . txid( ) ) ;
3625
+ assert_ne ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 0 ] . previous_output. txid) ;
3626
+ assert_ne ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 1 ] . input[ 0 ] . previous_output. txid) ;
3625
3627
}
3626
3628
get_announce_close_broadcast_events ( & nodes, 0 , 1 ) ;
3627
3629
assert_eq ! ( nodes[ 0 ] . node. list_channels( ) . len( ) , 0 ) ;
0 commit comments