From afafe790bbf5a868db8ddaee6bf307ab58182aa3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 24 Jan 2024 13:33:46 +0100 Subject: [PATCH] test: use similar-asserts instead of pretty-assertions (#6208) --- Cargo.lock | 28 ++----------------- Cargo.toml | 1 + bin/reth/Cargo.toml | 2 +- .../commands/debug_cmd/in_memory_merkle.rs | 4 +-- bin/reth/src/commands/debug_cmd/merkle.rs | 4 +-- crates/rpc/rpc-testing-util/Cargo.toml | 2 +- crates/rpc/rpc-types/Cargo.toml | 2 +- crates/storage/codecs/derive/Cargo.toml | 2 +- .../storage/codecs/derive/src/compact/mod.rs | 2 +- crates/trie/Cargo.toml | 2 +- crates/trie/src/proof.rs | 8 +++--- 11 files changed, 18 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49dee9511f..0413174295 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1423,10 +1423,10 @@ version = "0.1.0-alpha.16" dependencies = [ "convert_case 0.6.0", "parity-scale-codec", - "pretty_assertions", "proc-macro2", "quote", "serde", + "similar-asserts", "syn 2.0.48", ] @@ -2060,12 +2060,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "diff" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" - [[package]] name = "difflib" version = "0.4.0" @@ -5228,16 +5222,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "pretty_assertions" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" -dependencies = [ - "diff", - "yansi", -] - [[package]] name = "prettyplease" version = "0.2.16" @@ -5749,7 +5733,6 @@ dependencies = [ "metrics-util", "once_cell", "pin-project", - "pretty_assertions", "proptest", "rand 0.8.5", "ratatui", @@ -5795,6 +5778,7 @@ dependencies = [ "secp256k1 0.27.0", "serde", "serde_json", + "similar-asserts", "tempfile", "tokio", "toml 0.8.8", @@ -6961,7 +6945,6 @@ dependencies = [ "criterion", "derive_more", "once_cell", - "pretty_assertions", "proptest", "reth-db", "reth-interfaces", @@ -6969,6 +6952,7 @@ dependencies = [ "reth-provider", "revm", "serde_json", + "similar-asserts", "thiserror", "tokio", "tokio-stream", @@ -9457,12 +9441,6 @@ dependencies = [ "xml-rs", ] -[[package]] -name = "yansi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" - [[package]] name = "yoke" version = "0.7.3" diff --git a/Cargo.toml b/Cargo.toml index 069479ff3c..1461d5a3ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -258,6 +258,7 @@ pprof = "0.13" proptest = "1.4" proptest-derive = "0.4" serial_test = "2" +similar-asserts = "1.5.0" [workspace.metadata.cargo-udeps.ignore] # ignored because this is mutually exclusive with the optimism payload builder via feature flags diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 682f2986fe..71b3bdb035 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -105,7 +105,7 @@ eyre.workspace = true clap = { workspace = true, features = ["derive"] } tempfile.workspace = true backon = "0.4" -pretty_assertions = "1.3.0" +similar-asserts.workspace = true humantime = "2.1.0" itertools.workspace = true rayon.workspace = true diff --git a/bin/reth/src/commands/debug_cmd/in_memory_merkle.rs b/bin/reth/src/commands/debug_cmd/in_memory_merkle.rs index 3e1f2bff61..50dc6bbe38 100644 --- a/bin/reth/src/commands/debug_cmd/in_memory_merkle.rs +++ b/bin/reth/src/commands/debug_cmd/in_memory_merkle.rs @@ -233,7 +233,7 @@ impl Command { while in_mem_updates_iter.peek().is_some() || incremental_updates_iter.peek().is_some() { match (in_mem_updates_iter.next(), incremental_updates_iter.next()) { (Some(in_mem), Some(incr)) => { - pretty_assertions::assert_eq!(in_mem.0, incr.0, "Nibbles don't match"); + similar_asserts::assert_eq!(in_mem.0, incr.0, "Nibbles don't match"); if in_mem.1 != incr.1 && matches!(in_mem.0, TrieKey::AccountNode(ref nibbles) if nibbles.0.len() > self.skip_node_depth.unwrap_or_default()) { @@ -253,7 +253,7 @@ impl Command { } } - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( incremental_mismatched, in_mem_mismatched, "Mismatched trie updates" diff --git a/bin/reth/src/commands/debug_cmd/merkle.rs b/bin/reth/src/commands/debug_cmd/merkle.rs index e8a2c26dd6..2abcf8fe81 100644 --- a/bin/reth/src/commands/debug_cmd/merkle.rs +++ b/bin/reth/src/commands/debug_cmd/merkle.rs @@ -311,7 +311,7 @@ impl Command { { match (incremental_account_trie_iter.next(), clean_account_trie_iter.next()) { (Some(incremental), Some(clean)) => { - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( incremental.0, clean.0, "Nibbles don't match" @@ -364,7 +364,7 @@ impl Command { } } - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( ( incremental_account_mismatched, first_mismatched_storage.as_ref().map(|(incremental, _)| incremental) diff --git a/crates/rpc/rpc-testing-util/Cargo.toml b/crates/rpc/rpc-testing-util/Cargo.toml index af72a3c71d..d2c69c384e 100644 --- a/crates/rpc/rpc-testing-util/Cargo.toml +++ b/crates/rpc/rpc-testing-util/Cargo.toml @@ -27,7 +27,7 @@ serde_json.workspace = true # assertions -similar-asserts = "1.5.0" +similar-asserts.workspace = true [dev-dependencies] diff --git a/crates/rpc/rpc-types/Cargo.toml b/crates/rpc/rpc-types/Cargo.toml index cbe1c51b07..7bd02b678f 100644 --- a/crates/rpc/rpc-types/Cargo.toml +++ b/crates/rpc/rpc-types/Cargo.toml @@ -53,4 +53,4 @@ arbitrary = { workspace = true, features = ["derive"] } proptest.workspace = true proptest-derive.workspace = true rand.workspace = true -similar-asserts = "1.4" +similar-asserts.workspace = true diff --git a/crates/storage/codecs/derive/Cargo.toml b/crates/storage/codecs/derive/Cargo.toml index 1fe4a6a062..8238871874 100644 --- a/crates/storage/codecs/derive/Cargo.toml +++ b/crates/storage/codecs/derive/Cargo.toml @@ -33,7 +33,7 @@ serde = { workspace = true, default-features = false } parity-scale-codec = { version = "3.2.1", features = ["derive", "bytes"] } [dev-dependencies] -pretty_assertions = "1.3.0" +similar-asserts.workspace = true [features] default = ["compact"] diff --git a/crates/storage/codecs/derive/src/compact/mod.rs b/crates/storage/codecs/derive/src/compact/mod.rs index 701ec8d890..41b4ccfc55 100644 --- a/crates/storage/codecs/derive/src/compact/mod.rs +++ b/crates/storage/codecs/derive/src/compact/mod.rs @@ -182,7 +182,7 @@ pub fn is_flag_type(ftype: &str) -> bool { #[cfg(test)] mod tests { use super::*; - use pretty_assertions::assert_eq; + use similar_asserts::assert_eq; use syn::parse2; #[test] diff --git a/crates/trie/Cargo.toml b/crates/trie/Cargo.toml index 5a2f518f3e..4f51f80512 100644 --- a/crates/trie/Cargo.toml +++ b/crates/trie/Cargo.toml @@ -49,7 +49,7 @@ tokio = { workspace = true, default-features = false, features = ["sync", "rt", tokio-stream.workspace = true once_cell.workspace = true serde_json.workspace = true -pretty_assertions = "1.3.0" +similar-asserts.workspace = true criterion.workspace = true [features] diff --git a/crates/trie/src/proof.rs b/crates/trie/src/proof.rs index 726bed4677..e080a5ee7f 100644 --- a/crates/trie/src/proof.rs +++ b/crates/trie/src/proof.rs @@ -285,7 +285,7 @@ mod tests { for (target, expected_proof) in data { let target = Address::from_str(target).unwrap(); let account_proof = Proof::new(provider.tx_ref()).account_proof(target, &[]).unwrap(); - pretty_assertions::assert_eq!( + similar_asserts::assert_eq!( account_proof.proof, expected_proof, "proof for {target:?} does not match" @@ -333,7 +333,7 @@ mod tests { let provider = factory.provider().unwrap(); let account_proof = Proof::new(provider.tx_ref()).account_proof(target, &[]).unwrap(); - pretty_assertions::assert_eq!(account_proof.proof, expected_account_proof); + similar_asserts::assert_eq!(account_proof.proof, expected_account_proof); } #[test] @@ -355,7 +355,7 @@ mod tests { let provider = factory.provider().unwrap(); let account_proof = Proof::new(provider.tx_ref()).account_proof(target, &[]).unwrap(); - pretty_assertions::assert_eq!(account_proof.proof, expected_account_proof); + similar_asserts::assert_eq!(account_proof.proof, expected_account_proof); } #[test] @@ -440,6 +440,6 @@ mod tests { let provider = factory.provider().unwrap(); let account_proof = Proof::new(provider.tx_ref()).account_proof(target, &slots).unwrap(); - pretty_assertions::assert_eq!(account_proof, expected); + similar_asserts::assert_eq!(account_proof, expected); } }