Skip to content

Commit 7660327

Browse files
committed
Use Chain Observer type in end to end test
1 parent 7e461c7 commit 7660327

File tree

3 files changed

+51
-30
lines changed

3 files changed

+51
-30
lines changed

mithril-test-lab/mithril-end-to-end/src/mithril/aggregator.rs

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ use std::path::{Path, PathBuf};
88
use std::time::Duration;
99
use tokio::process::Child;
1010

11+
#[derive(Debug)]
12+
pub struct AggregatorConfig<'a> {
13+
pub server_port: u64,
14+
pub bft_node: &'a BftNode,
15+
pub cardano_cli_path: &'a Path,
16+
pub work_dir: &'a Path,
17+
pub bin_dir: &'a Path,
18+
pub mithril_era: &'a str,
19+
pub signed_entity_types: &'a [String],
20+
pub chain_observer_type: &'a str,
21+
}
22+
1123
#[derive(Debug)]
1224
pub struct Aggregator {
1325
server_port: u64,
@@ -17,20 +29,14 @@ pub struct Aggregator {
1729
}
1830

1931
impl Aggregator {
20-
pub fn new(
21-
server_port: u64,
22-
bft_node: &BftNode,
23-
cardano_cli_path: &Path,
24-
work_dir: &Path,
25-
bin_dir: &Path,
26-
mithril_era: &str,
27-
signed_entity_types: &[String],
28-
) -> StdResult<Self> {
32+
pub fn new(aggregator_config: &AggregatorConfig) -> StdResult<Self> {
2933
let magic_id = DEVNET_MAGIC_ID.to_string();
30-
let server_port_parameter = server_port.to_string();
31-
let era_reader_adapter_params =
32-
format!(r#"{{"markers": [{{"name": "{mithril_era}", "epoch": 1}}]}}"#);
33-
let signed_entity_types = signed_entity_types.join(",");
34+
let server_port_parameter = aggregator_config.server_port.to_string();
35+
let era_reader_adapter_params = format!(
36+
r#"{{"markers": [{{"name": "{}", "epoch": 1}}]}}"#,
37+
aggregator_config.mithril_era
38+
);
39+
let signed_entity_types = aggregator_config.signed_entity_types.join(",");
3440
let env = HashMap::from([
3541
("NETWORK", "devnet"),
3642
("RUN_INTERVAL", "400"),
@@ -43,25 +49,35 @@ impl Aggregator {
4349
("DATA_STORES_DIRECTORY", "./stores/aggregator"),
4450
(
4551
"CARDANO_NODE_SOCKET_PATH",
46-
bft_node.socket_path.to_str().unwrap(),
52+
aggregator_config.bft_node.socket_path.to_str().unwrap(),
4753
),
4854
("STORE_RETENTION_LIMIT", "10"),
49-
("CARDANO_CLI_PATH", cardano_cli_path.to_str().unwrap()),
55+
("CARDANO_CLI_PATH", aggregator_config.cardano_cli_path.to_str().unwrap()),
5056
("GENESIS_VERIFICATION_KEY", "5b33322c3235332c3138362c3230312c3137372c31312c3131372c3133352c3138372c3136372c3138312c3138382c32322c35392c3230362c3130352c3233312c3135302c3231352c33302c37382c3231322c37362c31362c3235322c3138302c37322c3133342c3133372c3234372c3136312c36385d"),
5157
("GENESIS_SECRET_KEY", "5b3131382c3138342c3232342c3137332c3136302c3234312c36312c3134342c36342c39332c3130362c3232392c38332c3133342c3138392c34302c3138392c3231302c32352c3138342c3136302c3134312c3233372c32362c3136382c35342c3233392c3230342c3133392c3131392c31332c3139395d"),
5258
("ERA_READER_ADAPTER_TYPE", "dummy"),
5359
("ERA_READER_ADAPTER_PARAMS", &era_reader_adapter_params),
5460
("SIGNED_ENTITY_TYPES", &signed_entity_types),
5561
("CARDANO_NODE_VERSION", "8.1.2"),
56-
("CARDANO_NODE_VERSION", "8.1.2"),
62+
("CHAIN_OBSERVER_TYPE", aggregator_config.chain_observer_type),
5763
]);
58-
let args = vec!["--db-directory", bft_node.db_path.to_str().unwrap(), "-vvv"];
64+
let args = vec![
65+
"--db-directory",
66+
aggregator_config.bft_node.db_path.to_str().unwrap(),
67+
"-vvv",
68+
];
5969

60-
let command = MithrilCommand::new("mithril-aggregator", work_dir, bin_dir, env, &args)?;
70+
let command = MithrilCommand::new(
71+
"mithril-aggregator",
72+
aggregator_config.work_dir,
73+
aggregator_config.bin_dir,
74+
env,
75+
&args,
76+
)?;
6177

6278
Ok(Self {
63-
server_port,
64-
db_directory: bft_node.db_path.clone(),
79+
server_port: aggregator_config.server_port,
80+
db_directory: aggregator_config.bft_node.db_path.clone(),
6581
command,
6682
process: None,
6783
})

mithril-test-lab/mithril-end-to-end/src/mithril/infrastructure.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use crate::{Aggregator, Client, Devnet, RelayAggregator, RelaySigner, Signer, DEVNET_MAGIC_ID};
1+
use crate::{
2+
Aggregator, AggregatorConfig, Client, Devnet, RelayAggregator, RelaySigner, Signer,
3+
DEVNET_MAGIC_ID,
4+
};
25
use anyhow::anyhow;
36
use mithril_common::chain_observer::{
47
CardanoCliChainObserver, CardanoCliRunner, ChainObserver, PallasChainObserver,
@@ -40,16 +43,18 @@ impl MithrilInfrastructure {
4043
.bft_nodes
4144
.first()
4245
.ok_or_else(|| anyhow!("No BFT node available for the aggregator"))?;
46+
let chain_observer_type = "pallas";
4347

44-
let mut aggregator = Aggregator::new(
45-
config.server_port,
48+
let mut aggregator = Aggregator::new(&AggregatorConfig {
49+
server_port: config.server_port,
4650
bft_node,
47-
&config.devnet.cardano_cli_path(),
48-
&config.work_dir,
49-
&config.bin_dir,
50-
&config.mithril_era,
51-
&config.signed_entity_types,
52-
)?;
51+
cardano_cli_path: &config.devnet.cardano_cli_path(),
52+
work_dir: &config.work_dir,
53+
bin_dir: &config.bin_dir,
54+
mithril_era: &config.mithril_era,
55+
signed_entity_types: &config.signed_entity_types,
56+
chain_observer_type,
57+
})?;
5358
aggregator.set_protocol_parameters(&ProtocolParameters {
5459
k: 75,
5560
m: 100,

mithril-test-lab/mithril-end-to-end/src/mithril/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod relay_aggregator;
55
mod relay_signer;
66
mod signer;
77

8-
pub use aggregator::Aggregator;
8+
pub use aggregator::{Aggregator, AggregatorConfig};
99
pub use client::{Client, ClientCommand, MithrilStakeDistributionCommand, SnapshotCommand};
1010
pub use infrastructure::{MithrilInfrastructure, MithrilInfrastructureConfig};
1111
pub use relay_aggregator::RelayAggregator;

0 commit comments

Comments
 (0)