Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(debugger): don't panic when arena is empty #6547

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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