@@ -2365,7 +2365,6 @@ pub(crate) mod test_utils {
2365
2365
use anyhow:: anyhow;
2366
2366
use edr_eth:: transaction:: { Eip155TransactionRequest , TransactionKind , TransactionRequest } ;
2367
2367
use edr_test_utils:: env:: get_alchemy_url;
2368
- use tempfile:: TempDir ;
2369
2368
2370
2369
use super :: * ;
2371
2370
use crate :: {
@@ -2397,8 +2396,6 @@ pub(crate) mod test_utils {
2397
2396
}
2398
2397
2399
2398
pub ( crate ) struct ProviderTestFixture {
2400
- // We need to keep the tempdir and runtime alive for the duration of the test
2401
- _cache_dir : TempDir ,
2402
2399
_runtime : runtime:: Runtime ,
2403
2400
pub config : ProviderConfig ,
2404
2401
pub provider_data : ProviderData < Infallible > ,
@@ -2425,21 +2422,19 @@ pub(crate) mod test_utils {
2425
2422
}
2426
2423
} ) ;
2427
2424
2428
- let cache_dir = TempDir :: new ( ) ?;
2429
- let config = create_test_config_with_fork ( cache_dir. path ( ) . to_path_buf ( ) , fork) ;
2425
+ let config = create_test_config_with_fork ( fork) ;
2430
2426
2431
2427
let runtime = runtime:: Builder :: new_multi_thread ( )
2432
2428
. worker_threads ( 1 )
2433
2429
. enable_all ( )
2434
2430
. thread_name ( "provider-data-test" )
2435
2431
. build ( ) ?;
2436
2432
2437
- Self :: new ( runtime, cache_dir , config)
2433
+ Self :: new ( runtime, config)
2438
2434
}
2439
2435
2440
2436
pub fn new (
2441
2437
runtime : tokio:: runtime:: Runtime ,
2442
- cache_dir : TempDir ,
2443
2438
mut config : ProviderConfig ,
2444
2439
) -> anyhow:: Result < Self > {
2445
2440
let logger = Box :: < NoopLogger > :: default ( ) ;
@@ -2466,7 +2461,6 @@ pub(crate) mod test_utils {
2466
2461
provider_data. impersonate_account ( impersonated_account) ;
2467
2462
2468
2463
Ok ( Self {
2469
- _cache_dir : cache_dir,
2470
2464
_runtime : runtime,
2471
2465
config,
2472
2466
provider_data,
@@ -2539,13 +2533,14 @@ mod tests {
2539
2533
use edr_evm:: { hex, MineOrdering , RemoteBlock , TransactionError } ;
2540
2534
use edr_test_utils:: env:: get_alchemy_url;
2541
2535
use serde_json:: json;
2542
- use tempfile:: TempDir ;
2543
2536
2544
2537
use super :: { test_utils:: ProviderTestFixture , * } ;
2545
2538
use crate :: {
2546
2539
data:: inspector:: tests:: { deploy_console_log_contract, ConsoleLogTransaction } ,
2547
2540
requests:: eth:: resolve_call_request,
2548
- test_utils:: { create_test_config_with_fork, one_ether, FORK_BLOCK_NUMBER } ,
2541
+ test_utils:: {
2542
+ create_test_config, create_test_config_with_fork, one_ether, FORK_BLOCK_NUMBER ,
2543
+ } ,
2549
2544
MemPoolConfig , MiningConfig , ProviderConfig ,
2550
2545
} ;
2551
2546
@@ -3052,8 +3047,7 @@ mod tests {
3052
3047
3053
3048
#[ test]
3054
3049
fn mine_and_commit_block_fifo_ordering ( ) -> anyhow:: Result < ( ) > {
3055
- let cache_dir = TempDir :: new ( ) ?;
3056
- let default_config = create_test_config_with_fork ( cache_dir. path ( ) . to_path_buf ( ) , None ) ;
3050
+ let default_config = create_test_config ( ) ;
3057
3051
let config = ProviderConfig {
3058
3052
mining : MiningConfig {
3059
3053
mem_pool : MemPoolConfig {
@@ -3070,7 +3064,7 @@ mod tests {
3070
3064
. thread_name ( "provider-data-test" )
3071
3065
. build ( ) ?;
3072
3066
3073
- let mut fixture = ProviderTestFixture :: new ( runtime, cache_dir , config) ?;
3067
+ let mut fixture = ProviderTestFixture :: new ( runtime, config) ?;
3074
3068
3075
3069
let transaction1 = fixture. signed_dummy_transaction ( 0 , None ) ?;
3076
3070
let transaction2 = fixture. signed_dummy_transaction ( 1 , None ) ?;
@@ -3144,8 +3138,7 @@ mod tests {
3144
3138
3145
3139
#[ test]
3146
3140
fn mine_and_commit_block_rewards_miner ( ) -> anyhow:: Result < ( ) > {
3147
- let cache_dir = TempDir :: new ( ) ?;
3148
- let default_config = create_test_config_with_fork ( cache_dir. path ( ) . to_path_buf ( ) , None ) ;
3141
+ let default_config = create_test_config ( ) ;
3149
3142
let config = ProviderConfig {
3150
3143
hardfork : SpecId :: BERLIN ,
3151
3144
..default_config
@@ -3157,7 +3150,7 @@ mod tests {
3157
3150
. thread_name ( "provider-data-test" )
3158
3151
. build ( ) ?;
3159
3152
3160
- let mut fixture = ProviderTestFixture :: new ( runtime, cache_dir , config) ?;
3153
+ let mut fixture = ProviderTestFixture :: new ( runtime, config) ?;
3161
3154
3162
3155
let miner = fixture. provider_data . beneficiary ;
3163
3156
let previous_miner_balance = fixture
@@ -3559,16 +3552,11 @@ mod tests {
3559
3552
. thread_name ( "provider-data-test" )
3560
3553
. build ( ) ?;
3561
3554
3562
- let cache_dir = TempDir :: new ( ) ?;
3563
-
3564
- let default_config = create_test_config_with_fork (
3565
- cache_dir. path ( ) . to_path_buf ( ) ,
3566
- Some ( ForkConfig {
3567
- json_rpc_url : get_alchemy_url ( ) ,
3568
- block_number : Some ( EIP_1559_ACTIVATION_BLOCK ) ,
3569
- http_headers : None ,
3570
- } ) ,
3571
- ) ;
3555
+ let default_config = create_test_config_with_fork ( Some ( ForkConfig {
3556
+ json_rpc_url : get_alchemy_url ( ) ,
3557
+ block_number : Some ( EIP_1559_ACTIVATION_BLOCK ) ,
3558
+ http_headers : None ,
3559
+ } ) ) ;
3572
3560
3573
3561
let config = ProviderConfig {
3574
3562
block_gas_limit : 1_000_000 ,
@@ -3579,7 +3567,7 @@ mod tests {
3579
3567
..default_config
3580
3568
} ;
3581
3569
3582
- let mut fixture = ProviderTestFixture :: new ( runtime, cache_dir , config) ?;
3570
+ let mut fixture = ProviderTestFixture :: new ( runtime, config) ?;
3583
3571
3584
3572
let default_call = CallRequest {
3585
3573
from : Some ( fixture. nth_local_account ( 0 ) ?) ,
@@ -3677,6 +3665,7 @@ mod tests {
3677
3665
) +) => {
3678
3666
$(
3679
3667
paste:: item! {
3668
+ #[ serial_test:: serial]
3680
3669
#[ test]
3681
3670
fn [ <full_block_ $name>] ( ) -> anyhow:: Result <( ) > {
3682
3671
let url = $url;
@@ -3727,15 +3716,20 @@ mod tests {
3727
3716
}
3728
3717
3729
3718
fn run_full_block ( url : String , block_number : u64 , chain_id : u64 ) -> anyhow:: Result < ( ) > {
3719
+ let default_config = create_test_config_with_fork ( Some ( ForkConfig {
3720
+ json_rpc_url : url. clone ( ) ,
3721
+ block_number : Some ( block_number - 1 ) ,
3722
+ http_headers : None ,
3723
+ } ) ) ;
3724
+
3730
3725
let runtime = runtime:: Builder :: new_multi_thread ( )
3731
3726
. worker_threads ( 1 )
3732
3727
. enable_all ( )
3733
3728
. thread_name ( "provider-data-test" )
3734
3729
. build ( ) ?;
3735
3730
3736
- let cache_dir = TempDir :: new ( ) ?;
3737
3731
let replay_block = {
3738
- let rpc_client = RpcClient :: new ( & url, cache_dir. path ( ) . to_path_buf ( ) , None ) ?;
3732
+ let rpc_client = RpcClient :: new ( & url, default_config . cache_dir . clone ( ) , None ) ?;
3739
3733
3740
3734
let block = runtime. block_on ( rpc_client. get_block_by_number_with_transaction_data (
3741
3735
PreEip1898BlockSpec :: Number ( block_number) ,
@@ -3751,15 +3745,6 @@ mod tests {
3751
3745
. hardfork_at_block_number ( block_number)
3752
3746
. ok_or ( anyhow ! ( "Unsupported block number" ) ) ?;
3753
3747
3754
- let default_config = create_test_config_with_fork (
3755
- cache_dir. path ( ) . to_path_buf ( ) ,
3756
- Some ( ForkConfig {
3757
- json_rpc_url : url,
3758
- block_number : Some ( block_number - 1 ) ,
3759
- http_headers : None ,
3760
- } ) ,
3761
- ) ;
3762
-
3763
3748
let replay_header = replay_block. header ( ) ;
3764
3749
let block_gas_limit = replay_header. gas_limit ;
3765
3750
@@ -3781,7 +3766,7 @@ mod tests {
3781
3766
..default_config
3782
3767
} ;
3783
3768
3784
- let mut fixture = ProviderTestFixture :: new ( runtime, cache_dir , config) ?;
3769
+ let mut fixture = ProviderTestFixture :: new ( runtime, config) ?;
3785
3770
3786
3771
for transaction in replay_block. transactions ( ) {
3787
3772
fixture
0 commit comments