Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Nov 22, 2023
1 parent c175134 commit b425ba5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions crates/cheatcodes/src/test/expect.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{Cheatcode, Cheatcodes, CheatsCtxt, DatabaseExt, Result, Vm::*};
use alloy_primitives::{Address, Bytes, Log as RawLog, B256, U256};
use alloy_sol_types::{ContractError, SolInterface, SolValue};
use alloy_sol_types::{ContractError, SolError, SolInterface, SolValue};
use revm::interpreter::{return_ok, InstructionResult};
use spec::Vm;
use std::collections::{hash_map::Entry, HashMap};
Expand Down Expand Up @@ -466,15 +466,23 @@ pub(crate) fn handle_expect_revert(
}

let mut actual_revert: Vec<u8> = retdata.into();
if let Ok(error) = ContractError::<Vm::VmErrors>::abi_decode(&actual_revert, false) {
match error {
ContractError::Revert(revert) => actual_revert = revert.reason.into_bytes(),
ContractError::Panic(_panic) => {}
ContractError::CustomError(Vm::VmErrors::CheatcodeError(cheatcode_error)) => {
actual_revert = cheatcode_error.message.into_bytes()
match actual_revert.get(..4).map(|slice| slice.try_into().unwrap()) {
Some(Vm::CheatcodeError::SELECTOR | alloy_sol_types::Revert::SELECTOR) => {
if let Ok(bytes) = Vec::<u8>::abi_decode(&actual_revert[4..], false) {
actual_revert = bytes;
}
}
_ => {}
}
// if let Ok(error) = ContractError::<Vm::VmErrors>::abi_decode(&actual_revert, false) {
// match error {
// ContractError::Revert(revert) => actual_revert = revert.reason.into_bytes(),
// ContractError::Panic(_panic) => {}
// ContractError::CustomError(Vm::VmErrors::CheatcodeError(cheatcode_error)) => {
// actual_revert = cheatcode_error.message.into_bytes();
// }
// }
// }

if actual_revert == expected_revert {
Ok(success_return())
Expand Down

0 comments on commit b425ba5

Please sign in to comment.