@@ -71,7 +71,7 @@ use std::cell::RefCell;
71
71
use std:: convert:: TryInto ;
72
72
use std:: cmp;
73
73
use std:: sync:: { Arc , Mutex } ;
74
- use std:: sync:: atomic:: { AtomicU64 , AtomicUsize , Ordering } ;
74
+ use std:: sync:: atomic:: { AtomicU64 , AtomicUsize , AtomicBool , Ordering } ;
75
75
use bech32:: u5;
76
76
77
77
#[ inline]
@@ -98,6 +98,7 @@ pub fn slice_to_be24(v: &[u8]) -> u32 {
98
98
struct InputData {
99
99
data : Vec < u8 > ,
100
100
read_pos : AtomicUsize ,
101
+ halt_fee_est_reads : AtomicBool ,
101
102
}
102
103
impl InputData {
103
104
fn get_slice ( & self , len : usize ) -> Option < & [ u8 ] > {
@@ -124,6 +125,9 @@ struct FuzzEstimator {
124
125
}
125
126
impl FeeEstimator for FuzzEstimator {
126
127
fn get_est_sat_per_1000_weight ( & self , _: ConfirmationTarget ) -> u32 {
128
+ if self . input . halt_fee_est_reads . load ( Ordering :: Acquire ) {
129
+ return 253 ;
130
+ }
127
131
//TODO: We should actually be testing at least much more than 64k...
128
132
match self . input . get_slice ( 2 ) {
129
133
Some ( slice) => cmp:: max ( slice_to_be16 ( slice) as u32 , 253 ) ,
@@ -446,6 +450,7 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
446
450
let input = Arc :: new ( InputData {
447
451
data : data. to_vec ( ) ,
448
452
read_pos : AtomicUsize :: new ( 0 ) ,
453
+ halt_fee_est_reads : AtomicBool :: new ( false ) ,
449
454
} ) ;
450
455
let fee_est = Arc :: new ( FuzzEstimator {
451
456
input : input. clone ( ) ,
@@ -703,10 +708,12 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger>) {
703
708
11 => {
704
709
let mut txn = broadcast. txn_broadcasted . lock ( ) . unwrap ( ) . split_off ( 0 ) ;
705
710
if !txn. is_empty ( ) {
711
+ input. halt_fee_est_reads . store ( true , Ordering :: Release ) ;
706
712
loss_detector. connect_block ( & txn[ ..] ) ;
707
713
for _ in 2 ..100 {
708
714
loss_detector. connect_block ( & [ ] ) ;
709
715
}
716
+ input. halt_fee_est_reads . store ( false , Ordering :: Release ) ;
710
717
}
711
718
for tx in txn. drain ( ..) {
712
719
loss_detector. funding_txn . push ( tx) ;
@@ -914,19 +921,32 @@ mod tests {
914
921
ext_from_hex ( "0c005e" , & mut test) ;
915
922
// the funding transaction
916
923
ext_from_hex ( "020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0150c3000000000000220020ae0000000000000000000000000000000000000000000000000000000000000000000000" , & mut test) ;
924
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
917
925
// connect a block with no transactions, one per line
918
926
ext_from_hex ( "0c0000" , & mut test) ;
927
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
919
928
ext_from_hex ( "0c0000" , & mut test) ;
929
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
920
930
ext_from_hex ( "0c0000" , & mut test) ;
931
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
921
932
ext_from_hex ( "0c0000" , & mut test) ;
933
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
922
934
ext_from_hex ( "0c0000" , & mut test) ;
935
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
923
936
ext_from_hex ( "0c0000" , & mut test) ;
937
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
924
938
ext_from_hex ( "0c0000" , & mut test) ;
939
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
925
940
ext_from_hex ( "0c0000" , & mut test) ;
941
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
926
942
ext_from_hex ( "0c0000" , & mut test) ;
943
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
927
944
ext_from_hex ( "0c0000" , & mut test) ;
945
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
928
946
ext_from_hex ( "0c0000" , & mut test) ;
947
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
929
948
ext_from_hex ( "0c0000" , & mut test) ;
949
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
930
950
// by now client should have sent a channel_ready (CHECK 3: SendChannelReady to 03000000 for chan 3d000000)
931
951
932
952
// inbound read from peer id 0 of len 18
@@ -1296,21 +1316,28 @@ mod tests {
1296
1316
ext_from_hex ( "0c007d" , & mut test) ;
1297
1317
// the commitment transaction for channel 3f00000000000000000000000000000000000000000000000000000000000000
1298
1318
ext_from_hex ( "02000000013a000000000000000000000000000000000000000000000000000000000000000000000000000000800258020000000000002200204b0000000000000000000000000000000000000000000000000000000000000014c0000000000000160014280000000000000000000000000000000000000005000020" , & mut test) ;
1319
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
1299
1320
//
1300
1321
// connect a block with one transaction of len 94
1301
1322
ext_from_hex ( "0c005e" , & mut test) ;
1302
1323
// the HTLC timeout transaction
1303
1324
ext_from_hex ( "0200000001730000000000000000000000000000000000000000000000000000000000000000000000000000000001a701000000000000220020b20000000000000000000000000000000000000000000000000000000000000000000000" , & mut test) ;
1325
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
1304
1326
// connect a block with no transactions
1305
1327
ext_from_hex ( "0c0000" , & mut test) ;
1328
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
1306
1329
// connect a block with no transactions
1307
1330
ext_from_hex ( "0c0000" , & mut test) ;
1331
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
1308
1332
// connect a block with no transactions
1309
1333
ext_from_hex ( "0c0000" , & mut test) ;
1334
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
1310
1335
// connect a block with no transactions
1311
1336
ext_from_hex ( "0c0000" , & mut test) ;
1337
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
1312
1338
// connect a block with no transactions
1313
1339
ext_from_hex ( "0c0000" , & mut test) ;
1340
+ ext_from_hex ( "00fd00fd" , & mut test) ; // Two feerate requests during block connection
1314
1341
1315
1342
// process the now-pending HTLC forward
1316
1343
ext_from_hex ( "07" , & mut test) ;
0 commit comments