Skip to content

Commit b266e54

Browse files
committed
fix: end to end test generates datum for the correct era
It was previously using the current era (and not the next when appropriate) to generate the transaction datum.
1 parent c87ad05 commit b266e54

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

mithril-test-lab/mithril-end-to-end/src/assertions/exec.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ pub async fn bootstrap_genesis_certificate(aggregator: &mut Aggregator) -> StdRe
1818
Ok(())
1919
}
2020

21-
pub async fn register_era_marker(aggregator: &mut Aggregator, devnet: &Devnet) -> StdResult<()> {
21+
pub async fn register_era_marker(
22+
aggregator: &mut Aggregator,
23+
devnet: &Devnet,
24+
mithril_era: &str,
25+
) -> StdResult<()> {
2226
info!("Register era marker");
2327

2428
info!("> generating era marker tx datum...");
2529
let tx_datum_file_path = devnet
2630
.artifacts_dir
2731
.join(PathBuf::from("era-tx-datum.txt".to_string()));
2832
aggregator
29-
.era_generate_tx_datum(&tx_datum_file_path)
33+
.era_generate_tx_datum(&tx_datum_file_path, mithril_era)
3034
.await?;
3135

3236
info!("> writing era marker on the Cardano chain...");

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

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
GENESIS_VERIFICATION_KEY,
66
};
77
use anyhow::{anyhow, Context};
8+
use mithril_common::era::SupportedEra;
89
use mithril_common::{entities, StdResult};
910
use std::collections::HashMap;
1011
use std::path::{Path, PathBuf};
@@ -145,10 +146,19 @@ impl Aggregator {
145146
}
146147

147148
// TODO: This works only for the current epoch, and needs to be fixed
148-
pub async fn era_generate_tx_datum(&mut self, target_path: &Path) -> StdResult<()> {
149-
let exit_status = self
150-
.command
151-
.start(&[
149+
pub async fn era_generate_tx_datum(
150+
&mut self,
151+
target_path: &Path,
152+
mithril_era: &str,
153+
) -> StdResult<()> {
154+
let mithril_eras = SupportedEra::eras();
155+
let args = if mithril_eras
156+
.iter()
157+
.position(|&era| era.to_string() == mithril_era)
158+
== Some(0)
159+
{
160+
// Current era
161+
vec![
152162
"era".to_string(),
153163
"generate-tx-datum".to_string(),
154164
"--current-era-epoch".to_string(),
@@ -157,7 +167,26 @@ impl Aggregator {
157167
ERA_MARKERS_SECRET_KEY.to_string(),
158168
"--target-path".to_string(),
159169
target_path.to_str().unwrap().to_string(),
160-
])?
170+
]
171+
} else {
172+
// Next era
173+
vec![
174+
"era".to_string(),
175+
"generate-tx-datum".to_string(),
176+
"--current-era-epoch".to_string(),
177+
"0".to_string(),
178+
"--next-era-epoch".to_string(),
179+
"1".to_string(),
180+
"--era-markers-secret-key".to_string(),
181+
ERA_MARKERS_SECRET_KEY.to_string(),
182+
"--target-path".to_string(),
183+
target_path.to_str().unwrap().to_string(),
184+
]
185+
};
186+
187+
let exit_status = self
188+
.command
189+
.start(&args)?
161190
.wait()
162191
.await
163192
.with_context(|| "`mithril-aggregator era generate-tx-datum` crashed")?;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ impl MithrilInfrastructure {
6363
m: 100,
6464
phi_f: 0.95,
6565
});
66-
assertions::register_era_marker(&mut aggregator, &config.devnet).await?;
66+
assertions::register_era_marker(&mut aggregator, &config.devnet, &config.mithril_era)
67+
.await?;
6768
aggregator.serve()?;
6869

6970
let mut relay_aggregators: Vec<RelayAggregator> = vec![];

0 commit comments

Comments
 (0)