@@ -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 } ;
@@ -70,6 +69,7 @@ pub struct LocalKubernetesNetConfig {
7069 pub build_mode : BuildMode ,
7170 pub policy_config : ResourceControlPolicyConfig ,
7271 pub dual_store : bool ,
72+ pub path_provider : PathProvider ,
7373}
7474
7575/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
@@ -83,7 +83,6 @@ pub struct LocalKubernetesNet {
8383 network : Network ,
8484 testing_prng_seed : Option < u64 > ,
8585 next_client_id : usize ,
86- tmp_dir : Arc < TempDir > ,
8786 binaries : BuildArg ,
8887 no_build : bool ,
8988 docker_image_name : String ,
@@ -94,6 +93,7 @@ pub struct LocalKubernetesNet {
9493 num_proxies : usize ,
9594 num_shards : usize ,
9695 dual_store : bool ,
96+ path_provider : PathProvider ,
9797}
9898
9999#[ cfg( with_testing) ]
@@ -130,6 +130,8 @@ impl SharedLocalKubernetesNetTestingConfig {
130130 build_mode : BuildMode :: Release ,
131131 policy_config : ResourceControlPolicyConfig :: Testnet ,
132132 dual_store : false ,
133+ path_provider : PathProvider :: create_temporary_directory ( )
134+ . expect ( "Creating temporary directory should not fail" ) ,
133135 } )
134136 }
135137}
@@ -164,6 +166,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
164166 self . num_proxies ,
165167 self . num_shards ,
166168 self . dual_store ,
169+ self . path_provider ,
167170 ) ?;
168171
169172 let client = net. make_client ( ) . await ;
@@ -280,11 +283,8 @@ impl LineraNet for LocalKubernetesNet {
280283 }
281284
282285 async fn make_client ( & mut self ) -> ClientWrapper {
283- let path_provider = PathProvider :: TemporaryDirectory {
284- tmp_dir : self . tmp_dir . clone ( ) ,
285- } ;
286286 let client = ClientWrapper :: new (
287- path_provider,
287+ self . path_provider . clone ( ) ,
288288 self . network ,
289289 self . testing_prng_seed ,
290290 self . next_client_id ,
@@ -345,12 +345,12 @@ impl LocalKubernetesNet {
345345 num_proxies : usize ,
346346 num_shards : usize ,
347347 dual_store : bool ,
348+ path_provider : PathProvider ,
348349 ) -> Result < Self > {
349350 Ok ( Self {
350351 network,
351352 testing_prng_seed,
352353 next_client_id : 0 ,
353- tmp_dir : Arc :: new ( tempdir ( ) ?) ,
354354 binaries,
355355 no_build,
356356 docker_image_name,
@@ -361,22 +361,23 @@ impl LocalKubernetesNet {
361361 num_proxies,
362362 num_shards,
363363 dual_store,
364+ path_provider,
364365 } )
365366 }
366367
367368 async fn command_for_binary ( & self , name : & ' static str ) -> Result < Command > {
368369 let path = resolve_binary ( name, env ! ( "CARGO_PKG_NAME" ) ) . await ?;
369370 let mut command = Command :: new ( path) ;
370- command. current_dir ( self . tmp_dir . path ( ) ) ;
371+ command. current_dir ( self . path_provider . path ( ) ) ;
371372 Ok ( command)
372373 }
373374
374375 fn configuration_string ( & self , validator_number : usize ) -> Result < String > {
375376 let path = self
376- . tmp_dir
377+ . path_provider
377378 . path ( )
378379 . join ( format ! ( "validator_{validator_number}.toml" ) ) ;
379- let public_port = 19100 ;
380+ let public_port = 19100 + validator_number ;
380381 let private_port = 20100 ;
381382 let metrics_port = 21100 ;
382383 let protocol = self . network . toml ( ) ;
@@ -464,12 +465,12 @@ impl LocalKubernetesNet {
464465 . join ( "linera-validator" )
465466 . join ( "working" ) ;
466467 fs_err:: copy (
467- self . tmp_dir . path ( ) . join ( "genesis.json" ) ,
468+ self . path_provider . path ( ) . join ( "genesis.json" ) ,
468469 base_dir. join ( "genesis.json" ) ,
469470 ) ?;
470471
471472 let kubectl_instance_clone = self . kubectl_instance . clone ( ) ;
472- let tmp_dir_path_clone = self . tmp_dir . path ( ) . to_path_buf ( ) ;
473+ let path_provider_path_clone = self . path_provider . path ( ) . to_path_buf ( ) ;
473474 let num_proxies = self . num_proxies ;
474475 let num_shards = self . num_shards ;
475476
@@ -479,7 +480,7 @@ impl LocalKubernetesNet {
479480 let github_root = github_root. clone ( ) ;
480481
481482 let kubectl_instance = kubectl_instance_clone. clone ( ) ;
482- let tmp_dir_path = tmp_dir_path_clone . clone ( ) ;
483+ let path_provider_path = path_provider_path_clone . clone ( ) ;
483484
484485 let docker_image_name = docker_image_name. clone ( ) ;
485486 let dual_store = self . dual_store ;
@@ -489,7 +490,7 @@ impl LocalKubernetesNet {
489490
490491 let server_config_filename = format ! ( "server_{}.json" , validator_number) ;
491492 fs_err:: copy (
492- tmp_dir_path . join ( & server_config_filename) ,
493+ path_provider_path . join ( & server_config_filename) ,
493494 base_dir. join ( & server_config_filename) ,
494495 ) ?;
495496
0 commit comments