Skip to content

Commit

Permalink
fix(debugger): don't panic when arena is empty (#6547)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Dec 8, 2023
1 parent 8a31bf1 commit fb601f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
2 changes: 2 additions & 0 deletions crates/debugger/src/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ impl Debugger {
.spawn(move || Self::event_listener(tx))
.expect("failed to spawn thread");

eyre::ensure!(!cx.debug_arena().is_empty(), "debug arena is empty");

// Draw the initial state.
cx.draw(terminal)?;

Expand Down
17 changes: 3 additions & 14 deletions crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl TestArgs {
// Prepare the test builder
let should_debug = self.debug.is_some();

let mut runner_builder = MultiContractRunnerBuilder::default()
let runner_builder = MultiContractRunnerBuilder::default()
.set_debug(should_debug)
.initial_balance(evm_opts.initial_balance)
.evm_spec(config.evm_spec_id())
Expand All @@ -197,7 +197,7 @@ impl TestArgs {
.with_cheats_config(CheatsConfig::new(&config, evm_opts.clone()))
.with_test_options(test_options.clone());

let mut runner = runner_builder.clone().build(
let runner = runner_builder.clone().build(
project_root,
output.clone(),
env.clone(),
Expand All @@ -213,17 +213,6 @@ impl TestArgs {
Use --match-contract and --match-path to further limit the search."
);
}
let test_funcs = runner.get_matching_test_functions(&filter);
// if we debug a fuzz test, we should not collect data on the first run
if !test_funcs.first().expect("matching function exists").inputs.is_empty() {
runner_builder = runner_builder.set_debug(false);
runner = runner_builder.clone().build(
project_root,
output.clone(),
env.clone(),
evm_opts.clone(),
)?;
}
}

let known_contracts = runner.known_contracts.clone();
Expand Down Expand Up @@ -307,7 +296,7 @@ impl TestArgs {
let source_contract = compact_to_contract(contract)?;
sources
.0
.entry(id.clone().name)
.entry(id.name.clone())
.or_default()
.insert(source.id, (source_code, source_contract));
}
Expand Down

0 comments on commit fb601f5

Please sign in to comment.