Skip to content

Commit 65db042

Browse files
committed
Rework aggregator features compatibility tests
Test deserialisation of previous structure with the current json
1 parent f325c29 commit 65db042

File tree

1 file changed

+23
-32
lines changed

1 file changed

+23
-32
lines changed

mithril-common/src/messages/aggregator_features.rs

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ mod tests {
7676
pub cardano_transactions_prover: Option<CardanoTransactionsProverCapabilities>,
7777
}
7878

79-
fn golden_message_v1() -> AggregatorFeaturesMessagePrevious {
79+
fn golden_message_previous() -> AggregatorFeaturesMessagePrevious {
8080
AggregatorFeaturesMessagePrevious {
8181
open_api_version: "0.0.1".to_string(),
8282
documentation_url: "https://example.com".to_string(),
@@ -91,7 +91,7 @@ mod tests {
9191
}
9292
}
9393

94-
fn golden_message_v2() -> AggregatorFeaturesMessage {
94+
fn golden_message_actual() -> AggregatorFeaturesMessage {
9595
AggregatorFeaturesMessage {
9696
open_api_version: "0.0.1".to_string(),
9797
documentation_url: "https://example.com".to_string(),
@@ -110,44 +110,35 @@ mod tests {
110110
}
111111
}
112112

113-
// Test the retro compatibility with possible future upgrades.
114-
#[test]
115-
fn test_v1() {
116-
let json = r#"{
117-
"open_api_version": "0.0.1",
118-
"documentation_url": "https://example.com",
119-
"capabilities": {
120-
"signed_entity_types": ["CardanoTransactions"],
121-
"cardano_transactions_prover": {
122-
"max_hashes_allowed_by_request": 100
123-
}
113+
const ACTUAL_JSON: &str = r#"{
114+
"open_api_version": "0.0.1",
115+
"documentation_url": "https://example.com",
116+
"capabilities": {
117+
"signed_entity_types": ["CardanoTransactions"],
118+
"cardano_transactions_prover": {
119+
"max_hashes_allowed_by_request": 100
120+
},
121+
"cardano_transactions_signing_config": {
122+
"security_parameter": 70,
123+
"step": 20
124124
}
125-
}"#;
125+
}
126+
}"#;
126127

128+
// Test the retro compatibility with possible future upgrades.
129+
#[test]
130+
fn test_actual_json_deserialized_into_previous_message() {
131+
let json = ACTUAL_JSON;
127132
let message: AggregatorFeaturesMessagePrevious = serde_json::from_str(json).unwrap();
128133

129-
assert_eq!(golden_message_v1(), message);
134+
assert_eq!(golden_message_previous(), message);
130135
}
131136

132137
#[test]
133-
fn test_v2() {
134-
let json = r#"{
135-
"open_api_version": "0.0.1",
136-
"documentation_url": "https://example.com",
137-
"capabilities": {
138-
"signed_entity_types": ["CardanoTransactions"],
139-
"cardano_transactions_prover": {
140-
"max_hashes_allowed_by_request": 100
141-
},
142-
"cardano_transactions_signing_config": {
143-
"security_parameter": 70,
144-
"step": 20
145-
}
146-
}
147-
}"#;
148-
138+
fn test_actual_json_deserialized_into_actual_message() {
139+
let json = ACTUAL_JSON;
149140
let message: AggregatorFeaturesMessage = serde_json::from_str(json).unwrap();
150141

151-
assert_eq!(golden_message_v2(), message);
142+
assert_eq!(golden_message_actual(), message);
152143
}
153144
}

0 commit comments

Comments
 (0)