Skip to content

Commit 97dd1ad

Browse files
dlachaumesfauvel
andcommitted
Add retro compatibility test for AggregatorFeaturesMessage
Co-authored-by: Sébastien Fauvel <[email protected]>
1 parent 1a49160 commit 97dd1ad

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

mithril-common/src/messages/aggregator_features.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,42 @@ pub struct CardanoTransactionsProverCapabilities {
5050
/// Maximum number of hashes allowed for a single request
5151
pub max_hashes_allowed_by_request: usize,
5252
}
53+
54+
#[cfg(test)]
55+
mod tests {
56+
use super::*;
57+
58+
fn golden_message() -> AggregatorFeaturesMessage {
59+
AggregatorFeaturesMessage {
60+
open_api_version: "0.0.1".to_string(),
61+
documentation_url: "https://example.com".to_string(),
62+
capabilities: AggregatorCapabilities {
63+
signed_entity_types: BTreeSet::from([
64+
SignedEntityTypeDiscriminants::CardanoTransactions,
65+
]),
66+
cardano_transactions_prover: Some(CardanoTransactionsProverCapabilities {
67+
max_hashes_allowed_by_request: 100,
68+
}),
69+
},
70+
}
71+
}
72+
73+
// Test the retro compatibility with possible future upgrades.
74+
#[test]
75+
fn test_v1() {
76+
let json = r#"{
77+
"open_api_version": "0.0.1",
78+
"documentation_url": "https://example.com",
79+
"capabilities": {
80+
"signed_entity_types": ["CardanoTransactions"],
81+
"cardano_transactions_prover": {
82+
"max_hashes_allowed_by_request": 100
83+
}
84+
}
85+
}"#;
86+
87+
let message: AggregatorFeaturesMessage = serde_json::from_str(json).unwrap();
88+
89+
assert_eq!(golden_message(), message);
90+
}
91+
}

0 commit comments

Comments
 (0)