fix: quote tests

This commit is contained in:
DaniPopes 2023-02-24 22:07:44 +01:00
parent dcd1ef2eda
commit e06fcd4fd3
No known key found for this signature in database
GPG Key ID: 0F09640DDB7AC692
2 changed files with 15 additions and 26 deletions

View File

@ -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>,
M,
TransferEventFilter,
> {
) -> ::ethers_contract::builders::Event<::std::sync::Arc<M>, 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>, 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,
])
},
);

View File

@ -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(),
)
};
}