From e06fcd4fd33eb79d8ede2ae022e3d035eac978ac Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 24 Feb 2023 22:07:44 +0100 Subject: [PATCH] fix: quote tests --- .../src/contract/events.rs | 36 ++++++------------- .../ethers-contract-abigen/src/test/macros.rs | 5 ++- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/ethers-contract/ethers-contract-abigen/src/contract/events.rs b/ethers-contract/ethers-contract-abigen/src/contract/events.rs index 7076dd73..c0edd2f5 100644 --- a/ethers-contract/ethers-contract-abigen/src/contract/events.rs +++ b/ethers-contract/ethers-contract-abigen/src/contract/events.rs @@ -254,44 +254,30 @@ mod tests { } #[test] - #[rustfmt::skip] fn expand_transfer_filter_with_alias() { let event = Event { name: "Transfer".into(), inputs: vec![ - EventParam { - name: "from".into(), - kind: ParamType::Address, - indexed: true, - }, - EventParam { - name: "to".into(), - kind: ParamType::Address, - indexed: true, - }, - EventParam { - name: "amount".into(), - kind: ParamType::Uint(256), - indexed: false, - }, + EventParam { name: "from".into(), kind: ParamType::Address, indexed: true }, + EventParam { name: "to".into(), kind: ParamType::Address, indexed: true }, + EventParam { name: "amount".into(), kind: ParamType::Uint(256), indexed: false }, ], anonymous: false, }; let sig = "Transfer(address,address,uint256)"; let cx = test_context_with_alias(sig, "TransferEvent"); + #[rustfmt::skip] assert_quote!(cx.expand_filter(&event), { #[doc = "Gets the contract's `Transfer` event"] pub fn transfer_event_filter( &self - ) -> ::ethers_contract::builders::Event< - ::std::sync::Arc, - M, - TransferEventFilter, - > { + ) -> ::ethers_contract::builders::Event<::std::sync::Arc, M, TransferEventFilter> + { self.0.event() } }); } + #[test] fn expand_transfer_filter() { let event = Event { @@ -304,10 +290,11 @@ mod tests { anonymous: false, }; let cx = test_context(); + #[rustfmt::skip] assert_quote!(cx.expand_filter(&event), { #[doc = "Gets the contract's `Transfer` event"] pub fn transfer_filter( - &self, + &self ) -> ::ethers_contract::builders::Event<::std::sync::Arc, M, TransferFilter> { self.0.event() @@ -408,7 +395,6 @@ mod tests { } #[test] - #[rustfmt::skip] fn expand_hash_value() { assert_quote!( expand_hash( @@ -416,8 +402,8 @@ mod tests { ), { ::ethers_core::types::H256([ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, ]) }, ); diff --git a/ethers-contract/ethers-contract-abigen/src/test/macros.rs b/ethers-contract/ethers-contract-abigen/src/test/macros.rs index 467f89e9..a31008af 100644 --- a/ethers-contract/ethers-contract-abigen/src/test/macros.rs +++ b/ethers-contract/ethers-contract-abigen/src/test/macros.rs @@ -5,6 +5,9 @@ /// If the expanded source does not match the quoted source. macro_rules! assert_quote { ($ex:expr, { $($t:tt)* } $(,)?) => { - assert_eq!($ex.to_string(), quote::quote! { $($t)* }.to_string()) + assert_eq!( + $ex.to_string(), + quote::quote! { $($t)* }.to_string(), + ) }; }