-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add routes for ancillary_files_restored, complete_restoratio…
…n and partial_restoration
- Loading branch information
Showing
8 changed files
with
613 additions
and
76 deletions.
There are no files selected for viewing
424 changes: 362 additions & 62 deletions
424
mithril-aggregator/src/http_server/routes/statistics_routes.rs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
mithril-common/src/messages/cardano_database_ancillary_files_restored.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Message structure of an ancillary files restoration | ||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct CardanoDatabaseAncillaryFilesRestoredMessage { | ||
/// Number of ancillary files restored. | ||
pub nb_ancillary_files: u32, | ||
} | ||
|
||
impl CardanoDatabaseAncillaryFilesRestoredMessage { | ||
/// Return a dummy test entity (test-only). | ||
pub fn dummy() -> Self { | ||
Self { | ||
nb_ancillary_files: 34, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
const CURRENT_JSON: &str = r#"{ | ||
"nb_ancillary_files": 62 | ||
}"#; | ||
|
||
fn golden_message_current() -> CardanoDatabaseAncillaryFilesRestoredMessage { | ||
CardanoDatabaseAncillaryFilesRestoredMessage { | ||
nb_ancillary_files: 62, | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_current_json_deserialized_into_current_message() { | ||
let json = CURRENT_JSON; | ||
let message: CardanoDatabaseAncillaryFilesRestoredMessage = | ||
serde_json::from_str(json).unwrap(); | ||
|
||
assert_eq!(golden_message_current(), message); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
mithril-common/src/messages/cardano_database_complete_restoration.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Message structure of a complete Cardano database restoration | ||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct CardanoDatabaseCompleteRestorationMessage { | ||
/// Number of complete restoration. | ||
pub nb_complete_restoration: u32, | ||
} | ||
|
||
impl CardanoDatabaseCompleteRestorationMessage { | ||
/// Return a dummy test entity (test-only). | ||
pub fn dummy() -> Self { | ||
Self { | ||
nb_complete_restoration: 34, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
const CURRENT_JSON: &str = r#"{ | ||
"nb_complete_restoration": 62 | ||
}"#; | ||
|
||
fn golden_message_current() -> CardanoDatabaseCompleteRestorationMessage { | ||
CardanoDatabaseCompleteRestorationMessage { | ||
nb_complete_restoration: 62, | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_current_json_deserialized_into_current_message() { | ||
let json = CURRENT_JSON; | ||
let message: CardanoDatabaseCompleteRestorationMessage = | ||
serde_json::from_str(json).unwrap(); | ||
|
||
assert_eq!(golden_message_current(), message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
mithril-common/src/messages/cardano_database_partial_restoration.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Message structure of a partial Cardano database restoration | ||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct CardanoDatabasePartialRestorationMessage { | ||
/// Number of partial restoration. | ||
pub nb_partial_restoration: u32, | ||
} | ||
|
||
impl CardanoDatabasePartialRestorationMessage { | ||
/// Return a dummy test entity (test-only). | ||
pub fn dummy() -> Self { | ||
Self { | ||
nb_partial_restoration: 34, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
const CURRENT_JSON: &str = r#"{ | ||
"nb_partial_restoration": 62 | ||
}"#; | ||
|
||
fn golden_message_current() -> CardanoDatabasePartialRestorationMessage { | ||
CardanoDatabasePartialRestorationMessage { | ||
nb_partial_restoration: 62, | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_current_json_deserialized_into_current_message() { | ||
let json = CURRENT_JSON; | ||
let message: CardanoDatabasePartialRestorationMessage = serde_json::from_str(json).unwrap(); | ||
|
||
assert_eq!(golden_message_current(), message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters