|
1 | | -use super::{ |
2 | | - call_after_invariant_function, call_invariant_function, error::FailedInvariantCaseData, |
3 | | - shrink_sequence, |
4 | | -}; |
5 | | -use crate::executors::{EarlyExit, Executor}; |
| 1 | +use super::{call_after_invariant_function, call_invariant_function}; |
| 2 | +use crate::executors::{EarlyExit, Executor, invariant::shrink::shrink_sequence}; |
6 | 3 | use alloy_dyn_abi::JsonAbiExt; |
7 | 4 | use alloy_primitives::{Log, U256, map::HashMap}; |
8 | 5 | use eyre::Result; |
9 | 6 | use foundry_common::{ContractsByAddress, ContractsByArtifact}; |
| 7 | +use foundry_config::InvariantConfig; |
10 | 8 | use foundry_evm_coverage::HitMaps; |
11 | 9 | use foundry_evm_fuzz::{BaseCounterExample, BasicTxDetails, invariant::InvariantContract}; |
12 | 10 | use foundry_evm_traces::{TraceKind, TraceMode, Traces, load_contracts}; |
13 | 11 | use indicatif::ProgressBar; |
14 | 12 | use parking_lot::RwLock; |
15 | | -use proptest::test_runner::TestError; |
16 | 13 | use std::sync::Arc; |
17 | 14 |
|
18 | 15 | /// Replays a call sequence for collecting logs and traces. |
@@ -98,50 +95,41 @@ pub fn replay_run( |
98 | 95 | /// Replays the error case, shrinks the failing sequence and collects all necessary traces. |
99 | 96 | #[expect(clippy::too_many_arguments)] |
100 | 97 | pub fn replay_error( |
101 | | - failed_case: &FailedInvariantCaseData, |
102 | | - invariant_contract: &InvariantContract<'_>, |
| 98 | + config: InvariantConfig, |
103 | 99 | mut executor: Executor, |
| 100 | + calls: &[BasicTxDetails], |
| 101 | + inner_sequence: Option<Vec<Option<BasicTxDetails>>>, |
| 102 | + invariant_contract: &InvariantContract<'_>, |
104 | 103 | known_contracts: &ContractsByArtifact, |
105 | 104 | ided_contracts: ContractsByAddress, |
106 | 105 | logs: &mut Vec<Log>, |
107 | 106 | traces: &mut Traces, |
108 | 107 | line_coverage: &mut Option<HitMaps>, |
109 | 108 | deprecated_cheatcodes: &mut HashMap<&'static str, Option<&'static str>>, |
110 | 109 | progress: Option<&ProgressBar>, |
111 | | - show_solidity: bool, |
112 | 110 | early_exit: &EarlyExit, |
113 | 111 | ) -> Result<Vec<BaseCounterExample>> { |
114 | | - match failed_case.test_error { |
115 | | - // Don't use at the moment. |
116 | | - TestError::Abort(_) => Ok(vec![]), |
117 | | - TestError::Fail(_, ref calls) => { |
118 | | - // Shrink sequence of failed calls. |
119 | | - let calls = shrink_sequence( |
120 | | - failed_case, |
121 | | - calls, |
122 | | - &executor, |
123 | | - invariant_contract.call_after_invariant, |
124 | | - progress, |
125 | | - early_exit, |
126 | | - )?; |
| 112 | + // Shrink sequence of failed calls. |
| 113 | + let calls = |
| 114 | + shrink_sequence(&config, invariant_contract, calls, &executor, progress, early_exit)?; |
127 | 115 |
|
128 | | - set_up_inner_replay(&mut executor, &failed_case.inner_sequence); |
129 | | - |
130 | | - // Replay calls to get the counterexample and to collect logs, traces and coverage. |
131 | | - replay_run( |
132 | | - invariant_contract, |
133 | | - executor, |
134 | | - known_contracts, |
135 | | - ided_contracts, |
136 | | - logs, |
137 | | - traces, |
138 | | - line_coverage, |
139 | | - deprecated_cheatcodes, |
140 | | - &calls, |
141 | | - show_solidity, |
142 | | - ) |
143 | | - } |
| 116 | + if let Some(sequence) = inner_sequence { |
| 117 | + set_up_inner_replay(&mut executor, &sequence); |
144 | 118 | } |
| 119 | + |
| 120 | + // Replay calls to get the counterexample and to collect logs, traces and coverage. |
| 121 | + replay_run( |
| 122 | + invariant_contract, |
| 123 | + executor, |
| 124 | + known_contracts, |
| 125 | + ided_contracts, |
| 126 | + logs, |
| 127 | + traces, |
| 128 | + line_coverage, |
| 129 | + deprecated_cheatcodes, |
| 130 | + &calls, |
| 131 | + config.show_solidity, |
| 132 | + ) |
145 | 133 | } |
146 | 134 |
|
147 | 135 | /// Sets up the calls generated by the internal fuzzer, if they exist. |
|
0 commit comments