@@ -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 , task:: JoinSet } ;
1817#[ cfg( with_testing) ]
1918use { linera_base:: command:: current_binary_parent, tokio:: sync:: OnceCell } ;
@@ -73,6 +72,7 @@ pub struct LocalKubernetesNetConfig {
7372 pub indexer_image_name : String ,
7473 pub explorer_image_name : String ,
7574 pub dual_store : bool ,
75+ pub path_provider : PathProvider ,
7676}
7777
7878/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
@@ -86,7 +86,6 @@ pub struct LocalKubernetesNet {
8686 network : Network ,
8787 testing_prng_seed : Option < u64 > ,
8888 next_client_id : usize ,
89- tmp_dir : Arc < TempDir > ,
9089 binaries : BuildArg ,
9190 no_build : bool ,
9291 docker_image_name : String ,
@@ -100,6 +99,7 @@ pub struct LocalKubernetesNet {
10099 indexer_image_name : String ,
101100 explorer_image_name : String ,
102101 dual_store : bool ,
102+ path_provider : PathProvider ,
103103}
104104
105105#[ cfg( with_testing) ]
@@ -139,6 +139,8 @@ impl SharedLocalKubernetesNetTestingConfig {
139139 indexer_image_name : String :: from ( "linera-indexer:latest" ) ,
140140 explorer_image_name : String :: from ( "linera-explorer:latest" ) ,
141141 dual_store : false ,
142+ path_provider : PathProvider :: create_temporary_directory ( )
143+ . expect ( "Creating temporary directory should not fail" ) ,
142144 } )
143145 }
144146}
@@ -176,6 +178,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
176178 self . indexer_image_name ,
177179 self . explorer_image_name ,
178180 self . dual_store ,
181+ self . path_provider ,
179182 ) ?;
180183
181184 let client = net. make_client ( ) . await ;
@@ -292,11 +295,8 @@ impl LineraNet for LocalKubernetesNet {
292295 }
293296
294297 async fn make_client ( & mut self ) -> ClientWrapper {
295- let path_provider = PathProvider :: TemporaryDirectory {
296- tmp_dir : self . tmp_dir . clone ( ) ,
297- } ;
298298 let client = ClientWrapper :: new (
299- path_provider,
299+ self . path_provider . clone ( ) ,
300300 self . network ,
301301 self . testing_prng_seed ,
302302 self . next_client_id ,
@@ -360,12 +360,12 @@ impl LocalKubernetesNet {
360360 indexer_image_name : String ,
361361 explorer_image_name : String ,
362362 dual_store : bool ,
363+ path_provider : PathProvider ,
363364 ) -> Result < Self > {
364365 Ok ( Self {
365366 network,
366367 testing_prng_seed,
367368 next_client_id : 0 ,
368- tmp_dir : Arc :: new ( tempdir ( ) ?) ,
369369 binaries,
370370 no_build,
371371 docker_image_name,
@@ -379,22 +379,23 @@ impl LocalKubernetesNet {
379379 indexer_image_name,
380380 explorer_image_name,
381381 dual_store,
382+ path_provider,
382383 } )
383384 }
384385
385386 async fn command_for_binary ( & self , name : & ' static str ) -> Result < Command > {
386387 let path = resolve_binary ( name, env ! ( "CARGO_PKG_NAME" ) ) . await ?;
387388 let mut command = Command :: new ( path) ;
388- command. current_dir ( self . tmp_dir . path ( ) ) ;
389+ command. current_dir ( self . path_provider . path ( ) ) ;
389390 Ok ( command)
390391 }
391392
392393 fn configuration_string ( & self , validator_number : usize ) -> Result < String > {
393394 let path = self
394- . tmp_dir
395+ . path_provider
395396 . path ( )
396397 . join ( format ! ( "validator_{validator_number}.toml" ) ) ;
397- let public_port = 19100 ;
398+ let public_port = 19100 + validator_number ;
398399 let private_port = 20100 ;
399400 let metrics_port = 21100 ;
400401 let protocol = self . network . toml ( ) ;
@@ -535,12 +536,12 @@ impl LocalKubernetesNet {
535536 . join ( "linera-validator" )
536537 . join ( "working" ) ;
537538 fs_err:: copy (
538- self . tmp_dir . path ( ) . join ( "genesis.json" ) ,
539+ self . path_provider . path ( ) . join ( "genesis.json" ) ,
539540 base_dir. join ( "genesis.json" ) ,
540541 ) ?;
541542
542543 let kubectl_instance_clone = self . kubectl_instance . clone ( ) ;
543- let tmp_dir_path_clone = self . tmp_dir . path ( ) . to_path_buf ( ) ;
544+ let path_provider_path_clone = self . path_provider . path ( ) . to_path_buf ( ) ;
544545 let num_proxies = self . num_proxies ;
545546 let num_shards = self . num_shards ;
546547
@@ -550,7 +551,7 @@ impl LocalKubernetesNet {
550551 let github_root = github_root. clone ( ) ;
551552
552553 let kubectl_instance = kubectl_instance_clone. clone ( ) ;
553- let tmp_dir_path = tmp_dir_path_clone . clone ( ) ;
554+ let path_provider_path = path_provider_path_clone . clone ( ) ;
554555
555556 let docker_image_name = docker_image_name. clone ( ) ;
556557 let indexer_image_name = indexer_image_name. clone ( ) ;
@@ -565,7 +566,7 @@ impl LocalKubernetesNet {
565566
566567 let server_config_filename = format ! ( "server_{}.json" , validator_number) ;
567568 fs_err:: copy (
568- tmp_dir_path . join ( & server_config_filename) ,
569+ path_provider_path . join ( & server_config_filename) ,
569570 base_dir. join ( & server_config_filename) ,
570571 ) ?;
571572
0 commit comments