@@ -33,6 +33,7 @@ use actix::Message;
3333use actix:: { Addr , Recipient } ;
3434use itertools:: Itertools ;
3535use masq_lib:: blockchains:: chains:: Chain ;
36+ use masq_lib:: constants:: DEFAULT_MAX_BLOCK_COUNT ;
3637use masq_lib:: logger:: Logger ;
3738use masq_lib:: messages:: ScanType ;
3839use masq_lib:: ui_gateway:: NodeFromUiMessage ;
@@ -287,7 +288,7 @@ impl BlockchainBridge {
287288 } ;
288289 let max_block_count = match self . persistent_config . max_block_count ( ) {
289290 Ok ( Some ( mbc) ) => mbc,
290- _ => u64 :: MAX ,
291+ _ => DEFAULT_MAX_BLOCK_COUNT ,
291292 } ;
292293 let use_unlimited_block_count_range = u64:: MAX == max_block_count;
293294 let use_latest_block = u64:: MAX == start_block_nbr;
@@ -1019,7 +1020,7 @@ mod tests {
10191020 ) ) )
10201021 . lower_interface_results ( Box :: new ( lower_interface) ) ;
10211022 let persistent_config = PersistentConfigurationMock :: new ( )
1022- . max_block_count_result ( Ok ( Some ( 100_000 ) ) )
1023+ . max_block_count_result ( Ok ( Some ( DEFAULT_MAX_BLOCK_COUNT ) ) )
10231024 . start_block_result ( Ok ( Some ( 5 ) ) ) ; // no set_start_block_result: set_start_block() must not be called
10241025 let mut subject = BlockchainBridge :: new (
10251026 Box :: new ( blockchain_interface) ,
@@ -1277,11 +1278,12 @@ mod tests {
12771278 }
12781279
12791280 #[ test]
1280- fn handle_retrieve_transactions_uses_latest_block_number_upon_get_block_number_error ( ) {
1281+ fn handle_retrieve_transactions_uses_default_max_block_count_for_ending_block_number_upon_get_block_number_error (
1282+ ) {
12811283 init_test_logging ( ) ;
12821284 let retrieve_transactions_params_arc = Arc :: new ( Mutex :: new ( vec ! [ ] ) ) ;
12831285 let system = System :: new (
1284- "handle_retrieve_transactions_uses_latest_block_number_upon_get_block_number_error " ,
1286+ "handle_retrieve_transactions_uses_default_max_block_count_for_ending_block_number_upon_get_block_number_error " ,
12851287 ) ;
12861288 let ( accountant, _, accountant_recording_arc) = make_recorder ( ) ;
12871289 let earning_wallet = make_wallet ( "somewallet" ) ;
@@ -1311,7 +1313,7 @@ mod tests {
13111313 . retrieve_transactions_result ( Ok ( expected_transactions. clone ( ) ) )
13121314 . lower_interface_results ( Box :: new ( lower_interface) ) ;
13131315 let persistent_config = PersistentConfigurationMock :: new ( )
1314- . max_block_count_result ( Ok ( None ) )
1316+ . max_block_count_result ( Ok ( Some ( DEFAULT_MAX_BLOCK_COUNT ) ) )
13151317 . start_block_result ( Ok ( Some ( 6 ) ) ) ;
13161318 let subject = BlockchainBridge :: new (
13171319 Box :: new ( blockchain_interface_mock) ,
@@ -1341,7 +1343,7 @@ mod tests {
13411343 * retrieve_transactions_params,
13421344 vec![ (
13431345 BlockNumber :: Number ( 6u64 . into( ) ) ,
1344- BlockNumber :: Latest ,
1346+ BlockNumber :: Number ( ( DEFAULT_MAX_BLOCK_COUNT + 6u64 ) . into ( ) ) ,
13451347 earning_wallet
13461348 ) ]
13471349 ) ;
@@ -1361,7 +1363,7 @@ mod tests {
13611363 } ) ,
13621364 }
13631365 ) ;
1364- TestLogHandler :: new ( ) . exists_log_containing ( "DEBUG: BlockchainBridge: Using 'latest' block number instead of a literal number. QueryFailed(\" Failed to read the latest block number\" )" ) ;
1366+ TestLogHandler :: new ( ) . exists_log_containing ( "DEBUG: BlockchainBridge: Using '100006' ending block number. QueryFailed(\" Failed to read the latest block number\" )" ) ;
13651367 }
13661368
13671369 #[ test]
@@ -1400,7 +1402,7 @@ mod tests {
14001402 . retrieve_transactions_result ( Ok ( expected_transactions. clone ( ) ) )
14011403 . lower_interface_results ( Box :: new ( lower_interface) ) ;
14021404 let persistent_config = PersistentConfigurationMock :: new ( )
1403- . max_block_count_result ( Ok ( None ) )
1405+ . max_block_count_result ( Ok ( Some ( DEFAULT_MAX_BLOCK_COUNT ) ) )
14041406 . start_block_result ( Ok ( None ) ) ;
14051407 let subject = BlockchainBridge :: new (
14061408 Box :: new ( blockchain_interface_mock) ,
@@ -1449,7 +1451,8 @@ mod tests {
14491451 }
14501452
14511453 #[ test]
1452- fn handle_retrieve_transactions_with_latest_for_start_and_end_block_is_supported ( ) {
1454+ fn handle_retrieve_transactions_when_get_block_number_fails_uses_latest_for_start_and_end_block (
1455+ ) {
14531456 let retrieve_transactions_params_arc = Arc :: new ( Mutex :: new ( vec ! [ ] ) ) ;
14541457 let earning_wallet = make_wallet ( "somewallet" ) ;
14551458 let amount = 42 ;
@@ -1471,11 +1474,11 @@ mod tests {
14711474 } ;
14721475
14731476 let system = System :: new (
1474- "handle_retrieve_transactions_with_latest_for_start_and_end_block_is_supported " ,
1477+ "handle_retrieve_transactions_when_get_block_number_fails_uses_latest_for_start_and_end_block " ,
14751478 ) ;
14761479 let ( accountant, _, accountant_recording_arc) = make_recorder ( ) ;
14771480 let persistent_config = PersistentConfigurationMock :: new ( )
1478- . max_block_count_result ( Ok ( None ) )
1481+ . max_block_count_result ( Ok ( Some ( DEFAULT_MAX_BLOCK_COUNT ) ) )
14791482 . start_block_result ( Ok ( None ) ) ;
14801483 let latest_block_number = LatestBlockNumber :: Err ( BlockchainError :: QueryFailed (
14811484 "Failed to read from block chain service" . to_string ( ) ,
0 commit comments