Compare commits

...

1 Commits

Author SHA1 Message Date
Omar Abdulla aa2053de6f Correct the type of address in matterlabs events 2025-07-28 07:44:41 +03:00
2 changed files with 63 additions and 3 deletions
+13 -2
View File
@@ -3,6 +3,7 @@
use std::collections::HashMap;
use std::fmt::Debug;
use std::marker::PhantomData;
use std::str::FromStr;
use alloy::json_abi::JsonAbi;
use alloy::network::{Ethereum, TransactionBuilder};
@@ -439,8 +440,18 @@ where
expected_events.iter().zip(execution_receipt.logs())
{
// Handling the emitter assertion.
if let Some(expected_address) = expected_event.address {
let expected = expected_address;
if let Some(ref expected_address) = expected_event.address {
let expected = if let Some(contract_instance) = expected_address
.strip_suffix(".address")
.map(ContractInstance::new)
{
deployed_contracts
.get(&contract_instance)
.map(|(address, _)| *address)
} else {
Address::from_str(expected_address).ok()
}
.context("Failed to get the address of the event")?;
let actual = actual_event.address();
if actual != expected {
tracing::error!(
+50 -1
View File
@@ -51,7 +51,7 @@ pub struct ExpectedOutput {
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
pub struct Event {
pub address: Option<Address>,
pub address: Option<String>,
pub topics: Vec<String>,
pub values: Calldata,
}
@@ -1010,4 +1010,53 @@ mod tests {
// Assert
assert!(resolved.is_err())
}
#[test]
fn expected_json_can_be_deserialized1() {
// Arrange
let str = r#"
{
"return_data": [
"1"
],
"events": [
{
"topics": [],
"values": []
}
]
}
"#;
// Act
let expected = serde_json::from_str::<Expected>(str);
// Assert
expected.expect("Failed to deserialize");
}
#[test]
fn expected_json_can_be_deserialized2() {
// Arrange
let str = r#"
{
"return_data": [
"1"
],
"events": [
{
"address": "Main.address",
"topics": [],
"values": []
}
]
}
"#;
// Act
let expected = serde_json::from_str::<Expected>(str);
// Assert
expected.expect("Failed to deserialize");
}
}