@@ -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 {
@@ -71,6 +70,7 @@ pub struct LocalKubernetesNetConfig {
7170 pub docker_image_name : String ,
7271 pub build_mode : BuildMode ,
7372 pub policy_config : ResourceControlPolicyConfig ,
73+ pub path_provider : PathProvider ,
7474}
7575
7676/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
@@ -84,7 +84,6 @@ pub struct LocalKubernetesNet {
8484 network : Network ,
8585 testing_prng_seed : Option < u64 > ,
8686 next_client_id : usize ,
87- tmp_dir : Arc < TempDir > ,
8887 binaries : BuildArg ,
8988 no_build : bool ,
9089 docker_image_name : String ,
@@ -93,6 +92,7 @@ pub struct LocalKubernetesNet {
9392 kind_clusters : Vec < KindCluster > ,
9493 num_initial_validators : usize ,
9594 num_shards : usize ,
95+ path_provider : PathProvider ,
9696}
9797
9898#[ cfg( with_testing) ]
@@ -115,6 +115,7 @@ impl SharedLocalKubernetesNetTestingConfig {
115115 binaries = BuildArg :: Directory ( binaries_dir) ;
116116 }
117117 }
118+ let path_provider = PathProvider :: create_temporary_directory ( ) . unwrap ( ) ;
118119 Self ( LocalKubernetesNetConfig {
119120 network,
120121 testing_prng_seed : Some ( 37 ) ,
@@ -127,6 +128,7 @@ impl SharedLocalKubernetesNetTestingConfig {
127128 docker_image_name : String :: from ( "linera:latest" ) ,
128129 build_mode : BuildMode :: Release ,
129130 policy_config : ResourceControlPolicyConfig :: Testnet ,
131+ path_provider,
130132 } )
131133 }
132134}
@@ -159,6 +161,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
159161 clusters,
160162 self . num_initial_validators ,
161163 self . num_shards ,
164+ self . path_provider ,
162165 ) ?;
163166
164167 let client = net. make_client ( ) . await ;
@@ -275,11 +278,8 @@ impl LineraNet for LocalKubernetesNet {
275278 }
276279
277280 async fn make_client ( & mut self ) -> ClientWrapper {
278- let path_provider = PathProvider :: TemporaryDirectory {
279- tmp_dir : self . tmp_dir . clone ( ) ,
280- } ;
281281 let client = ClientWrapper :: new (
282- path_provider,
282+ self . path_provider . clone ( ) ,
283283 self . network ,
284284 self . testing_prng_seed ,
285285 self . next_client_id ,
@@ -338,12 +338,12 @@ impl LocalKubernetesNet {
338338 kind_clusters : Vec < KindCluster > ,
339339 num_initial_validators : usize ,
340340 num_shards : usize ,
341+ path_provider : PathProvider ,
341342 ) -> Result < Self > {
342343 Ok ( Self {
343344 network,
344345 testing_prng_seed,
345346 next_client_id : 0 ,
346- tmp_dir : Arc :: new ( tempdir ( ) ?) ,
347347 binaries,
348348 no_build,
349349 docker_image_name,
@@ -352,19 +352,23 @@ impl LocalKubernetesNet {
352352 kind_clusters,
353353 num_initial_validators,
354354 num_shards,
355+ path_provider,
355356 } )
356357 }
357358
358359 async fn command_for_binary ( & self , name : & ' static str ) -> Result < Command > {
359360 let path = resolve_binary ( name, env ! ( "CARGO_PKG_NAME" ) ) . await ?;
360361 let mut command = Command :: new ( path) ;
361- command. current_dir ( self . tmp_dir . path ( ) ) ;
362+ command. current_dir ( self . path_provider . path ( ) ) ;
362363 Ok ( command)
363364 }
364365
365366 fn configuration_string ( & self , server_number : usize ) -> Result < String > {
366367 let n = server_number;
367- let path = self . tmp_dir . path ( ) . join ( format ! ( "validator_{n}.toml" ) ) ;
368+ let path = self
369+ . path_provider
370+ . path ( )
371+ . join ( format ! ( "validator_{n}.toml" ) ) ;
368372 let port = 19100 + server_number;
369373 let internal_port = 20100 ;
370374 let metrics_port = 21100 ;
@@ -442,13 +446,11 @@ impl LocalKubernetesNet {
442446 . join ( "kubernetes" )
443447 . join ( "linera-validator" )
444448 . join ( "working" ) ;
445- fs_err:: copy (
446- self . tmp_dir . path ( ) . join ( "genesis.json" ) ,
447- base_dir. join ( "genesis.json" ) ,
448- ) ?;
449+ let path = self . path_provider . path ( ) ;
450+ fs_err:: copy ( path. join ( "genesis.json" ) , base_dir. join ( "genesis.json" ) ) ?;
449451
450452 let kubectl_instance_clone = self . kubectl_instance . clone ( ) ;
451- let tmp_dir_path_clone = self . tmp_dir . path ( ) . to_path_buf ( ) ;
453+ let tmp_dir_path_clone = path. to_path_buf ( ) ;
452454 let num_shards = self . num_shards ;
453455
454456 let mut validators_initialization_futures = Vec :: new ( ) ;
0 commit comments