@@ -4,16 +4,15 @@ use bitcoincore_rpc::RpcApi;
4
4
use tracing:: { debug, info} ;
5
5
6
6
use super :: {
7
- bitcoin:: BitcoinNodeCluster ,
8
- config :: TestConfig ,
9
- docker :: DockerEnv ,
10
- full_node :: FullNode ,
11
- node :: NodeKind ,
12
- sequencer :: Sequencer ,
13
- traits :: { LogProvider , LogProviderErased , NodeT } ,
14
- Result ,
7
+ bitcoin:: BitcoinNodeCluster , config :: TestConfig , docker :: DockerEnv , full_node :: FullNode ,
8
+ node :: NodeKind , sequencer :: Sequencer , traits :: NodeT , Result ,
9
+ } ;
10
+ use crate :: {
11
+ batch_prover :: BatchProver ,
12
+ light_client_prover :: LightClientProver ,
13
+ log_provider :: { LogPathProvider , LogPathProviderErased } ,
14
+ utils :: tail_file ,
15
15
} ;
16
- use crate :: { batch_prover:: BatchProver , light_client_prover:: LightClientProver , utils:: tail_file} ;
17
16
18
17
pub struct TestContext {
19
18
pub config : TestConfig ,
@@ -41,7 +40,6 @@ pub struct TestFramework {
41
40
pub batch_prover : Option < BatchProver > ,
42
41
pub light_client_prover : Option < LightClientProver > ,
43
42
pub full_node : Option < FullNode > ,
44
- show_logs : bool ,
45
43
pub initial_da_height : u64 ,
46
44
}
47
45
@@ -64,15 +62,13 @@ impl TestFramework {
64
62
65
63
let bitcoin_nodes = BitcoinNodeCluster :: new ( & ctx) . await ?;
66
64
67
- // tokio::time::sleep(std::time::Duration::from_secs(30)).await;
68
65
Ok ( Self {
69
66
bitcoin_nodes,
70
67
sequencer : None ,
71
68
batch_prover : None ,
72
69
light_client_prover : None ,
73
70
full_node : None ,
74
71
ctx,
75
- show_logs : true ,
76
72
initial_da_height : 0 ,
77
73
} )
78
74
}
@@ -103,36 +99,31 @@ impl TestFramework {
103
99
Ok ( ( ) )
104
100
}
105
101
106
- fn get_nodes_as_log_provider ( & self ) -> Vec < & dyn LogProviderErased > {
107
- vec ! [
108
- self . bitcoin_nodes. get( 0 ) . map( LogProvider :: as_erased) ,
109
- self . sequencer. as_ref( ) . map( LogProvider :: as_erased) ,
110
- self . full_node. as_ref( ) . map( LogProvider :: as_erased) ,
111
- self . batch_prover. as_ref( ) . map( LogProvider :: as_erased) ,
112
- self . light_client_prover
113
- . as_ref( )
114
- . map( LogProvider :: as_erased) ,
115
- ]
116
- . into_iter ( )
117
- . flatten ( )
118
- . collect ( )
119
- }
120
-
121
- pub fn show_log_paths ( & self ) {
122
- if self . show_logs {
123
- info ! (
124
- "Logs available at {}" ,
125
- self . ctx. config. test_case. dir. display( )
126
- ) ;
127
-
128
- for node in self . get_nodes_as_log_provider ( ) {
129
- info ! (
130
- "{} logs available at : {}" ,
131
- node. kind( ) ,
132
- node. log_path( ) . display( )
133
- ) ;
134
- }
135
- }
102
+ fn get_nodes_as_log_provider ( & self ) -> Vec < & dyn LogPathProviderErased > {
103
+ let test_case = & self . ctx . config . test_case ;
104
+
105
+ self . ctx
106
+ . config
107
+ . bitcoin
108
+ . iter ( )
109
+ . map ( LogPathProvider :: as_erased)
110
+ . map ( Option :: Some )
111
+ . chain ( vec ! [
112
+ test_case
113
+ . with_sequencer
114
+ . then( || LogPathProvider :: as_erased( & self . ctx. config. sequencer) ) ,
115
+ test_case
116
+ . with_full_node
117
+ . then( || LogPathProvider :: as_erased( & self . ctx. config. full_node) ) ,
118
+ test_case
119
+ . with_batch_prover
120
+ . then( || LogPathProvider :: as_erased( & self . ctx. config. batch_prover) ) ,
121
+ test_case
122
+ . with_light_client_prover
123
+ . then( || LogPathProvider :: as_erased( & self . ctx. config. light_client_prover) ) ,
124
+ ] )
125
+ . flatten ( )
126
+ . collect ( )
136
127
}
137
128
138
129
pub fn dump_log ( & self ) -> Result < ( ) > {
@@ -142,11 +133,11 @@ impl TestFramework {
142
133
. ok ( )
143
134
. and_then ( |v| v. parse :: < usize > ( ) . ok ( ) )
144
135
. unwrap_or ( 25 ) ;
145
- for node in self . get_nodes_as_log_provider ( ) {
146
- debug ! ( "{} logs (last {n_lines} lines):" , node . kind( ) ) ;
147
- if let Err ( e ) = tail_file ( & node . log_path ( ) , n_lines) {
148
- eprint ! ( "{e}" ) ;
149
- }
136
+ for provider in self . get_nodes_as_log_provider ( ) {
137
+ println ! ( "{} logs (last {n_lines} lines):" , provider . kind( ) ) ;
138
+ let _ = tail_file ( & provider . log_path ( ) , n_lines) ;
139
+ println ! ( "{} stderr logs (last {n_lines} lines):" , provider . kind ( ) ) ;
140
+ let _ = tail_file ( & provider . stderr_path ( ) , n_lines ) ;
150
141
}
151
142
Ok ( ( ) )
152
143
}
0 commit comments