mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-22 21:57:58 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aa2053de6f |
@@ -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!(
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user