@@ -14,11 +14,6 @@ use linera_base::{
1414} ;
1515use linera_execution:: ResourceControlPolicy ;
1616use tokio:: process:: Command ;
17- #[ cfg( with_testing) ]
18- use {
19- crate :: cli_wrappers:: wallet:: FaucetOption , linera_base:: command:: current_binary_parent,
20- tokio:: sync:: OnceCell ,
21- } ;
2217
2318use crate :: cli_wrappers:: {
2419 docker:: { BuildArg , DockerImage } ,
@@ -30,12 +25,6 @@ use crate::cli_wrappers::{
3025 ClientWrapper , LineraNet , LineraNetConfig , Network , OnClientDrop ,
3126} ;
3227
33- #[ cfg( with_testing) ]
34- static SHARED_LOCAL_KUBERNETES_TESTING_NET : OnceCell < (
35- Arc < Mutex < LocalKubernetesNet > > ,
36- ClientWrapper ,
37- ) > = OnceCell :: const_new ( ) ;
38-
3928/// The information needed to start a [`LocalKubernetesNet`].
4029pub struct LocalKubernetesNetConfig {
4130 pub network : Network ,
@@ -51,11 +40,6 @@ pub struct LocalKubernetesNetConfig {
5140 pub path_provider : PathProvider ,
5241}
5342
54- /// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
55- /// or use an existing one.
56- #[ cfg( with_testing) ]
57- pub struct SharedLocalKubernetesNetTestingConfig ( LocalKubernetesNetConfig ) ;
58-
5943/// A set of Linera validators running locally as native processes.
6044#[ derive( Clone ) ]
6145pub struct LocalKubernetesNet {
@@ -72,43 +56,6 @@ pub struct LocalKubernetesNet {
7256 path_provider : PathProvider ,
7357}
7458
75- #[ cfg( with_testing) ]
76- impl SharedLocalKubernetesNetTestingConfig {
77- // The second argument is sometimes used locally to use specific binaries for tests.
78- pub fn new ( network : Network , mut binaries : BuildArg ) -> Self {
79- if std:: env:: var ( "LINERA_TRY_RELEASE_BINARIES" ) . unwrap_or_default ( ) == "true"
80- && matches ! ( binaries, BuildArg :: Build )
81- {
82- // For cargo test, current binary should be in debug mode
83- let current_binary_parent =
84- current_binary_parent ( ) . expect ( "Fetching current binaries path should not fail" ) ;
85- // But binaries for cluster should be release mode
86- let binaries_dir = current_binary_parent
87- . parent ( )
88- . expect ( "Getting parent should not fail" )
89- . join ( "release" ) ;
90- if binaries_dir. exists ( ) {
91- // If release exists, use those binaries
92- binaries = BuildArg :: Directory ( binaries_dir) ;
93- }
94- }
95- let path_provider = PathProvider :: create_temporary_directory ( ) . unwrap ( ) ;
96- Self ( LocalKubernetesNetConfig {
97- network,
98- testing_prng_seed : Some ( 37 ) ,
99- num_other_initial_chains : 2 ,
100- initial_amount : Amount :: from_tokens ( 2000 ) ,
101- num_initial_validators : 4 ,
102- num_shards : 4 ,
103- binaries,
104- no_build : false ,
105- docker_image_name : String :: from ( "linera:latest" ) ,
106- policy : ResourceControlPolicy :: devnet ( ) ,
107- path_provider,
108- } )
109- }
110- }
111-
11259#[ async_trait]
11360impl LineraNetConfig for LocalKubernetesNetConfig {
11461 type Net = LocalKubernetesNet ;
@@ -159,65 +106,6 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
159106 }
160107}
161108
162- #[ cfg( with_testing) ]
163- #[ async_trait]
164- impl LineraNetConfig for SharedLocalKubernetesNetTestingConfig {
165- type Net = Arc < Mutex < LocalKubernetesNet > > ;
166-
167- async fn instantiate ( self ) -> Result < ( Self :: Net , ClientWrapper ) > {
168- let ( net, initial_client) = SHARED_LOCAL_KUBERNETES_TESTING_NET
169- . get_or_init ( || async {
170- let ( net, initial_client) = self
171- . 0
172- . instantiate ( )
173- . await
174- . expect ( "Instantiating LocalKubernetesNetConfig should not fail" ) ;
175- ( Arc :: new ( Mutex :: new ( net) ) , initial_client)
176- } )
177- . await ;
178-
179- let mut net = net. clone ( ) ;
180- let client = net. make_client ( ) . await ;
181- // The tests assume we've created a genesis config with 2
182- // chains with 10 tokens each.
183- client. wallet_init ( & [ ] , FaucetOption :: None ) . await . unwrap ( ) ;
184- for _ in 0 ..2 {
185- initial_client
186- . open_and_assign ( & client, Amount :: from_tokens ( 10 ) )
187- . await
188- . unwrap ( ) ;
189- }
190-
191- Ok ( ( net, client) )
192- }
193-
194- async fn policy ( & self ) -> ResourceControlPolicy {
195- self . 0 . policy ( ) . await
196- }
197- }
198-
199- #[ async_trait]
200- impl LineraNet for Arc < Mutex < LocalKubernetesNet > > {
201- async fn ensure_is_running ( & mut self ) -> Result < ( ) > {
202- let self_clone = self . clone ( ) ;
203- let mut self_lock = self_clone. lock ( ) . await ;
204-
205- self_lock. ensure_is_running ( ) . await
206- }
207-
208- async fn make_client ( & mut self ) -> ClientWrapper {
209- let self_clone = self . clone ( ) ;
210- let mut self_lock = self_clone. lock ( ) . await ;
211-
212- self_lock. make_client ( ) . await
213- }
214-
215- async fn terminate ( & mut self ) -> Result < ( ) > {
216- // Users are responsible for killing the clusters if they want to
217- Ok ( ( ) )
218- }
219- }
220-
221109#[ async_trait]
222110impl LineraNet for LocalKubernetesNet {
223111 async fn ensure_is_running ( & mut self ) -> Result < ( ) > {
0 commit comments