1
- use std:: { fs:: File , path:: PathBuf , sync:: Arc , time:: Duration } ;
1
+ use std:: {
2
+ fs:: File ,
3
+ io:: Write ,
4
+ path:: { Path , PathBuf } ,
5
+ sync:: Arc ,
6
+ time:: Duration ,
7
+ } ;
2
8
3
9
use anyhow:: Context ;
4
10
use clap:: Parser ;
@@ -87,6 +93,24 @@ pub async fn wait_for_http_response(url: &str, timeout: Duration, message: &str)
87
93
}
88
94
}
89
95
96
+ pub fn write_stake_distribution (
97
+ mock_stake_distribution_file_path : & Path ,
98
+ signers_fixture : & MithrilFixture ,
99
+ ) {
100
+ let mock_stake_distribution_file = File :: create ( mock_stake_distribution_file_path) . unwrap ( ) ;
101
+ serde_json:: to_writer (
102
+ & mock_stake_distribution_file,
103
+ & signers_fixture. cardano_cli_stake_distribution ( ) ,
104
+ )
105
+ . expect ( "Writing the stake distribution into a file for the mock cardano cli failed" ) ;
106
+ }
107
+
108
+ pub fn write_epoch ( mock_epoch_file_path : & Path , epoch : Epoch ) {
109
+ let mock_epoch_file = File :: create ( mock_epoch_file_path) . unwrap ( ) ;
110
+ write ! ( & mock_epoch_file, "{}" , * epoch)
111
+ . expect ( "Writing the epoch into a file for the mock cardano cli failed" ) ;
112
+ }
113
+
90
114
#[ derive( Debug , Parser ) ]
91
115
#[ command( author, version, about, long_about = None ) ]
92
116
pub struct MainOpts {
@@ -205,6 +229,7 @@ async fn main() -> StdResult<()> {
205
229
let _logger = init_logger ( & opts) ;
206
230
let args = AggregatorParameters :: new ( & opts) ?;
207
231
let mock_stake_distribution_file_path = args. work_dir . join ( "stake_distribution.json" ) ;
232
+ let mock_epoch_file_path = args. work_dir . join ( "epoch.txt" ) ;
208
233
info ! ( ">> Starting stress test with options: {opts:?}" ) ;
209
234
210
235
info ! ( ">> Creation of the Signer Key Registrations payloads" ) ;
@@ -222,15 +247,12 @@ async fn main() -> StdResult<()> {
222
247
)
223
248
. unwrap ( ) ;
224
249
225
- let mock_stake_distribution_file = File :: create ( & mock_stake_distribution_file_path) . unwrap ( ) ;
226
- serde_json:: to_writer (
227
- & mock_stake_distribution_file,
228
- & signers_fixture. cardano_cli_stake_distribution ( ) ,
229
- )
230
- . expect ( "Writing the stake distribution into a file for the mock cardano cli failed" ) ;
250
+ write_epoch ( & mock_epoch_file_path, Epoch ( 26 ) ) ;
251
+ write_stake_distribution ( & mock_stake_distribution_file_path, & signers_fixture) ;
231
252
232
253
aggregator. change_run_interval ( Duration :: from_secs ( 6 ) ) ;
233
- aggregator. set_mock_cardano_cli_stake_distribution_file ( & mock_stake_distribution_file_path) ;
254
+ aggregator
255
+ . set_mock_cardano_cli_file_path ( & mock_stake_distribution_file_path, & mock_epoch_file_path) ;
234
256
aggregator. set_protocol_parameters ( & ProtocolParameters :: default ( ) ) ;
235
257
aggregator. serve ( ) . unwrap ( ) ;
236
258
0 commit comments