Skip to content

Commit 3295034

Browse files
committed
refactor(e2e): remove distinction master/slave aggregator
As master/slave signer registration is only one of the configurations to be tested.
1 parent 94cdb4d commit 3295034

File tree

5 files changed

+73
-206
lines changed

5 files changed

+73
-206
lines changed

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

+22-34
Original file line numberDiff line numberDiff line change
@@ -51,60 +51,48 @@ impl Spec {
5151
}
5252

5353
pub async fn run(self) -> StdResult<()> {
54+
let mut join_set = JoinSet::new();
5455
let spec = Arc::new(self);
5556
let infrastructure_guard = spec.infrastructure.read().await;
5657
let infrastructure = infrastructure_guard
5758
.as_ref()
5859
.ok_or(anyhow!("No infrastructure found"))?;
60+
let aggregators = infrastructure_guard
61+
.as_ref()
62+
.ok_or(anyhow!("No infrastructure found"))?
63+
.aggregators();
5964

6065
// Transfer some funds on the devnet to have some Cardano transactions to sign.
6166
// This step needs to be executed early in the process so that the transactions are available
6267
// for signing in the penultimate immutable chunk before the end of the test.
6368
// As we get closer to the tip of the chain when signing, we'll be able to relax this constraint.
6469
assertions::transfer_funds(infrastructure.devnet()).await?;
6570

66-
let mut join_set = JoinSet::new();
67-
let spec_clone = spec.clone();
68-
join_set.spawn(async move { spec_clone.start_master().await });
69-
for index in 0..infrastructure.slave_aggregators().len() {
71+
for index in 0..aggregators.len() {
7072
let spec_clone = spec.clone();
71-
join_set.spawn(async move { spec_clone.start_slave(index).await });
73+
join_set.spawn(async move {
74+
let infrastructure_guard = spec_clone.infrastructure.read().await;
75+
let infrastructure = infrastructure_guard
76+
.as_ref()
77+
.ok_or(anyhow!("No infrastructure found"))?;
78+
79+
spec_clone
80+
.start_aggregator(
81+
infrastructure.aggregator(index),
82+
infrastructure.chain_observer(index),
83+
infrastructure,
84+
)
85+
.await
86+
});
7287
}
88+
7389
while let Some(res) = join_set.join_next().await {
7490
res??;
7591
}
7692

7793
Ok(())
7894
}
7995

80-
pub async fn start_master(&self) -> StdResult<()> {
81-
let infrastructure_guard = self.infrastructure.read().await;
82-
let infrastructure = infrastructure_guard
83-
.as_ref()
84-
.ok_or(anyhow!("No infrastructure found"))?;
85-
86-
self.start_aggregator(
87-
infrastructure.master_aggregator(),
88-
infrastructure.master_chain_observer(),
89-
infrastructure,
90-
)
91-
.await
92-
}
93-
94-
pub async fn start_slave(&self, slave_index: usize) -> StdResult<()> {
95-
let infrastructure_guard = self.infrastructure.read().await;
96-
let infrastructure = infrastructure_guard
97-
.as_ref()
98-
.ok_or(anyhow!("No infrastructure found"))?;
99-
100-
self.start_aggregator(
101-
infrastructure.slave_aggregator(slave_index),
102-
infrastructure.slave_chain_observer(slave_index),
103-
infrastructure,
104-
)
105-
.await
106-
}
107-
10896
pub async fn start_aggregator(
10997
&self,
11098
aggregator: &Aggregator,
@@ -138,7 +126,7 @@ impl Spec {
138126
)
139127
.await?;
140128

141-
if aggregator.index() == 0 {
129+
if aggregator.is_first() {
142130
// Delegate some stakes to pools
143131
let delegation_round = 1;
144132
assertions::delegate_stakes_to_pools(infrastructure.devnet(), delegation_round).await?;

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use tokio::sync::RwLock;
1717

1818
#[derive(Debug)]
1919
pub struct AggregatorConfig<'a> {
20-
pub is_master: bool,
2120
pub index: usize,
2221
pub name: &'a str,
2322
pub server_port: u64,
@@ -39,7 +38,6 @@ pub struct AggregatorConfig<'a> {
3938

4039
#[derive(Debug)]
4140
pub struct Aggregator {
42-
is_master: bool,
4341
index: usize,
4442
name_suffix: String,
4543
server_port: u64,
@@ -135,7 +133,6 @@ impl Aggregator {
135133
command.set_log_name(&format!("mithril-aggregator-{}", aggregator_config.name,));
136134

137135
Ok(Self {
138-
is_master: aggregator_config.is_master,
139136
index: aggregator_config.index,
140137
name_suffix: aggregator_config.name.to_string(),
141138
server_port: aggregator_config.server_port,
@@ -145,9 +142,12 @@ impl Aggregator {
145142
})
146143
}
147144

145+
pub fn name_suffix(index: usize) -> String {
146+
format!("{}", index + 1)
147+
}
148+
148149
pub fn copy_configuration(other: &Aggregator) -> Self {
149150
Self {
150-
is_master: other.is_master,
151151
index: other.index,
152152
name_suffix: other.name_suffix.clone(),
153153
server_port: other.server_port,
@@ -157,8 +157,8 @@ impl Aggregator {
157157
}
158158
}
159159

160-
pub fn is_master(&self) -> bool {
161-
self.is_master
160+
pub fn is_first(&self) -> bool {
161+
self.index == 0
162162
}
163163

164164
pub fn index(&self) -> usize {

0 commit comments

Comments
 (0)