-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add `InspectorStack` Adds `InspectorStack`, an inspector that calls a stack of other inspectors sequentially. Closes #752 * feat: port cheatcodes to revm * feat: port `expectCall` cheatcode * feat: extract labels from cheatcode inspector * feat: port `expectEmit` cheatcode * refactor: move log decoding into `forge` crate * chore: remove unused evm patch * test: re-enable debug logs test * fix: record reads on `SSTORE` ops * refactor: rename `record` to `start_record` * docs: clarify why `DUMMY_CALL_OUTPUT` is 320 bytes * fix: handle `expectRevert` with no return data * build: bump revm * chore: remove outdated todo * refactor: use static dispatch in `InspectorStack` * build: use k256 * fix: make gas usage not so crazy
- Loading branch information
Showing
20 changed files
with
1,222 additions
and
126 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//! Various utilities to decode test results | ||
use crate::abi::ConsoleEvents::{self, *}; | ||
use ethers::{abi::RawLog, contract::EthLogDecode}; | ||
|
||
/// Decode a set of logs, only returning logs from DSTest logging events and Hardhat's `console.log` | ||
pub fn decode_console_logs(logs: &[RawLog]) -> Vec<String> { | ||
logs.iter().filter_map(decode_console_log).collect() | ||
} | ||
|
||
/// Decode a single log. | ||
/// | ||
/// This function returns [None] if it is not a DSTest log or the result of a Hardhat | ||
/// `console.log`. | ||
pub fn decode_console_log(log: &RawLog) -> Option<String> { | ||
let decoded = match ConsoleEvents::decode_log(log).ok()? { | ||
LogsFilter(inner) => format!("{}", inner.0), | ||
LogBytesFilter(inner) => format!("{}", inner.0), | ||
LogNamedAddressFilter(inner) => format!("{}: {:?}", inner.key, inner.val), | ||
LogNamedBytes32Filter(inner) => { | ||
format!("{}: 0x{}", inner.key, hex::encode(inner.val)) | ||
} | ||
LogNamedDecimalIntFilter(inner) => { | ||
let (sign, val) = inner.val.into_sign_and_abs(); | ||
format!( | ||
"{}: {}{}", | ||
inner.key, | ||
sign, | ||
ethers::utils::format_units(val, inner.decimals.as_u32()).unwrap() | ||
) | ||
} | ||
LogNamedDecimalUintFilter(inner) => { | ||
format!( | ||
"{}: {}", | ||
inner.key, | ||
ethers::utils::format_units(inner.val, inner.decimals.as_u32()).unwrap() | ||
) | ||
} | ||
LogNamedIntFilter(inner) => format!("{}: {:?}", inner.key, inner.val), | ||
LogNamedUintFilter(inner) => format!("{}: {:?}", inner.key, inner.val), | ||
LogNamedBytesFilter(inner) => { | ||
format!("{}: 0x{}", inner.key, hex::encode(inner.val)) | ||
} | ||
LogNamedStringFilter(inner) => format!("{}: {}", inner.key, inner.val), | ||
|
||
e => e.to_string(), | ||
}; | ||
Some(decoded) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.