@@ -15,11 +15,6 @@ use linera_base::{
1515use linera_execution:: ResourceControlPolicy ;
1616use tempfile:: { tempdir, TempDir } ;
1717use tokio:: process:: Command ;
18- #[ cfg( with_testing) ]
19- use {
20- crate :: cli_wrappers:: wallet:: FaucetOption , linera_base:: command:: current_binary_parent,
21- tokio:: sync:: OnceCell ,
22- } ;
2318
2419use crate :: cli_wrappers:: {
2520 docker:: { BuildArg , DockerImage } ,
@@ -31,12 +26,6 @@ use crate::cli_wrappers::{
3126 ClientWrapper , LineraNet , LineraNetConfig , Network , OnClientDrop ,
3227} ;
3328
34- #[ cfg( with_testing) ]
35- static SHARED_LOCAL_KUBERNETES_TESTING_NET : OnceCell < (
36- Arc < Mutex < LocalKubernetesNet > > ,
37- ClientWrapper ,
38- ) > = OnceCell :: const_new ( ) ;
39-
4029/// The information needed to start a [`LocalKubernetesNet`].
4130pub struct LocalKubernetesNetConfig {
4231 pub network : Network ,
@@ -51,11 +40,6 @@ pub struct LocalKubernetesNetConfig {
5140 pub policy : ResourceControlPolicy ,
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,41 +56,6 @@ pub struct LocalKubernetesNet {
7256 num_shards : usize ,
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- Self ( LocalKubernetesNetConfig {
96- network,
97- testing_prng_seed : Some ( 37 ) ,
98- num_other_initial_chains : 2 ,
99- initial_amount : Amount :: from_tokens ( 2000 ) ,
100- num_initial_validators : 4 ,
101- num_shards : 4 ,
102- binaries,
103- no_build : false ,
104- docker_image_name : String :: from ( "linera:latest" ) ,
105- policy : ResourceControlPolicy :: devnet ( ) ,
106- } )
107- }
108- }
109-
11059#[ async_trait]
11160impl LineraNetConfig for LocalKubernetesNetConfig {
11261 type Net = LocalKubernetesNet ;
@@ -156,65 +105,6 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
156105 }
157106}
158107
159- #[ cfg( with_testing) ]
160- #[ async_trait]
161- impl LineraNetConfig for SharedLocalKubernetesNetTestingConfig {
162- type Net = Arc < Mutex < LocalKubernetesNet > > ;
163-
164- async fn instantiate ( self ) -> Result < ( Self :: Net , ClientWrapper ) > {
165- let ( net, initial_client) = SHARED_LOCAL_KUBERNETES_TESTING_NET
166- . get_or_init ( || async {
167- let ( net, initial_client) = self
168- . 0
169- . instantiate ( )
170- . await
171- . expect ( "Instantiating LocalKubernetesNetConfig should not fail" ) ;
172- ( Arc :: new ( Mutex :: new ( net) ) , initial_client)
173- } )
174- . await ;
175-
176- let mut net = net. clone ( ) ;
177- let client = net. make_client ( ) . await ;
178- // The tests assume we've created a genesis config with 2
179- // chains with 10 tokens each.
180- client. wallet_init ( & [ ] , FaucetOption :: None ) . await . unwrap ( ) ;
181- for _ in 0 ..2 {
182- initial_client
183- . open_and_assign ( & client, Amount :: from_tokens ( 10 ) )
184- . await
185- . unwrap ( ) ;
186- }
187-
188- Ok ( ( net, client) )
189- }
190-
191- async fn policy ( & self ) -> ResourceControlPolicy {
192- self . 0 . policy ( ) . await
193- }
194- }
195-
196- #[ async_trait]
197- impl LineraNet for Arc < Mutex < LocalKubernetesNet > > {
198- async fn ensure_is_running ( & mut self ) -> Result < ( ) > {
199- let self_clone = self . clone ( ) ;
200- let mut self_lock = self_clone. lock ( ) . await ;
201-
202- self_lock. ensure_is_running ( ) . await
203- }
204-
205- async fn make_client ( & mut self ) -> ClientWrapper {
206- let self_clone = self . clone ( ) ;
207- let mut self_lock = self_clone. lock ( ) . await ;
208-
209- self_lock. make_client ( ) . await
210- }
211-
212- async fn terminate ( & mut self ) -> Result < ( ) > {
213- // Users are responsible for killing the clusters if they want to
214- Ok ( ( ) )
215- }
216- }
217-
218108#[ async_trait]
219109impl LineraNet for LocalKubernetesNet {
220110 async fn ensure_is_running ( & mut self ) -> Result < ( ) > {
0 commit comments