@@ -3251,6 +3251,7 @@ mod tests {
3251
3251
use chain:: keysinterface;
3252
3252
use ln:: channelmanager:: { ChannelManager , ChannelManagerReadArgs , OnionKeys , PaymentFailReason , RAACommitmentOrder } ;
3253
3253
use ln:: channelmonitor:: { ChannelMonitor , ChannelMonitorUpdateErr , CLTV_CLAIM_BUFFER , HTLC_FAIL_TIMEOUT_BLOCKS , ManyChannelMonitor } ;
3254
+ use ln:: channel:: { ACCEPTED_HTLC_SCRIPT_WEIGHT , OFFERED_HTLC_SCRIPT_WEIGHT } ;
3254
3255
use ln:: router:: { Route , RouteHop , Router } ;
3255
3256
use ln:: msgs;
3256
3257
use ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler } ;
@@ -5763,7 +5764,7 @@ mod tests {
5763
5764
assert_eq ! ( revoked_local_txn[ 0 ] . output. len( ) , 2 ) ; // Only HTLC and output back to 0 are present
5764
5765
assert_eq ! ( revoked_local_txn[ 1 ] . input. len( ) , 1 ) ;
5765
5766
assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . previous_output. txid, revoked_local_txn[ 0 ] . txid( ) ) ;
5766
- assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ; // HTLC-Timeout
5767
+ assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // HTLC-Timeout
5767
5768
// Revoke the old state
5768
5769
claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , payment_preimage_3) ;
5769
5770
@@ -5882,7 +5883,7 @@ mod tests {
5882
5883
assert_eq ! ( revoked_local_txn[ 0 ] . input[ 0 ] . previous_output. txid, chan_1. 3 . txid( ) ) ;
5883
5884
assert_eq ! ( revoked_local_txn[ 1 ] . input. len( ) , 1 ) ;
5884
5885
assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . previous_output. txid, revoked_local_txn[ 0 ] . txid( ) ) ;
5885
- assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ; // HTLC-Timeout
5886
+ assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // HTLC-Timeout
5886
5887
check_spends ! ( revoked_local_txn[ 1 ] , revoked_local_txn[ 0 ] . clone( ) ) ;
5887
5888
5888
5889
//Revoke the old state
@@ -5908,16 +5909,16 @@ mod tests {
5908
5909
witness_lens. insert ( node_txn[ 0 ] . input [ 2 ] . witness . last ( ) . unwrap ( ) . len ( ) ) ;
5909
5910
assert_eq ! ( witness_lens. len( ) , 3 ) ;
5910
5911
assert_eq ! ( * witness_lens. iter( ) . skip( 0 ) . next( ) . unwrap( ) , 77 ) ; // revoked to_local
5911
- assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , 133 ) ; // revoked offered HTLC
5912
- assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , 138 ) ; // revoked received HTLC
5912
+ assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // revoked offered HTLC
5913
+ assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ; // revoked received HTLC
5913
5914
5914
5915
// Next nodes[1] broadcasts its current local tx state:
5915
5916
assert_eq ! ( node_txn[ 1 ] . input. len( ) , 1 ) ;
5916
5917
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . previous_output. txid, chan_1. 3 . txid( ) ) ; //Spending funding tx unique txouput, tx broadcasted by ChannelManager
5917
5918
5918
5919
assert_eq ! ( node_txn[ 2 ] . input. len( ) , 1 ) ;
5919
5920
let witness_script = node_txn[ 2 ] . clone ( ) . input [ 0 ] . witness . pop ( ) . unwrap ( ) ;
5920
- assert_eq ! ( witness_script. len( ) , 133 ) ; //Spending an offered htlc output
5921
+ assert_eq ! ( witness_script. len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; //Spending an offered htlc output
5921
5922
assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 1 ] . txid( ) ) ;
5922
5923
assert_ne ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 0 ] . previous_output. txid) ;
5923
5924
assert_ne ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 1 ] . previous_output. txid) ;
@@ -5980,15 +5981,15 @@ mod tests {
5980
5981
witness_lens. insert ( node_txn[ 2 ] . input [ 0 ] . witness . last ( ) . unwrap ( ) . len ( ) ) ;
5981
5982
assert_eq ! ( witness_lens. len( ) , 3 ) ;
5982
5983
assert_eq ! ( * witness_lens. iter( ) . skip( 0 ) . next( ) . unwrap( ) , 77 ) ; // revoked to_local
5983
- assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , 133 ) ; // revoked offered HTLC
5984
- assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , 138 ) ; // revoked received HTLC
5984
+ assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // revoked offered HTLC
5985
+ assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ; // revoked received HTLC
5985
5986
5986
5987
assert_eq ! ( node_txn[ 3 ] . input. len( ) , 1 ) ;
5987
5988
check_spends ! ( node_txn[ 3 ] , chan_1. 3 . clone( ) ) ;
5988
5989
5989
5990
assert_eq ! ( node_txn[ 4 ] . input. len( ) , 1 ) ;
5990
5991
let witness_script = node_txn[ 4 ] . input [ 0 ] . witness . last ( ) . unwrap ( ) ;
5991
- assert_eq ! ( witness_script. len( ) , 133 ) ; //Spending an offered htlc output
5992
+ assert_eq ! ( witness_script. len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; //Spending an offered htlc output
5992
5993
assert_eq ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 3 ] . txid( ) ) ;
5993
5994
assert_ne ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 0 ] . previous_output. txid) ;
5994
5995
assert_ne ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 1 ] . input[ 0 ] . previous_output. txid) ;
@@ -6053,11 +6054,11 @@ mod tests {
6053
6054
let node_txn = nodes[ 2 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) . clone ( ) ; // ChannelManager : 2 (commitment tx, HTLC-Success tx), ChannelMonitor : 1 (HTLC-Success tx)
6054
6055
assert_eq ! ( node_txn. len( ) , 3 ) ;
6055
6056
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
6056
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
6057
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
6057
6058
check_spends ! ( node_txn[ 1 ] , chan_2. 3 . clone( ) ) ;
6058
6059
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
6059
6060
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
6060
- assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
6061
+ assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
6061
6062
6062
6063
// Verify that B's ChannelManager is able to extract preimage from HTLC Success tx and pass it backward
6063
6064
nodes[ 1 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : node_txn} , 1 ) ;
@@ -6088,12 +6089,12 @@ mod tests {
6088
6089
assert_eq ! ( node_txn[ 0 ] , node_txn[ 3 ] ) ;
6089
6090
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
6090
6091
check_spends ! ( node_txn[ 3 ] , commitment_tx[ 0 ] . clone( ) ) ;
6091
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
6092
- assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
6092
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
6093
+ assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
6093
6094
check_spends ! ( node_txn[ 1 ] , chan_2. 3 . clone( ) ) ;
6094
6095
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
6095
6096
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
6096
- assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
6097
+ assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
6097
6098
node_txn. clear ( )
6098
6099
}
6099
6100
@@ -6112,9 +6113,9 @@ mod tests {
6112
6113
assert_eq ! ( node_txn. len( ) , 3 ) ;
6113
6114
assert_eq ! ( node_txn[ 0 ] , node_txn[ 2 ] ) ;
6114
6115
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
6115
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
6116
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
6116
6117
check_spends ! ( node_txn[ 2 ] , commitment_tx[ 0 ] . clone( ) ) ;
6117
- assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
6118
+ assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
6118
6119
check_spends ! ( node_txn[ 1 ] , chan_1. 3 . clone( ) ) ;
6119
6120
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
6120
6121
let commitment_tx = node_txn[ 1 ] . clone ( ) ;
@@ -6132,12 +6133,12 @@ mod tests {
6132
6133
assert_eq ! ( node_txn[ 0 ] , node_txn[ 3 ] ) ;
6133
6134
check_spends ! ( node_txn[ 0 ] , commitment_tx. clone( ) ) ;
6134
6135
check_spends ! ( node_txn[ 3 ] , commitment_tx. clone( ) ) ;
6135
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
6136
- assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
6136
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
6137
+ assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
6137
6138
check_spends ! ( node_txn[ 1 ] , chan_1. 3 . clone( ) ) ;
6138
6139
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
6139
6140
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
6140
- assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
6141
+ assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
6141
6142
}
6142
6143
6143
6144
#[ test]
@@ -6207,15 +6208,15 @@ mod tests {
6207
6208
assert_eq ! ( node_txn[ 1 ] , node_txn[ 6 ] ) ;
6208
6209
assert_eq ! ( node_txn[ 2 ] , node_txn[ 7 ] ) ;
6209
6210
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
6210
- assert_eq ! ( node_txn[ 0 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 138 ) ;
6211
+ assert_eq ! ( node_txn[ 0 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
6211
6212
check_spends ! ( node_txn[ 1 ] , chan_2. 3 . clone( ) ) ;
6212
6213
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
6213
6214
assert_eq ! ( node_txn[ 1 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 71 ) ;
6214
- assert_eq ! ( node_txn[ 2 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ;
6215
+ assert_eq ! ( node_txn[ 2 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
6215
6216
check_spends ! ( node_txn[ 3 ] , chan_2. 3 . clone( ) ) ;
6216
6217
check_spends ! ( node_txn[ 4 ] , node_txn[ 3 ] . clone( ) ) ;
6217
6218
assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
6218
- assert_eq ! ( node_txn[ 4 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
6219
+ assert_eq ! ( node_txn[ 4 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
6219
6220
timeout_tx = node_txn[ 0 ] . clone ( ) ;
6220
6221
node_txn. clear ( ) ;
6221
6222
}
@@ -6260,11 +6261,11 @@ mod tests {
6260
6261
assert_eq ! ( node_txn. len( ) , 4 ) ;
6261
6262
assert_eq ! ( node_txn[ 0 ] , node_txn[ 3 ] ) ;
6262
6263
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
6263
- assert_eq ! ( node_txn[ 0 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 138 ) ;
6264
+ assert_eq ! ( node_txn[ 0 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
6264
6265
check_spends ! ( node_txn[ 1 ] , chan_1. 3 . clone( ) ) ;
6265
6266
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
6266
6267
assert_eq ! ( node_txn[ 1 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 71 ) ;
6267
- assert_eq ! ( node_txn[ 2 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ;
6268
+ assert_eq ! ( node_txn[ 2 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
6268
6269
}
6269
6270
6270
6271
#[ test]
0 commit comments