Skip to content

Commit

Permalink
fix: keep default labels
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Feb 14, 2024
1 parent bb21b65 commit 4ae60e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 8 additions & 5 deletions crates/evm/traces/src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ impl CallTraceDecoder {

Self {
contracts: Default::default(),

labels: [
(CHEATCODE_ADDRESS, "VM".to_string()),
(HARDHAT_CONSOLE_ADDRESS, "console".to_string()),
Expand All @@ -164,6 +163,7 @@ impl CallTraceDecoder {
(TEST_CONTRACT_ADDRESS, "DefaultTestContract".to_string()),
]
.into(),
receive_contracts: Default::default(),

functions: hh_funcs()
.chain(
Expand All @@ -174,24 +174,27 @@ impl CallTraceDecoder {
)
.map(|(selector, func)| (selector, vec![func]))
.collect(),

events: Console::abi::events()
.into_values()
.flatten()
.map(|event| ((event.selector(), indexed_inputs(&event)), vec![event]))
.collect(),

errors: Default::default(),

signature_identifier: None,
receive_contracts: Default::default(),
verbosity: 0,
}
}

/// Clears all known addresses.
pub fn clear_addresses(&mut self) {
self.contracts.clear();
self.labels.clear();

let default_labels = &Self::new().labels;
if self.labels.len() > default_labels.len() {
self.labels = default_labels.clone();
}

self.receive_contracts.clear();
}

Expand Down
4 changes: 3 additions & 1 deletion crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ impl TestArgs {

// Clear the addresses and labels from previous runs.
decoder.clear_addresses();
decoder.labels = result.labeled_addresses.clone();
decoder
.labels
.extend(result.labeled_addresses.iter().map(|(k, v)| (*k, v.clone())));

// Identify addresses and decode traces.
let mut decoded_traces = Vec::with_capacity(result.traces.len());
Expand Down

0 comments on commit 4ae60e5

Please sign in to comment.