Skip to content

Commit 85cefb7

Browse files
committed
Adapt snapshot routes to new location
1 parent d94bd0a commit 85cefb7

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

mithril-aggregator/src/snapshot_uploaders/local_snapshot_uploader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl SnapshotUploader for LocalSnapshotUploader {
3737

3838
let digest = tools::extract_digest_from_path(Path::new(archive_name));
3939
let location = format!(
40-
"{}{}/snapshot/{}/download",
40+
"{}{}/artifact/snapshot/{}/download",
4141
self.snapshot_server_url,
4242
http_server::SERVER_BASE_PATH,
4343
digest.unwrap()

mithril-client/src/aggregator.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl AggregatorHandler for AggregatorHTTPClient {
212212
/// List snapshots
213213
async fn list_snapshots(&self) -> Result<Vec<Snapshot>, AggregatorHandlerError> {
214214
debug!("List snapshots");
215-
let url = format!("{}/snapshots", self.aggregator_endpoint);
215+
let url = format!("{}/artifact/snapshots", self.aggregator_endpoint);
216216
let response = self
217217
.prepare_request_builder(Client::new().get(url.clone()))
218218
.await
@@ -246,7 +246,7 @@ impl AggregatorHandler for AggregatorHTTPClient {
246246
/// Get snapshot details
247247
async fn get_snapshot_details(&self, digest: &str) -> Result<Snapshot, AggregatorHandlerError> {
248248
debug!("Details snapshot {}", digest);
249-
let url = format!("{}/snapshot/{}", self.aggregator_endpoint, digest);
249+
let url = format!("{}/artifact/snapshot/{}", self.aggregator_endpoint, digest);
250250
let response = self
251251
.prepare_request_builder(Client::new().get(url.clone()))
252252
.await
@@ -446,7 +446,7 @@ mod tests {
446446
let (server, config) = setup_test();
447447
let snapshots_expected = fake_data::snapshots(5);
448448
let _snapshots_mock = server.mock(|when, then| {
449-
when.path("/snapshots");
449+
when.path("/artifact/snapshots");
450450
then.status(200).body(json!(snapshots_expected).to_string());
451451
});
452452
let aggregator_client = AggregatorHTTPClient::new(
@@ -463,7 +463,7 @@ mod tests {
463463
async fn test_list_snapshots_ko_412() {
464464
let (server, config) = setup_test();
465465
let _snapshots_mock = server.mock(|when, then| {
466-
when.path("/snapshots");
466+
when.path("/artifact/snapshots");
467467
then.status(412).header(
468468
MITHRIL_API_VERSION_HEADER,
469469
APIVersionProvider::compute_all_versions_sorted()
@@ -488,7 +488,7 @@ mod tests {
488488
async fn test_list_snapshots_ko_500() {
489489
let (server, config) = setup_test();
490490
let _snapshots_mock = server.mock(|when, then| {
491-
when.path("/snapshots");
491+
when.path("/artifact/snapshots");
492492
then.status(500);
493493
});
494494
let aggregator_client = AggregatorHTTPClient::new(
@@ -518,7 +518,7 @@ mod tests {
518518
let (server, config) = setup_test();
519519
let snapshot_expected = fake_data::snapshots(1).first().unwrap().to_owned();
520520
let _snapshots_mock = server.mock(|when, then| {
521-
when.path(format!("/snapshot/{digest}"));
521+
when.path(format!("/artifact/snapshot/{digest}"));
522522
then.status(200).body(json!(snapshot_expected).to_string());
523523
});
524524
let aggregator_client = AggregatorHTTPClient::new(
@@ -536,7 +536,7 @@ mod tests {
536536
let digest = "digest123";
537537
let (server, config) = setup_test();
538538
let _snapshots_mock = server.mock(|when, then| {
539-
when.path(format!("/snapshot/{digest}"));
539+
when.path(format!("/artifact/snapshot/{digest}"));
540540
then.status(404);
541541
});
542542
let aggregator_client = AggregatorHTTPClient::new(
@@ -553,7 +553,7 @@ mod tests {
553553
let (server, config) = setup_test();
554554
let digest = "digest123";
555555
let _snapshots_mock = server.mock(|when, then| {
556-
when.path(format!("/snapshot/{digest}"));
556+
when.path(format!("/artifact/snapshot/{digest}"));
557557
then.status(412)
558558
.header(MITHRIL_API_VERSION_HEADER, "0.0.999");
559559
});
@@ -575,7 +575,7 @@ mod tests {
575575
let digest = "digest123";
576576
let (server, config) = setup_test();
577577
let _snapshots_mock = server.mock(|when, then| {
578-
when.path(format!("/snapshot/{digest}"));
578+
when.path(format!("/artifact/snapshot/{digest}"));
579579
then.status(500);
580580
});
581581
let aggregator_client = AggregatorHTTPClient::new(

mithril-common/src/test_utils/fake_data.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Fake data builders for testing.
22
33
use crate::entities::{
4-
CertificateMetadata, LotteryIndex, ProtocolMessage, ProtocolMessagePartKey, SignedEntityType,
5-
SingleSignatures,
4+
CertificateMetadata, Epoch, LotteryIndex, ProtocolMessage, ProtocolMessagePartKey,
5+
SignedEntityType, SingleSignatures,
66
};
77
use crate::{crypto_helper, entities};
88

@@ -185,6 +185,17 @@ pub fn snapshots(total: u64) -> Vec<entities::Snapshot> {
185185
.collect::<Vec<entities::Snapshot>>()
186186
}
187187

188+
/// Fake Mithril Stake Distribution
189+
pub fn mithril_stake_distributions(total: u64) -> Vec<entities::MithrilStakeDistribution> {
190+
(1..total + 1)
191+
.map(|epoch_idx| entities::MithrilStakeDistribution {
192+
epoch: Epoch(epoch_idx),
193+
signers_with_stake: self::signers_with_stakes(5),
194+
hash: format!("hash-epoch-{epoch_idx}"),
195+
})
196+
.collect::<Vec<entities::MithrilStakeDistribution>>()
197+
}
198+
188199
const SIGNERS_WITH_STAKE_JSON: &str = r###"
189200
[
190201
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ async fn update_protocol_parameters(aggregator: &mut Aggregator) -> Result<(), S
241241
}
242242

243243
async fn assert_node_producing_snapshot(aggregator_endpoint: &str) -> Result<String, String> {
244-
let url = format!("{aggregator_endpoint}/snapshots");
244+
let url = format!("{aggregator_endpoint}/artifact/snapshots");
245245
info!("Waiting for the aggregator to produce a snapshot");
246246

247247
// todo: reduce the number of attempts if we can reduce the delay between two immutables
@@ -274,7 +274,7 @@ async fn assert_signer_is_signing_snapshot(
274274
digest: &str,
275275
expected_epoch_min: Epoch,
276276
) -> Result<String, String> {
277-
let url = format!("{aggregator_endpoint}/snapshot/{digest}");
277+
let url = format!("{aggregator_endpoint}/artifact/snapshot/{digest}");
278278
info!(
279279
"Asserting the aggregator is signing the snapshot message `{}` with an expected min epoch of `{}`",
280280
digest,

0 commit comments

Comments
 (0)