Skip to content

Commit 6eea402

Browse files
committed
Apply review comments
1 parent ca9e084 commit 6eea402

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use serde::{Deserialize, Serialize};
22

33
/// Message adapter trait
4-
pub trait MessageAdapter<U, V: Serialize + for<'a> Deserialize<'a>> {
4+
pub trait MessageAdapter<U, V>
5+
where
6+
V: Serialize + for<'a> Deserialize<'a>,
7+
{
58
/// Adapt entity to message
69
fn adapt(from: U) -> V;
710
}

mithril-common/src/messages/mithril_stake_distribution.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mod tests {
3838
fn golden_message() -> MithrilStakeDistributionMessage {
3939
MithrilStakeDistributionMessage {
4040
epoch: Epoch(1),
41-
signers_with_stake: fake_data::signers_with_stakes(2),
41+
signers_with_stake: fake_data::signers_with_stakes(1),
4242
hash: "hash-123".to_string(),
4343
}
4444
}
@@ -47,23 +47,22 @@ mod tests {
4747
#[test]
4848
fn test_v1() {
4949
let json = r#"{
50-
"digest": "0b9f5ad7f33cc523775c82249294eb8a1541d54f08eb3107cafc5638403ec7c6",
51-
"beacon": {
52-
"network": "preview",
53-
"epoch": 86,
54-
"immutable_file_number": 1728
55-
},
56-
"certificate_hash": "d5daf6c03ace4a9c074e951844075b9b373bafc4e039160e3e2af01823e9abfb",
57-
"size": 807803196,
58-
"created_at": "2023-01-19T13:43:05.618857482Z",
59-
"locations": [
60-
"https://host/certificate.tar.gz"
61-
]
62-
}"#;
50+
"epoch": 1,
51+
"signers": [
52+
{
53+
"party_id": "0",
54+
"verification_key": "7b22766b223a5b3134332c3136312c3235352c34382c37382c35372c3230342c3232302c32352c3232312c3136342c3235322c3234382c31342c35362c3132362c3138362c3133352c3232382c3138382c3134352c3138312c35322c3230302c39372c39392c3231332c34362c302c3139392c3139332c38392c3138372c38382c32392c3133352c3137332c3234342c38362c33362c38332c35342c36372c3136342c362c3133372c39342c37322c362c3130352c3132382c3132382c39332c34382c3137362c31312c342c3234362c3133382c34382c3138302c3133332c39302c3134322c3139322c32342c3139332c3131312c3134322c33312c37362c3131312c3131302c3233342c3135332c39302c3230382c3139322c33312c3132342c39352c3130322c34392c3135382c39392c35322c3232302c3136352c39342c3235312c36382c36392c3132312c31362c3232342c3139345d2c22706f70223a5b3136382c35302c3233332c3139332c31352c3133362c36352c37322c3132332c3134382c3132392c3137362c33382c3139382c3230392c34372c32382c3230342c3137362c3134342c35372c3235312c34322c32382c36362c37362c38392c39372c3135382c36332c35342c3139382c3139342c3137362c3133352c3232312c31342c3138352c3139372c3232352c3230322c39382c3234332c37342c3233332c3232352c3134332c3135312c3134372c3137372c3137302c3131372c36362c3136352c36362c36322c33332c3231362c3233322c37352c36382c3131342c3139352c32322c3130302c36352c34342c3139382c342c3136362c3130322c3233332c3235332c3234302c35392c3137352c36302c3131372c3134322c3131342c3134302c3132322c31372c38372c3131302c3138372c312c31372c31302c3139352c3135342c31332c3234392c38362c35342c3232365d7d",
55+
"stake": 826
56+
}
57+
],
58+
"hash": "hash-123"
59+
}"#;
6360
let message: MithrilStakeDistributionMessage = serde_json::from_str(json).expect(
6461
"This JSON is expected to be succesfully parsed into a MithrilStakeDistributionMessage instance.",
6562
);
6663

64+
println!("{}", serde_json::to_string(&golden_message()).unwrap());
65+
6766
assert_eq!(golden_message(), message);
6867
}
6968
}

0 commit comments

Comments
 (0)