@@ -2393,6 +2393,7 @@ mod tests {
2393
2393
use ln:: router:: { Route , RouteHop , Router } ;
2394
2394
use ln:: msgs;
2395
2395
use ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler } ;
2396
+ use ln:: channel:: { ACCEPTED_HTLC_SCRIPT_WEIGHT , OFFERED_HTLC_SCRIPT_WEIGHT } ;
2396
2397
use util:: test_utils;
2397
2398
use util:: events:: { Event , EventsProvider } ;
2398
2399
use util:: errors:: APIError ;
@@ -4049,7 +4050,7 @@ mod tests {
4049
4050
assert_eq ! ( revoked_local_txn[ 0 ] . output. len( ) , 2 ) ; // Only HTLC and output back to 0 are present
4050
4051
assert_eq ! ( revoked_local_txn[ 1 ] . input. len( ) , 1 ) ;
4051
4052
assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . previous_output. txid, revoked_local_txn[ 0 ] . txid( ) ) ;
4052
- assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ; // HTLC-Timeout
4053
+ assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // HTLC-Timeout
4053
4054
// Revoke the old state
4054
4055
claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , payment_preimage_3) ;
4055
4056
@@ -4129,7 +4130,7 @@ mod tests {
4129
4130
assert_eq ! ( revoked_local_txn[ 0 ] . input[ 0 ] . previous_output. txid, chan_1. 3 . txid( ) ) ;
4130
4131
assert_eq ! ( revoked_local_txn[ 1 ] . input. len( ) , 1 ) ;
4131
4132
assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . previous_output. txid, revoked_local_txn[ 0 ] . txid( ) ) ;
4132
- assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ; // HTLC-Timeout
4133
+ assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // HTLC-Timeout
4133
4134
check_spends ! ( revoked_local_txn[ 1 ] , revoked_local_txn[ 0 ] . clone( ) ) ;
4134
4135
4135
4136
//Revoke the old state
@@ -4155,16 +4156,16 @@ mod tests {
4155
4156
witness_lens. insert ( node_txn[ 0 ] . input [ 2 ] . witness . last ( ) . unwrap ( ) . len ( ) ) ;
4156
4157
assert_eq ! ( witness_lens. len( ) , 3 ) ;
4157
4158
assert_eq ! ( * witness_lens. iter( ) . skip( 0 ) . next( ) . unwrap( ) , 77 ) ; // revoked to_local
4158
- assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , 133 ) ; // revoked offered HTLC
4159
- assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , 138 ) ; // revoked received HTLC
4159
+ assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // revoked offered HTLC
4160
+ assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ; // revoked received HTLC
4160
4161
4161
4162
// Next nodes[1] broadcasts its current local tx state:
4162
4163
assert_eq ! ( node_txn[ 1 ] . input. len( ) , 1 ) ;
4163
4164
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . previous_output. txid, chan_1. 3 . txid( ) ) ; //Spending funding tx unique txouput, tx broadcasted by ChannelManager
4164
4165
4165
4166
assert_eq ! ( node_txn[ 2 ] . input. len( ) , 1 ) ;
4166
4167
let witness_script = node_txn[ 2 ] . clone ( ) . input [ 0 ] . witness . pop ( ) . unwrap ( ) ;
4167
- assert_eq ! ( witness_script. len( ) , 133 ) ; //Spending an offered htlc output
4168
+ assert_eq ! ( witness_script. len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; //Spending an offered htlc output
4168
4169
assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 1 ] . txid( ) ) ;
4169
4170
assert_ne ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 0 ] . previous_output. txid) ;
4170
4171
assert_ne ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 1 ] . previous_output. txid) ;
@@ -4227,15 +4228,15 @@ mod tests {
4227
4228
witness_lens. insert ( node_txn[ 2 ] . input [ 0 ] . witness . last ( ) . unwrap ( ) . len ( ) ) ;
4228
4229
assert_eq ! ( witness_lens. len( ) , 3 ) ;
4229
4230
assert_eq ! ( * witness_lens. iter( ) . skip( 0 ) . next( ) . unwrap( ) , 77 ) ; // revoked to_local
4230
- assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , 133 ) ; // revoked offered HTLC
4231
- assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , 138 ) ; // revoked received HTLC
4231
+ assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // revoked offered HTLC
4232
+ assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ; // revoked received HTLC
4232
4233
4233
4234
assert_eq ! ( node_txn[ 3 ] . input. len( ) , 1 ) ;
4234
4235
check_spends ! ( node_txn[ 3 ] , chan_1. 3 . clone( ) ) ;
4235
4236
4236
4237
assert_eq ! ( node_txn[ 4 ] . input. len( ) , 1 ) ;
4237
4238
let witness_script = node_txn[ 4 ] . input [ 0 ] . witness . last ( ) . unwrap ( ) ;
4238
- assert_eq ! ( witness_script. len( ) , 133 ) ; //Spending an offered htlc output
4239
+ assert_eq ! ( witness_script. len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; //Spending an offered htlc output
4239
4240
assert_eq ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 3 ] . txid( ) ) ;
4240
4241
assert_ne ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 0 ] . previous_output. txid) ;
4241
4242
assert_ne ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 1 ] . input[ 0 ] . previous_output. txid) ;
@@ -4300,11 +4301,11 @@ mod tests {
4300
4301
let node_txn = nodes[ 2 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) . clone ( ) ; // ChannelManager : 2 (commitment tx, HTLC-Success tx), ChannelMonitor : 1 (HTLC-Success tx)
4301
4302
assert_eq ! ( node_txn. len( ) , 3 ) ;
4302
4303
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
4303
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
4304
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
4304
4305
check_spends ! ( node_txn[ 1 ] , chan_2. 3 . clone( ) ) ;
4305
4306
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
4306
4307
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
4307
- assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
4308
+ assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
4308
4309
4309
4310
// Verify that B's ChannelManager is able to extract preimage from HTLC Success tx and pass it backward
4310
4311
nodes[ 1 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : node_txn} , 1 ) ;
@@ -4335,12 +4336,12 @@ mod tests {
4335
4336
assert_eq ! ( node_txn[ 0 ] , node_txn[ 3 ] ) ;
4336
4337
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
4337
4338
check_spends ! ( node_txn[ 3 ] , commitment_tx[ 0 ] . clone( ) ) ;
4338
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
4339
- assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
4339
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
4340
+ assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
4340
4341
check_spends ! ( node_txn[ 1 ] , chan_2. 3 . clone( ) ) ;
4341
4342
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
4342
4343
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
4343
- assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
4344
+ assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
4344
4345
node_txn. clear ( )
4345
4346
}
4346
4347
@@ -4359,9 +4360,9 @@ mod tests {
4359
4360
assert_eq ! ( node_txn. len( ) , 3 ) ;
4360
4361
assert_eq ! ( node_txn[ 0 ] , node_txn[ 2 ] ) ;
4361
4362
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
4362
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
4363
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
4363
4364
check_spends ! ( node_txn[ 2 ] , commitment_tx[ 0 ] . clone( ) ) ;
4364
- assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
4365
+ assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
4365
4366
check_spends ! ( node_txn[ 1 ] , chan_1. 3 . clone( ) ) ;
4366
4367
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
4367
4368
let commitment_tx = node_txn[ 1 ] . clone ( ) ;
@@ -4379,12 +4380,12 @@ mod tests {
4379
4380
assert_eq ! ( node_txn[ 0 ] , node_txn[ 3 ] ) ;
4380
4381
check_spends ! ( node_txn[ 0 ] , commitment_tx. clone( ) ) ;
4381
4382
check_spends ! ( node_txn[ 3 ] , commitment_tx. clone( ) ) ;
4382
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
4383
- assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 138 ) ;
4383
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
4384
+ assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
4384
4385
check_spends ! ( node_txn[ 1 ] , chan_1. 3 . clone( ) ) ;
4385
4386
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
4386
4387
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
4387
- assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
4388
+ assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
4388
4389
}
4389
4390
4390
4391
#[ test]
@@ -4454,15 +4455,15 @@ mod tests {
4454
4455
assert_eq ! ( node_txn[ 1 ] , node_txn[ 6 ] ) ;
4455
4456
assert_eq ! ( node_txn[ 2 ] , node_txn[ 7 ] ) ;
4456
4457
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
4457
- assert_eq ! ( node_txn[ 0 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 138 ) ;
4458
+ assert_eq ! ( node_txn[ 0 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
4458
4459
check_spends ! ( node_txn[ 1 ] , chan_2. 3 . clone( ) ) ;
4459
4460
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
4460
4461
assert_eq ! ( node_txn[ 1 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 71 ) ;
4461
- assert_eq ! ( node_txn[ 2 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ;
4462
+ assert_eq ! ( node_txn[ 2 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
4462
4463
check_spends ! ( node_txn[ 3 ] , chan_2. 3 . clone( ) ) ;
4463
4464
check_spends ! ( node_txn[ 4 ] , node_txn[ 3 ] . clone( ) ) ;
4464
4465
assert_eq ! ( node_txn[ 3 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 71 ) ;
4465
- assert_eq ! ( node_txn[ 4 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , 133 ) ;
4466
+ assert_eq ! ( node_txn[ 4 ] . input[ 0 ] . witness. clone( ) . last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
4466
4467
timeout_tx = node_txn[ 0 ] . clone ( ) ;
4467
4468
node_txn. clear ( ) ;
4468
4469
}
@@ -4507,11 +4508,11 @@ mod tests {
4507
4508
assert_eq ! ( node_txn. len( ) , 4 ) ;
4508
4509
assert_eq ! ( node_txn[ 0 ] , node_txn[ 3 ] ) ;
4509
4510
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
4510
- assert_eq ! ( node_txn[ 0 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 138 ) ;
4511
+ assert_eq ! ( node_txn[ 0 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
4511
4512
check_spends ! ( node_txn[ 1 ] , chan_1. 3 . clone( ) ) ;
4512
4513
check_spends ! ( node_txn[ 2 ] , node_txn[ 1 ] . clone( ) ) ;
4513
4514
assert_eq ! ( node_txn[ 1 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 71 ) ;
4514
- assert_eq ! ( node_txn[ 2 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ;
4515
+ assert_eq ! ( node_txn[ 2 ] . clone( ) . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
4515
4516
}
4516
4517
4517
4518
#[ test]
0 commit comments