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::collections::HashMap;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use alloy::json_abi::JsonAbi;
|
use alloy::json_abi::JsonAbi;
|
||||||
use alloy::network::{Ethereum, TransactionBuilder};
|
use alloy::network::{Ethereum, TransactionBuilder};
|
||||||
@@ -439,8 +440,18 @@ where
|
|||||||
expected_events.iter().zip(execution_receipt.logs())
|
expected_events.iter().zip(execution_receipt.logs())
|
||||||
{
|
{
|
||||||
// Handling the emitter assertion.
|
// Handling the emitter assertion.
|
||||||
if let Some(expected_address) = expected_event.address {
|
if let Some(ref expected_address) = expected_event.address {
|
||||||
let expected = expected_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();
|
let actual = actual_event.address();
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub struct ExpectedOutput {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
|
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
|
||||||
pub struct Event {
|
pub struct Event {
|
||||||
pub address: Option<Address>,
|
pub address: Option<String>,
|
||||||
pub topics: Vec<String>,
|
pub topics: Vec<String>,
|
||||||
pub values: Calldata,
|
pub values: Calldata,
|
||||||
}
|
}
|
||||||
@@ -1010,4 +1010,53 @@ mod tests {
|
|||||||
// Assert
|
// Assert
|
||||||
assert!(resolved.is_err())
|
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