diff --git a/swap/src/lib.rs b/swap/src/lib.rs index 1d45a8df..b71d005f 100644 --- a/swap/src/lib.rs +++ b/swap/src/lib.rs @@ -9,7 +9,6 @@ pub mod bob; pub mod cli; pub mod monero; pub mod network; -pub mod serde; pub mod state; pub mod storage; pub mod trace; diff --git a/swap/src/serde.rs b/swap/src/serde.rs deleted file mode 100644 index 754946bd..00000000 --- a/swap/src/serde.rs +++ /dev/null @@ -1,47 +0,0 @@ -pub mod peer_id { - use libp2p::PeerId; - use serde::{de::Error, Deserialize, Deserializer, Serializer}; - - pub fn serialize(peer_id: &PeerId, serializer: S) -> Result - where - S: Serializer, - { - let string = peer_id.to_string(); - serializer.serialize_str(&string) - } - - #[allow(dead_code)] - pub fn deserialize<'de, D>(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let string = String::deserialize(deserializer)?; - let peer_id = string.parse().map_err(D::Error::custom)?; - - Ok(peer_id) - } - - #[cfg(test)] - mod tests { - use super::*; - use serde::Serialize; - use spectral::prelude::*; - - #[derive(Serialize)] - struct SerializablePeerId(#[serde(with = "super")] PeerId); - - #[test] - fn maker_id_serializes_as_expected() { - let peer_id = SerializablePeerId( - "QmfUfpC2frwFvcDzpspnfZitHt5wct6n4kpG5jzgRdsxkY" - .parse() - .unwrap(), - ); - - let got = serde_json::to_string(&peer_id).expect("failed to serialize peer id"); - - assert_that(&got) - .is_equal_to(r#""QmfUfpC2frwFvcDzpspnfZitHt5wct6n4kpG5jzgRdsxkY""#.to_string()); - } - } -}