event_scanner/test_utils/
types.rs1use alloy::sol_types::SolEvent;
2
3use crate::Message;
4
5#[derive(Debug)]
6pub struct LogMetadata<E: SolEvent> {
7 pub event: E,
8 pub address: alloy::primitives::Address,
9 pub tx_hash: alloy::primitives::B256,
10}
11
12impl<E: SolEvent> PartialEq<Vec<LogMetadata<E>>> for Message {
13 fn eq(&self, other: &Vec<LogMetadata<E>>) -> bool {
14 self.eq(&other.as_slice())
15 }
16}
17
18impl<E: SolEvent> PartialEq<&Vec<LogMetadata<E>>> for Message {
19 fn eq(&self, other: &&Vec<LogMetadata<E>>) -> bool {
20 self.eq(&other.as_slice())
21 }
22}
23
24impl<E: SolEvent, const N: usize> PartialEq<&[LogMetadata<E>; N]> for Message {
25 fn eq(&self, other: &&[LogMetadata<E>; N]) -> bool {
26 self.eq(&other.as_slice())
27 }
28}
29
30impl<E: SolEvent> PartialEq<&[LogMetadata<E>]> for Message {
31 fn eq(&self, other: &&[LogMetadata<E>]) -> bool {
32 if let Message::Data(logs) = self {
33 let log_data = logs
34 .iter()
35 .map(|l| {
36 let address = l.address();
37 let tx_hash = l.transaction_hash.unwrap();
38 (l.inner.data.clone(), address, tx_hash)
39 })
40 .collect::<Vec<_>>();
41 let expected = other
42 .iter()
43 .map(|e| (e.event.encode_log_data(), e.address, e.tx_hash))
44 .collect::<Vec<_>>();
45 log_data == expected
46 } else {
47 false
48 }
49 }
50}