@@ -13,7 +13,6 @@ use linera_base::{
1313 data_types:: Amount ,
1414} ;
1515use linera_client:: client_options:: ResourceControlPolicyConfig ;
16- use tempfile:: { tempdir, TempDir } ;
1716use tokio:: process:: Command ;
1817#[ cfg( with_testing) ]
1918use { linera_base:: command:: current_binary_parent, tokio:: sync:: OnceCell } ;
@@ -69,6 +68,7 @@ pub struct LocalKubernetesNetConfig {
6968 pub build_mode : BuildMode ,
7069 pub policy_config : ResourceControlPolicyConfig ,
7170 pub dual_store : bool ,
71+ pub path_provider : PathProvider ,
7272}
7373
7474/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
@@ -82,7 +82,6 @@ pub struct LocalKubernetesNet {
8282 network : Network ,
8383 testing_prng_seed : Option < u64 > ,
8484 next_client_id : usize ,
85- tmp_dir : Arc < TempDir > ,
8685 binaries : BuildArg ,
8786 no_build : bool ,
8887 docker_image_name : String ,
@@ -92,6 +91,7 @@ pub struct LocalKubernetesNet {
9291 num_initial_validators : usize ,
9392 num_shards : usize ,
9493 dual_store : bool ,
94+ path_provider : PathProvider ,
9595}
9696
9797#[ cfg( with_testing) ]
@@ -114,6 +114,7 @@ impl SharedLocalKubernetesNetTestingConfig {
114114 binaries = BuildArg :: Directory ( binaries_dir) ;
115115 }
116116 }
117+ let path_provider = PathProvider :: create_temporary_directory ( ) . unwrap ( ) ;
117118 Self ( LocalKubernetesNetConfig {
118119 network,
119120 testing_prng_seed : Some ( 37 ) ,
@@ -127,6 +128,7 @@ impl SharedLocalKubernetesNetTestingConfig {
127128 build_mode : BuildMode :: Release ,
128129 policy_config : ResourceControlPolicyConfig :: Testnet ,
129130 dual_store : false ,
131+ path_provider,
130132 } )
131133 }
132134}
@@ -160,6 +162,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
160162 self . num_initial_validators ,
161163 self . num_shards ,
162164 self . dual_store ,
165+ self . path_provider ,
163166 ) ?;
164167
165168 let client = net. make_client ( ) . await ;
@@ -276,11 +279,8 @@ impl LineraNet for LocalKubernetesNet {
276279 }
277280
278281 async fn make_client ( & mut self ) -> ClientWrapper {
279- let path_provider = PathProvider :: TemporaryDirectory {
280- tmp_dir : self . tmp_dir . clone ( ) ,
281- } ;
282282 let client = ClientWrapper :: new (
283- path_provider,
283+ self . path_provider . clone ( ) ,
284284 self . network ,
285285 self . testing_prng_seed ,
286286 self . next_client_id ,
@@ -340,12 +340,12 @@ impl LocalKubernetesNet {
340340 num_initial_validators : usize ,
341341 num_shards : usize ,
342342 dual_store : bool ,
343+ path_provider : PathProvider ,
343344 ) -> Result < Self > {
344345 Ok ( Self {
345346 network,
346347 testing_prng_seed,
347348 next_client_id : 0 ,
348- tmp_dir : Arc :: new ( tempdir ( ) ?) ,
349349 binaries,
350350 no_build,
351351 docker_image_name,
@@ -355,19 +355,23 @@ impl LocalKubernetesNet {
355355 num_initial_validators,
356356 num_shards,
357357 dual_store,
358+ path_provider,
358359 } )
359360 }
360361
361362 async fn command_for_binary ( & self , name : & ' static str ) -> Result < Command > {
362363 let path = resolve_binary ( name, env ! ( "CARGO_PKG_NAME" ) ) . await ?;
363364 let mut command = Command :: new ( path) ;
364- command. current_dir ( self . tmp_dir . path ( ) ) ;
365+ command. current_dir ( self . path_provider . path ( ) ) ;
365366 Ok ( command)
366367 }
367368
368369 fn configuration_string ( & self , server_number : usize ) -> Result < String > {
369370 let n = server_number;
370- let path = self . tmp_dir . path ( ) . join ( format ! ( "validator_{n}.toml" ) ) ;
371+ let path = self
372+ . path_provider
373+ . path ( )
374+ . join ( format ! ( "validator_{n}.toml" ) ) ;
371375 let port = 19100 + server_number;
372376 let internal_port = 20100 ;
373377 let metrics_port = 21100 ;
@@ -450,13 +454,11 @@ impl LocalKubernetesNet {
450454 . join ( "kubernetes" )
451455 . join ( "linera-validator" )
452456 . join ( "working" ) ;
453- fs_err:: copy (
454- self . tmp_dir . path ( ) . join ( "genesis.json" ) ,
455- base_dir. join ( "genesis.json" ) ,
456- ) ?;
457+ let path = self . path_provider . path ( ) ;
458+ fs_err:: copy ( path. join ( "genesis.json" ) , base_dir. join ( "genesis.json" ) ) ?;
457459
458460 let kubectl_instance_clone = self . kubectl_instance . clone ( ) ;
459- let tmp_dir_path_clone = self . tmp_dir . path ( ) . to_path_buf ( ) ;
461+ let tmp_dir_path_clone = path. to_path_buf ( ) ;
460462 let num_shards = self . num_shards ;
461463
462464 let mut validators_initialization_futures = Vec :: new ( ) ;
0 commit comments