mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-04-23 17:48:03 +00:00
remove a few unnecessary structs
This commit is contained in:
@@ -47,11 +47,11 @@ pub enum Payload {
|
||||
#[serde(rename = "afg.finalized")]
|
||||
AfgFinalized(AfgFinalized),
|
||||
#[serde(rename = "afg.received_precommit")]
|
||||
AfgReceivedPrecommit(AfgReceivedPrecommit),
|
||||
AfgReceivedPrecommit(AfgReceived),
|
||||
#[serde(rename = "afg.received_prevote")]
|
||||
AfgReceivedPrevote(AfgReceivedPrevote),
|
||||
AfgReceivedPrevote(AfgReceived),
|
||||
#[serde(rename = "afg.received_commit")]
|
||||
AfgReceivedCommit(AfgReceivedCommit),
|
||||
AfgReceivedCommit(AfgReceived),
|
||||
#[serde(rename = "afg.authority_set")]
|
||||
AfgAuthoritySet(AfgAuthoritySet),
|
||||
#[serde(rename = "afg.finalized_blocks_up_to")]
|
||||
@@ -109,24 +109,6 @@ pub struct AfgReceived {
|
||||
pub voter: Option<Box<str>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
pub struct AfgReceivedPrecommit {
|
||||
#[serde(flatten)]
|
||||
pub received: AfgReceived,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
pub struct AfgReceivedPrevote {
|
||||
#[serde(flatten)]
|
||||
pub received: AfgReceived,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
pub struct AfgReceivedCommit {
|
||||
#[serde(flatten)]
|
||||
pub received: AfgReceived,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy)]
|
||||
pub struct Block {
|
||||
#[serde(rename = "best")]
|
||||
@@ -189,4 +171,53 @@ mod tests {
|
||||
"message did not match variant V2",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn message_v2_received_precommit() {
|
||||
let json = r#"{
|
||||
"id":1,
|
||||
"ts":"2021-01-13T12:22:20.053527101+01:00",
|
||||
"payload":{
|
||||
"target_hash":"0xcc41708573f2acaded9dd75e07dac2d4163d136ca35b3061c558d7a35a09dd8d",
|
||||
"target_number":"209",
|
||||
"voter":"foo",
|
||||
"msg":"afg.received_precommit"
|
||||
}
|
||||
}"#;
|
||||
assert!(
|
||||
matches!(
|
||||
serde_json::from_str::<NodeMessage>(json).unwrap(),
|
||||
NodeMessage::V2 {
|
||||
payload: Payload::AfgReceivedPrecommit(..),
|
||||
..
|
||||
},
|
||||
),
|
||||
"message did not match the expected output",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn message_v2_tx_pool_import() {
|
||||
// We should happily ignore any fields we don't care about.
|
||||
let json = r#"{
|
||||
"id":1,
|
||||
"ts":"2021-01-13T12:22:20.053527101+01:00",
|
||||
"payload":{
|
||||
"foo":"Something",
|
||||
"bar":123,
|
||||
"wibble":"wobble",
|
||||
"msg":"txpool.import"
|
||||
}
|
||||
}"#;
|
||||
assert!(
|
||||
matches!(
|
||||
serde_json::from_str::<NodeMessage>(json).unwrap(),
|
||||
NodeMessage::V2 {
|
||||
payload: Payload::TxPoolImport,
|
||||
..
|
||||
},
|
||||
),
|
||||
"message did not match the expected output",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ impl From<json::Payload> for Payload {
|
||||
Payload::AfgFinalized(m.into())
|
||||
},
|
||||
json::Payload::AfgReceivedPrecommit(m) => {
|
||||
Payload::AfgReceivedPrecommit(m.received.into())
|
||||
Payload::AfgReceivedPrecommit(m.into())
|
||||
},
|
||||
json::Payload::AfgReceivedPrevote(m) => {
|
||||
Payload::AfgReceivedPrevote(m.received.into())
|
||||
Payload::AfgReceivedPrevote(m.into())
|
||||
},
|
||||
json::Payload::AfgReceivedCommit(m) => {
|
||||
Payload::AfgReceivedCommit(m.received.into())
|
||||
Payload::AfgReceivedCommit(m.into())
|
||||
},
|
||||
json::Payload::AfgAuthoritySet(m) => {
|
||||
Payload::AfgAuthoritySet(m.into())
|
||||
|
||||
Reference in New Issue
Block a user