Skip to content

Commit

Permalink
fix snapshot digest and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ghubertpalo committed Jun 16, 2022
1 parent d68f312 commit 6e8d24a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 3 additions & 1 deletion mithril-aggregator/src/runtime/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::snapshot_uploaders::SnapshotLocation;
use crate::{DependencyManager, SnapshotError, Snapshotter};
use async_trait::async_trait;
use chrono::Utc;
use hex::FromHex;
use mithril_common::digesters::{Digester, DigesterResult, ImmutableDigester, ImmutableFile};
use mithril_common::entities::{Beacon, Certificate, CertificatePending, Snapshot};

Expand Down Expand Up @@ -378,8 +379,9 @@ impl AggregatorRunnerTrait for AggregatorRunner {
file_path: &Path,
remote_locations: Vec<String>,
) -> Result<Snapshot, RuntimeError> {
let digest_hex = Vec::from_hex(certificate.digest).unwrap();
let snapshot = Snapshot::new(
certificate.digest,
String::from_utf8(digest_hex).map_err(|e| RuntimeError::General(e.to_string()))?,
certificate.hash,
std::fs::metadata(file_path)
.map_err(|e| RuntimeError::General(e.to_string()))?
Expand Down
4 changes: 2 additions & 2 deletions mithril-aggregator/src/runtime/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ impl AggregatorRuntime {
) -> Result<IdleState, RuntimeError> {
let certificate_pending = self.runner.drop_pending_certificate().await?;
let path = self.runner.create_snapshot_archive().await?;
let _ = self.runner.upload_snapshot_archive(&path).await?;
let locations = self.runner.upload_snapshot_archive(&path).await?;
let certificate = self
.runner
.create_and_save_certificate(&state.current_beacon, &certificate_pending)
.await?;
let _ = self
.runner
.create_and_save_snapshot(certificate, &path, Vec::new())
.create_and_save_snapshot(certificate, &path, locations)
.await?;

Ok(IdleState {
Expand Down
2 changes: 1 addition & 1 deletion mithril-test-lab/mithril-end-to-end/src/end_to_end_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Spec {
async fn wait_for_pending_certificate(aggregator_endpoint: &str) -> Result<(), String> {
let url = format!("{}/certificate-pending", aggregator_endpoint);

match attempt!(10, Duration::from_millis(100), {
match attempt!(10, Duration::from_millis(1000), {
match reqwest::get(url.clone()).await {
Ok(response) => match response.status() {
StatusCode::OK => {
Expand Down
11 changes: 7 additions & 4 deletions mithril-test-lab/mithril-end-to-end/src/mithril/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ impl Aggregator {
("SNAPSHOT_UPLOADER_TYPE", "local"),
(
"PENDING_CERTIFICATE_STORE_DIRECTORY",
"./store/pending-certs",
"./store/aggregator/pending-certs",
),
("CERTIFICATE_STORE_DIRECTORY", "./store/certs"),
("VERIFICATION_KEY_STORE_DIRECTORY", "./store/certs"),
("STAKE_STORE_DIRECTORY", "./store/stakes"),
("CERTIFICATE_STORE_DIRECTORY", "./store/aggregator/certs"),
(
"VERIFICATION_KEY_STORE_DIRECTORY",
"./store/aggregator/certs",
),
("STAKE_STORE_DIRECTORY", "./store/aggregator/stakes"),
]);
let args = vec![
"--db-directory",
Expand Down
2 changes: 1 addition & 1 deletion mithril-test-lab/mithril-end-to-end/src/mithril/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Signer {
("RUN_INTERVAL", "2000"),
("AGGREGATOR_ENDPOINT", &aggregator_endpoint),
("DB_DIRECTORY", db_directory.to_str().unwrap()),
("STAKE_STORE_DIRECTORY", "./store/stakes")
("STAKE_STORE_DIRECTORY", "./store/signer/stakes"),
]);
let args = vec!["-vvv"];

Expand Down

0 comments on commit 6e8d24a

Please sign in to comment.