Skip to content

Commit 300114d

Browse files
committed
Panic on gas addition overflow
1 parent 8f3b1f6 commit 300114d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/forge-runner/src/gas/report.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ impl GasSingleTestInfo {
8383
) {
8484
let contract_info = self.report_data.0.entry(contract_name).or_default();
8585

86-
if let Some(gas) = contract_info.gas_used.checked_add(gas_used) {
87-
contract_info.gas_used = gas;
88-
}
86+
let current_gas = contract_info.gas_used;
87+
contract_info.gas_used = current_gas.checked_add(gas_used).unwrap_or_else(|| {
88+
panic!("Gas addition overflow when adding {gas_used:?} to {current_gas:?}.")
89+
});
8990

9091
let entry = contract_info.functions.entry(selector).or_default();
9192
entry.records.push(gas_used.l2_gas.0);

0 commit comments

Comments
 (0)