diff --git a/crates/rpc-client/Cargo.toml b/crates/rpc-client/Cargo.toml index bf37a5f9379..4c59b753157 100644 --- a/crates/rpc-client/Cargo.toml +++ b/crates/rpc-client/Cargo.toml @@ -52,6 +52,7 @@ alloy-transport-ws.workspace = true ci_info.workspace = true tempfile = "3" futures-util.workspace = true +similar-asserts.workspace = true [features] default = ["reqwest"] diff --git a/crates/rpc-client/src/builtin.rs b/crates/rpc-client/src/builtin.rs index f04265b91d7..a8752b3adb6 100644 --- a/crates/rpc-client/src/builtin.rs +++ b/crates/rpc-client/src/builtin.rs @@ -185,6 +185,7 @@ impl FromStr for BuiltInConnectionString { #[cfg(test)] mod test { use super::*; + use similar_asserts::assert_eq; use url::Url; #[test] diff --git a/crates/rpc-client/src/client.rs b/crates/rpc-client/src/client.rs index f4596574842..67f9ff97024 100644 --- a/crates/rpc-client/src/client.rs +++ b/crates/rpc-client/src/client.rs @@ -374,6 +374,7 @@ mod pubsub_impl { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn test_client_with_poll_interval() { diff --git a/crates/rpc-client/tests/it/http.rs b/crates/rpc-client/tests/it/http.rs index bc399ca3dfc..6e29b8ad16f 100644 --- a/crates/rpc-client/tests/it/http.rs +++ b/crates/rpc-client/tests/it/http.rs @@ -1,6 +1,7 @@ use alloy_node_bindings::Anvil; use alloy_primitives::U64; use alloy_rpc_client::{ClientBuilder, RpcCall}; +use similar_asserts::assert_eq; #[tokio::test] async fn it_makes_a_request() { diff --git a/crates/rpc-client/tests/it/ws.rs b/crates/rpc-client/tests/it/ws.rs index d1286b44180..b569775509d 100644 --- a/crates/rpc-client/tests/it/ws.rs +++ b/crates/rpc-client/tests/it/ws.rs @@ -2,6 +2,7 @@ use alloy_node_bindings::Anvil; use alloy_primitives::U64; use alloy_rpc_client::{ClientBuilder, RpcCall}; use alloy_transport_ws::WsConnect; +use similar_asserts::assert_eq; #[tokio::test] async fn it_makes_a_request() { diff --git a/crates/rpc-types-admin/Cargo.toml b/crates/rpc-types-admin/Cargo.toml index 55ec70f3a47..5eb62c6b233 100644 --- a/crates/rpc-types-admin/Cargo.toml +++ b/crates/rpc-types-admin/Cargo.toml @@ -24,3 +24,6 @@ alloy-primitives = { workspace = true, features = ["serde", "std"] } serde.workspace = true serde_json.workspace = true + +[dev-dependencies] +similar-asserts.workspace = true \ No newline at end of file diff --git a/crates/rpc-types-admin/src/admin.rs b/crates/rpc-types-admin/src/admin.rs index 65dc2af2f5d..4facfd2978b 100644 --- a/crates/rpc-types-admin/src/admin.rs +++ b/crates/rpc-types-admin/src/admin.rs @@ -257,6 +257,7 @@ mod handshake { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn deserialize_peer_info() { diff --git a/crates/rpc-types-anvil/Cargo.toml b/crates/rpc-types-anvil/Cargo.toml index e1df7bd9b41..5f925a25cf3 100644 --- a/crates/rpc-types-anvil/Cargo.toml +++ b/crates/rpc-types-anvil/Cargo.toml @@ -26,3 +26,4 @@ serde.workspace = true [dev-dependencies] serde_json.workspace = true +similar-asserts.workspace = true \ No newline at end of file diff --git a/crates/rpc-types-anvil/src/lib.rs b/crates/rpc-types-anvil/src/lib.rs index 553c6106cfb..87930cf9a9d 100644 --- a/crates/rpc-types-anvil/src/lib.rs +++ b/crates/rpc-types-anvil/src/lib.rs @@ -167,6 +167,7 @@ impl Default for MineOptions { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn test_serde_forking_deserialization() { diff --git a/crates/rpc-types-beacon/src/events/mod.rs b/crates/rpc-types-beacon/src/events/mod.rs index 8648a04730d..fac423d6af0 100644 --- a/crates/rpc-types-beacon/src/events/mod.rs +++ b/crates/rpc-types-beacon/src/events/mod.rs @@ -351,6 +351,7 @@ pub struct PayloadAttributesData { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn serde_payload_attributes_event() { diff --git a/crates/rpc-types-beacon/src/payload.rs b/crates/rpc-types-beacon/src/payload.rs index 3029755fc1d..43e7adde581 100644 --- a/crates/rpc-types-beacon/src/payload.rs +++ b/crates/rpc-types-beacon/src/payload.rs @@ -589,6 +589,7 @@ pub mod beacon_payload { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn serde_get_payload_header_response() { diff --git a/crates/rpc-types-beacon/src/relay.rs b/crates/rpc-types-beacon/src/relay.rs index 047412d46fd..9605cf3bbfd 100644 --- a/crates/rpc-types-beacon/src/relay.rs +++ b/crates/rpc-types-beacon/src/relay.rs @@ -427,6 +427,7 @@ pub mod error { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn serde_validator() { @@ -435,7 +436,7 @@ mod tests { let validators: Vec = serde_json::from_str(s).unwrap(); let json: serde_json::Value = serde_json::from_str(s).unwrap(); - similar_asserts::assert_eq!(json, serde_json::to_value(validators).unwrap()); + assert_eq!(json, serde_json::to_value(validators).unwrap()); } #[test] diff --git a/crates/rpc-types-beacon/src/sidecar.rs b/crates/rpc-types-beacon/src/sidecar.rs index b511436fde2..e805cd4709e 100644 --- a/crates/rpc-types-beacon/src/sidecar.rs +++ b/crates/rpc-types-beacon/src/sidecar.rs @@ -104,6 +104,7 @@ pub struct BlobData { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; /// Should deserialize json containing 6 blobs #[test] diff --git a/crates/rpc-types-engine/src/identification.rs b/crates/rpc-types-engine/src/identification.rs index e8fc9b348ba..a727248e0ff 100644 --- a/crates/rpc-types-engine/src/identification.rs +++ b/crates/rpc-types-engine/src/identification.rs @@ -96,6 +96,7 @@ pub struct ClientVersionV1 { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] #[cfg(feature = "serde")] diff --git a/crates/rpc-types-engine/src/jwt.rs b/crates/rpc-types-engine/src/jwt.rs index 697b2d3136e..9d61fcabd38 100644 --- a/crates/rpc-types-engine/src/jwt.rs +++ b/crates/rpc-types-engine/src/jwt.rs @@ -287,6 +287,7 @@ mod tests { use super::*; use assert_matches::assert_matches; use jsonwebtoken::{encode, EncodingKey, Header}; + use similar_asserts::assert_eq; #[cfg(feature = "std")] use std::time::{Duration, SystemTime, UNIX_EPOCH}; use tempfile::tempdir; diff --git a/crates/rpc-types-engine/src/payload.rs b/crates/rpc-types-engine/src/payload.rs index 86c030f9503..77c8633189d 100644 --- a/crates/rpc-types-engine/src/payload.rs +++ b/crates/rpc-types-engine/src/payload.rs @@ -1259,6 +1259,7 @@ impl std::error::Error for PayloadValidationError {} mod tests { use super::*; use alloc::vec; + use similar_asserts::assert_eq; #[test] #[cfg(feature = "serde")] @@ -1325,7 +1326,7 @@ mod tests { .to_string(), }, }; - similar_asserts::assert_eq!(q, serde_json::from_str(s).unwrap()); + assert_eq!(q, serde_json::from_str(s).unwrap()); } #[test] diff --git a/crates/rpc-types-eth/src/block.rs b/crates/rpc-types-eth/src/block.rs index 58b09b0a971..2a150fede93 100644 --- a/crates/rpc-types-eth/src/block.rs +++ b/crates/rpc-types-eth/src/block.rs @@ -393,6 +393,7 @@ mod tests { use alloy_primitives::keccak256; use arbitrary::Arbitrary; use rand::Rng; + use similar_asserts::assert_eq; use super::*; diff --git a/crates/rpc-types-eth/src/call.rs b/crates/rpc-types-eth/src/call.rs index 8ca950dad75..e971aabdfce 100644 --- a/crates/rpc-types-eth/src/call.rs +++ b/crates/rpc-types-eth/src/call.rs @@ -131,6 +131,7 @@ impl<'de> serde::Deserialize<'de> for TransactionIndex { mod tests { use super::*; use crate::BlockNumberOrTag; + use similar_asserts::assert_eq; #[test] #[cfg(feature = "serde")] diff --git a/crates/rpc-types-eth/src/filter.rs b/crates/rpc-types-eth/src/filter.rs index e1acdb707ee..8aa70329d04 100644 --- a/crates/rpc-types-eth/src/filter.rs +++ b/crates/rpc-types-eth/src/filter.rs @@ -1169,6 +1169,7 @@ impl<'a> serde::Deserialize<'a> for PendingTransactionFilterKind { mod tests { use super::*; use serde_json::json; + use similar_asserts::assert_eq; #[cfg(feature = "serde")] fn serialize(t: &T) -> serde_json::Value { @@ -1180,7 +1181,7 @@ mod tests { fn test_empty_filter_topics_list() { let s = r#"{"fromBlock": "0xfc359e", "toBlock": "0xfc359e", "topics": [["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"], [], ["0x0000000000000000000000000c17e776cd218252adfca8d4e761d3fe757e9778"]]}"#; let filter = serde_json::from_str::(s).unwrap(); - similar_asserts::assert_eq!( + assert_eq!( filter.topics, [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" @@ -1228,7 +1229,7 @@ mod tests { let s = r#"{"blockHash":"0x58dc57ab582b282c143424bd01e8d923cddfdcda9455bad02a29522f6274a948"}"#; let filter = serde_json::from_str::(s).unwrap(); - similar_asserts::assert_eq!( + assert_eq!( filter.block_option, FilterBlockOption::AtBlockHash( "0x58dc57ab582b282c143424bd01e8d923cddfdcda9455bad02a29522f6274a948" @@ -1243,7 +1244,7 @@ mod tests { fn test_filter_topics_middle_wildcard() { let s = r#"{"fromBlock": "0xfc359e", "toBlock": "0xfc359e", "topics": [["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"], [], [null, "0x0000000000000000000000000c17e776cd218252adfca8d4e761d3fe757e9778"]]}"#; let filter = serde_json::from_str::(s).unwrap(); - similar_asserts::assert_eq!( + assert_eq!( filter.topics, [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" diff --git a/crates/rpc-types-eth/src/index.rs b/crates/rpc-types-eth/src/index.rs index b1cd2c19b94..3757c7e9c70 100644 --- a/crates/rpc-types-eth/src/index.rs +++ b/crates/rpc-types-eth/src/index.rs @@ -85,6 +85,7 @@ mod tests { use super::*; use rand::{thread_rng, Rng}; use serde_json::json; + use similar_asserts::assert_eq; #[test] #[cfg(feature = "serde")] diff --git a/crates/rpc-types-eth/src/log.rs b/crates/rpc-types-eth/src/log.rs index 9c15b67230b..c9e8f2def6c 100644 --- a/crates/rpc-types-eth/src/log.rs +++ b/crates/rpc-types-eth/src/log.rs @@ -158,6 +158,7 @@ mod tests { use super::*; use arbitrary::Arbitrary; use rand::Rng; + use similar_asserts::assert_eq; #[test] fn log_arbitrary() { diff --git a/crates/rpc-types-eth/src/pubsub.rs b/crates/rpc-types-eth/src/pubsub.rs index 26606225504..0ac42ace838 100644 --- a/crates/rpc-types-eth/src/pubsub.rs +++ b/crates/rpc-types-eth/src/pubsub.rs @@ -171,6 +171,7 @@ impl<'a> serde::Deserialize<'a> for Params { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] #[cfg(feature = "serde")] diff --git a/crates/rpc-types-eth/src/simulate.rs b/crates/rpc-types-eth/src/simulate.rs index 4615fab86f2..19d33bca844 100644 --- a/crates/rpc-types-eth/src/simulate.rs +++ b/crates/rpc-types-eth/src/simulate.rs @@ -157,6 +157,7 @@ mod tests { use super::*; use alloy_primitives::{Address, TxKind}; use serde_json::json; + use similar_asserts::assert_eq; #[test] #[cfg(feature = "serde")] diff --git a/crates/rpc-types-eth/src/state.rs b/crates/rpc-types-eth/src/state.rs index 4c53d664139..c8d575caf0a 100644 --- a/crates/rpc-types-eth/src/state.rs +++ b/crates/rpc-types-eth/src/state.rs @@ -109,6 +109,7 @@ impl EvmOverrides { mod tests { use super::*; use alloy_primitives::address; + use similar_asserts::assert_eq; #[test] fn test_default_account_override() { diff --git a/crates/rpc-types-eth/src/transaction/mod.rs b/crates/rpc-types-eth/src/transaction/mod.rs index dc76c841024..379c75b5e64 100644 --- a/crates/rpc-types-eth/src/transaction/mod.rs +++ b/crates/rpc-types-eth/src/transaction/mod.rs @@ -439,6 +439,7 @@ mod tests { use arbitrary::Arbitrary; use core::str::FromStr; use rand::Rng; + use similar_asserts::assert_eq; #[test] fn arbitrary_transaction() { diff --git a/crates/rpc-types-eth/src/transaction/receipt.rs b/crates/rpc-types-eth/src/transaction/receipt.rs index 237d6f95894..8b4f7067abb 100644 --- a/crates/rpc-types-eth/src/transaction/receipt.rs +++ b/crates/rpc-types-eth/src/transaction/receipt.rs @@ -216,6 +216,7 @@ mod test { use alloy_primitives::{address, b256, bloom, Bloom}; use arbitrary::Arbitrary; use rand::Rng; + use similar_asserts::assert_eq; #[test] fn transaction_receipt_arbitrary() { diff --git a/crates/rpc-types-eth/src/transaction/request.rs b/crates/rpc-types-eth/src/transaction/request.rs index b64e0d74fcb..52190810cf3 100644 --- a/crates/rpc-types-eth/src/transaction/request.rs +++ b/crates/rpc-types-eth/src/transaction/request.rs @@ -1045,6 +1045,7 @@ mod tests { use alloy_primitives::b256; use alloy_serde::WithOtherFields; use assert_matches::assert_matches; + use similar_asserts::assert_eq; // #[test] diff --git a/crates/rpc-types-eth/src/transaction/signature.rs b/crates/rpc-types-eth/src/transaction/signature.rs index ef631380938..9d7cfdb4dd0 100644 --- a/crates/rpc-types-eth/src/transaction/signature.rs +++ b/crates/rpc-types-eth/src/transaction/signature.rs @@ -102,6 +102,7 @@ impl From for Signature { mod tests { use super::*; use core::str::FromStr; + use similar_asserts::assert_eq; #[test] #[cfg(feature = "serde")] diff --git a/crates/rpc-types-mev/Cargo.toml b/crates/rpc-types-mev/Cargo.toml index 58fb3e4dd3e..0466d7da357 100644 --- a/crates/rpc-types-mev/Cargo.toml +++ b/crates/rpc-types-mev/Cargo.toml @@ -23,5 +23,8 @@ alloy-serde.workspace = true serde.workspace = true serde_json.workspace = true +[dev-dependencies] +similar-asserts.workspace = true + [lints] workspace = true diff --git a/crates/rpc-types-mev/src/mev_calls.rs b/crates/rpc-types-mev/src/mev_calls.rs index 688970f0196..638647f948b 100644 --- a/crates/rpc-types-mev/src/mev_calls.rs +++ b/crates/rpc-types-mev/src/mev_calls.rs @@ -178,6 +178,7 @@ mod tests { use crate::{common::PrivacyHint, RefundConfig}; use alloy_primitives::Bytes; + use similar_asserts::assert_eq; use super::*; diff --git a/crates/rpc-types-mev/src/stats.rs b/crates/rpc-types-mev/src/stats.rs index 74529d46543..10eb682328f 100644 --- a/crates/rpc-types-mev/src/stats.rs +++ b/crates/rpc-types-mev/src/stats.rs @@ -131,6 +131,7 @@ pub struct UserStats { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; use crate::SealedByBuildersAt; diff --git a/crates/rpc-types-trace/src/common.rs b/crates/rpc-types-trace/src/common.rs index 76363a17c6b..e85f1a9cc50 100644 --- a/crates/rpc-types-trace/src/common.rs +++ b/crates/rpc-types-trace/src/common.rs @@ -77,6 +77,7 @@ impl TraceResult { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] struct OkResult { diff --git a/crates/rpc-types-trace/src/filter.rs b/crates/rpc-types-trace/src/filter.rs index 3f6e64c178d..6c02afe6d74 100644 --- a/crates/rpc-types-trace/src/filter.rs +++ b/crates/rpc-types-trace/src/filter.rs @@ -198,6 +198,7 @@ mod tests { use super::*; use alloy_primitives::{Bytes, U256}; use serde_json::json; + use similar_asserts::assert_eq; #[test] fn test_parse_filter() { diff --git a/crates/rpc-types-trace/src/geth/call.rs b/crates/rpc-types-trace/src/geth/call.rs index 52e52a6341c..2c22d993d16 100644 --- a/crates/rpc-types-trace/src/geth/call.rs +++ b/crates/rpc-types-trace/src/geth/call.rs @@ -125,6 +125,7 @@ impl FlatCallConfig { mod tests { use super::*; use crate::geth::*; + use similar_asserts::assert_eq; // See const DEFAULT: &str = include_str!("../../test_data/call_tracer/default.json"); diff --git a/crates/rpc-types-trace/src/geth/four_byte.rs b/crates/rpc-types-trace/src/geth/four_byte.rs index e5de66fa0b4..8527971b68d 100644 --- a/crates/rpc-types-trace/src/geth/four_byte.rs +++ b/crates/rpc-types-trace/src/geth/four_byte.rs @@ -13,6 +13,7 @@ pub struct FourByteFrame(pub BTreeMap); mod tests { use super::*; use crate::geth::*; + use similar_asserts::assert_eq; const DEFAULT: &str = r#"{ "0x27dc297e-128": 1, diff --git a/crates/rpc-types-trace/src/geth/mod.rs b/crates/rpc-types-trace/src/geth/mod.rs index 48cee5bc61c..5702a64473c 100644 --- a/crates/rpc-types-trace/src/geth/mod.rs +++ b/crates/rpc-types-trace/src/geth/mod.rs @@ -666,6 +666,7 @@ fn serialize_string_storage_map_opt( #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn test_tracer_config() { @@ -724,7 +725,7 @@ mod tests { let log: StructLog = serde_json::from_str(s).unwrap(); let val = serde_json::to_value(&log).unwrap(); let input = serde_json::from_str::(s).unwrap(); - similar_asserts::assert_eq!(input, val); + assert_eq!(input, val); } #[test] @@ -752,7 +753,7 @@ mod tests { let de = serde_json::to_value(&result).unwrap(); let val = serde_json::from_str::(s).unwrap(); - similar_asserts::assert_eq!(val, de); + assert_eq!(val, de); } #[test] diff --git a/crates/rpc-types-trace/src/geth/mux.rs b/crates/rpc-types-trace/src/geth/mux.rs index fd79900c4a3..1714b32c8c3 100644 --- a/crates/rpc-types-trace/src/geth/mux.rs +++ b/crates/rpc-types-trace/src/geth/mux.rs @@ -17,6 +17,7 @@ pub struct MuxFrame(pub HashMap); mod tests { use super::*; use crate::geth::*; + use similar_asserts::assert_eq; const FOUR_BYTE_FRAME: &str = r#"{ "0x27dc297e-128": 1, diff --git a/crates/rpc-types-trace/src/geth/noop.rs b/crates/rpc-types-trace/src/geth/noop.rs index 40e546f825e..6f86e336da6 100644 --- a/crates/rpc-types-trace/src/geth/noop.rs +++ b/crates/rpc-types-trace/src/geth/noop.rs @@ -13,6 +13,7 @@ pub struct NoopFrame(BTreeMap<(), ()>); mod tests { use super::*; use crate::geth::*; + use similar_asserts::assert_eq; const DEFAULT: &str = r"{}"; diff --git a/crates/rpc-types-trace/src/geth/pre_state.rs b/crates/rpc-types-trace/src/geth/pre_state.rs index 481f4949927..4202228b64d 100644 --- a/crates/rpc-types-trace/src/geth/pre_state.rs +++ b/crates/rpc-types-trace/src/geth/pre_state.rs @@ -231,6 +231,7 @@ impl PreStateConfig { mod tests { use super::*; use crate::geth::*; + use similar_asserts::assert_eq; // See const DEFAULT: &str = include_str!("../../test_data/pre_state_tracer/default.json"); diff --git a/crates/rpc-types-trace/src/otterscan.rs b/crates/rpc-types-trace/src/otterscan.rs index e44c968faad..eef4534231e 100644 --- a/crates/rpc-types-trace/src/otterscan.rs +++ b/crates/rpc-types-trace/src/otterscan.rs @@ -255,6 +255,7 @@ pub struct ContractCreator { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn test_otterscan_receipt() { diff --git a/crates/rpc-types-trace/src/parity.rs b/crates/rpc-types-trace/src/parity.rs index c005d4df105..ea5186f026c 100644 --- a/crates/rpc-types-trace/src/parity.rs +++ b/crates/rpc-types-trace/src/parity.rs @@ -589,6 +589,7 @@ pub struct StorageDelta { mod tests { use super::*; use serde_json::{json, Value}; + use similar_asserts::assert_eq; use std::str::FromStr; #[test] @@ -637,10 +638,10 @@ mod tests { let json = serde_json::to_value(val.clone()).unwrap(); let expect = serde_json::from_str::(input).unwrap(); - similar_asserts::assert_eq!(json, expect); + assert_eq!(json, expect); let s = serde_json::to_string(&val).unwrap(); let json = serde_json::from_str::(&s).unwrap(); - similar_asserts::assert_eq!(json, expect); + assert_eq!(json, expect); let input = input.replace("suicide", "selfdestruct"); let val = serde_json::from_str::(&input).unwrap(); @@ -754,12 +755,10 @@ mod tests { let serialized = serde_json::to_string(&test_case.trace).unwrap(); let actual_json: Value = serde_json::from_str(&serialized).unwrap(); - similar_asserts::assert_eq!( - actual_json, - test_case.expected_json, + assert_eq!( + actual_json, test_case.expected_json, "Test case {} failed; Trace: {:?}", - i, - test_case.trace + i, test_case.trace ); } } @@ -791,7 +790,7 @@ mod tests { let trace: LocalizedTransactionTrace = serde_json::from_str(reference_data).unwrap(); assert!(trace.trace.action.is_call()); let serialized = serde_json::to_string_pretty(&trace).unwrap(); - similar_asserts::assert_eq!(serialized, reference_data); + assert_eq!(serialized, reference_data); } #[test] @@ -818,7 +817,7 @@ mod tests { let trace: LocalizedTransactionTrace = serde_json::from_str(reference_data).unwrap(); assert!(trace.trace.action.is_selfdestruct()); let serialized = serde_json::to_string_pretty(&trace).unwrap(); - similar_asserts::assert_eq!(serialized, reference_data); + assert_eq!(serialized, reference_data); } #[test] diff --git a/crates/rpc-types-txpool/src/txpool.rs b/crates/rpc-types-txpool/src/txpool.rs index 31ae76f63dd..447fcf61c44 100644 --- a/crates/rpc-types-txpool/src/txpool.rs +++ b/crates/rpc-types-txpool/src/txpool.rs @@ -178,6 +178,7 @@ pub struct TxpoolStatus { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn serde_txpool_content() { @@ -352,11 +353,8 @@ mod tests { let origin: serde_json::Value = serde_json::from_str(txpool_content_json).unwrap(); let serialized_value = serde_json::to_value(deserialized.clone()).unwrap(); - similar_asserts::assert_eq!(origin, serialized_value); - similar_asserts::assert_eq!( - deserialized, - serde_json::from_str::(&serialized).unwrap() - ); + assert_eq!(origin, serialized_value); + assert_eq!(deserialized, serde_json::from_str::(&serialized).unwrap()); } #[test] diff --git a/crates/rpc-types/Cargo.toml b/crates/rpc-types/Cargo.toml index 56a85a64d8d..57bdd38a658 100644 --- a/crates/rpc-types/Cargo.toml +++ b/crates/rpc-types/Cargo.toml @@ -34,6 +34,7 @@ serde = { workspace = true, features = ["derive", "std"] } [dev-dependencies] serde_json.workspace = true +similar-asserts.workspace = true [features] default = [ diff --git a/crates/rpc-types/src/rpc.rs b/crates/rpc-types/src/rpc.rs index 07da2c09c16..0ae26e215ca 100644 --- a/crates/rpc-types/src/rpc.rs +++ b/crates/rpc-types/src/rpc.rs @@ -26,6 +26,7 @@ impl RpcModules { #[cfg(test)] mod tests { use super::*; + use similar_asserts::assert_eq; #[test] fn test_parse_module_versions_roundtrip() { let s = r#"{"txpool":"1.0","trace":"1.0","eth":"1.0","web3":"1.0","net":"1.0"}"#; diff --git a/crates/serde/src/other/mod.rs b/crates/serde/src/other/mod.rs index f52845ec208..8fec656ba1a 100644 --- a/crates/serde/src/other/mod.rs +++ b/crates/serde/src/other/mod.rs @@ -235,6 +235,7 @@ where mod tests { use super::*; use rand::Rng; + use similar_asserts::assert_eq; #[test] fn other_fields_arbitrary() { @@ -259,8 +260,8 @@ mod tests { let with_other: WithOtherFields = serde_json::from_str("{\"a\": 1, \"b\": 2}").unwrap(); - similar_asserts::assert_eq!(with_other.inner.inner.a, 1); - similar_asserts::assert_eq!( + assert_eq!(with_other.inner.inner.a, 1); + assert_eq!( with_other.other, OtherFields::new(BTreeMap::from_iter([("b".to_string(), serde_json::json!(2))])) );