Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace assert_eq! with similar_asserts::assert_eq! (serde json) #1433

Closed
wants to merge 0 commits into from

Conversation

0xriazaka
Copy link
Contributor

@0xriazaka 0xriazaka commented Oct 4, 2024

Motivation

similar_asserts::assert_eq! highlights the exact differences between test subjects

Solution

Use similar_asserts for serde JSON comparison in rpc crates
Closes #1362

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@@ -283,7 +283,7 @@ mod tests {
}"#;
let peer_info: PeerInfo = serde_json::from_str(response).unwrap();

assert_eq!(peer_info.enode, "enode://bb37b7302f79e47c1226d6e3ccf0ef6d51146019efdcc1f6e861fd1c1a78d5e84e486225a6a8a503b93d5c50125ee980835c92bde7f7d12f074c16f4e439a578@127.0.0.1:60872");
similar_asserts::assert_eq!(peer_info.enode, "enode://bb37b7302f79e47c1226d6e3ccf0ef6d51146019efdcc1f6e861fd1c1a78d5e84e486225a6a8a503b93d5c50125ee980835c92bde7f7d12f074c16f4e439a578@127.0.0.1:60872");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if you imported it (use similar_asserts::assert_eq at the top of the test module) and kept the call sites the same

Copy link
Contributor Author

@0xriazaka 0xriazaka Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using "use similar_asserts::assert_eq" at the test module level would affect all assert_eq! calls, not just those related to serde JSON

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind, this macro's output is always better @mattsse

Copy link
Contributor Author

@0xriazaka 0xriazaka Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, wanna make this macro on every test module?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Replace assert_eq! with similar_asserts::assert_eq!
2 participants