@@ -6,7 +6,7 @@ use crate::{
66 inspectors:: Fuzzer ,
77} ;
88use alloy_json_abi:: Function ;
9- use alloy_primitives:: { Address , Bytes , FixedBytes , I256 , Selector , U256 , map:: { AddressMap , HashMap } } ;
9+ use alloy_primitives:: { Address , Bytes , FixedBytes , I256 , Selector , U256 , map:: AddressMap } ;
1010use alloy_sol_types:: { SolCall , sol} ;
1111use eyre:: { ContextCompat , Result , eyre} ;
1212use foundry_common:: {
@@ -35,7 +35,7 @@ use foundry_evm_traces::{CallTraceArena, SparsedTraceArena};
3535use indicatif:: ProgressBar ;
3636use parking_lot:: RwLock ;
3737use proptest:: { strategy:: Strategy , test_runner:: TestRunner } ;
38- use result:: { assert_after_invariant, assert_invariants , can_continue, did_fail_on_assert, invariant_preflight_check} ;
38+ use result:: { assert_after_invariant, can_continue, did_fail_on_assert, invariant_preflight_check} ;
3939use revm:: { context:: Block , state:: Account } ;
4040use serde:: { Deserialize , Serialize } ;
4141use serde_json:: json;
@@ -220,7 +220,7 @@ fn build_invariant_progress_json<M: Serialize>(
220220}
221221
222222/// Contains data collected during invariant test runs.
223- struct InvariantTestData < FEN : FoundryEvmNetwork > {
223+ struct InvariantTestData {
224224 // Consumed gas and calldata of every successful fuzz call.
225225 fuzz_cases : Vec < FuzzedCases > ,
226226 // Data related to reverts or failed assertions of the test.
@@ -229,8 +229,6 @@ struct InvariantTestData<FEN: FoundryEvmNetwork> {
229229 last_run_inputs : Vec < BasicTxDetails > ,
230230 // Additional traces for gas report.
231231 gas_report_traces : Vec < Vec < CallTraceArena > > ,
232- // Last call results of the invariant test.
233- last_call_results : Option < RawCallResult < FEN > > ,
234232 // Line coverage information collected from all fuzzed calls.
235233 line_coverage : Option < HitMaps > ,
236234 // Metrics for each fuzzed selector.
@@ -249,30 +247,28 @@ struct InvariantTestData<FEN: FoundryEvmNetwork> {
249247}
250248
251249/// Contains invariant test data.
252- struct InvariantTest < FEN : FoundryEvmNetwork > {
250+ struct InvariantTest {
253251 // Fuzz state of invariant test.
254252 fuzz_state : EvmFuzzState ,
255253 // Contracts fuzzed by the invariant test.
256254 targeted_contracts : FuzzRunIdentifiedContracts ,
257255 // Data collected during invariant runs.
258- test_data : InvariantTestData < FEN > ,
256+ test_data : InvariantTestData ,
259257}
260258
261- impl < FEN : FoundryEvmNetwork > InvariantTest < FEN > {
259+ impl InvariantTest {
262260 /// Instantiates an invariant test.
263261 fn new (
264262 fuzz_state : EvmFuzzState ,
265263 targeted_contracts : FuzzRunIdentifiedContracts ,
266264 failures : InvariantFailures ,
267- last_call_results : Option < RawCallResult < FEN > > ,
268265 branch_runner : TestRunner ,
269266 ) -> Self {
270267 let test_data = InvariantTestData {
271268 fuzz_cases : vec ! [ ] ,
272269 failures,
273270 last_run_inputs : vec ! [ ] ,
274271 gas_report_traces : vec ! [ ] ,
275- last_call_results,
276272 line_coverage : None ,
277273 metrics : Map :: default ( ) ,
278274 branch_runner,
@@ -297,11 +293,6 @@ impl<FEN: FoundryEvmNetwork> InvariantTest<FEN> {
297293 self . test_data . failures . record_failure ( invariant, error) ;
298294 }
299295
300- /// Set last invariant test call results.
301- fn set_last_call_results ( & mut self , call_result : Option < RawCallResult < FEN > > ) {
302- self . test_data . last_call_results = call_result;
303- }
304-
305296 /// Set last invariant run call sequence.
306297 fn set_last_run_inputs ( & mut self , inputs : & Vec < BasicTxDetails > ) {
307298 self . test_data . last_run_inputs . clone_from ( inputs) ;
@@ -332,7 +323,7 @@ impl<FEN: FoundryEvmNetwork> InvariantTest<FEN> {
332323
333324 /// End invariant test run by collecting results, cleaning collected artifacts and reverting
334325 /// created fuzz state.
335- fn end_run ( & mut self , run : InvariantTestRun < FEN > , gas_samples : usize ) {
326+ fn end_run < FEN : FoundryEvmNetwork > ( & mut self , run : InvariantTestRun < FEN > , gas_samples : usize ) {
336327 // We clear all the targeted contracts created during this run.
337328 self . targeted_contracts . clear_created_contracts ( run. created_contracts ) ;
338329
@@ -600,7 +591,7 @@ impl<'a, FEN: FoundryEvmNetwork> InvariantExecutor<'a, FEN> {
600591 || is_last_call
601592 } ;
602593
603- let can_continue_result = if should_check_invariant {
594+ let result = if should_check_invariant {
604595 can_continue (
605596 & invariant_contract,
606597 & mut invariant_test,
@@ -649,11 +640,11 @@ impl<'a, FEN: FoundryEvmNetwork> InvariantExecutor<'a, FEN> {
649640 }
650641 } ;
651642
652- if !can_continue_result || current_run. depth == self . config . depth - 1 {
643+ if !result || current_run. depth == self . config . depth - 1 {
653644 invariant_test. set_last_run_inputs ( & current_run. inputs ) ;
654645 }
655646 // If test cannot continue then stop current run and exit test suite.
656- if !can_continue_result {
647+ if !result {
657648 let reason = invariant_test
658649 . test_data
659650 . failures
@@ -787,7 +778,7 @@ impl<'a, FEN: FoundryEvmNetwork> InvariantExecutor<'a, FEN> {
787778 invariant_contract : & InvariantContract < ' _ > ,
788779 fuzz_fixtures : & FuzzFixtures ,
789780 fuzz_state : EvmFuzzState ,
790- ) -> Result < ( InvariantTest < FEN > , WorkerCorpus ) > {
781+ ) -> Result < ( InvariantTest , WorkerCorpus ) > {
791782 // Finds out the chosen deployed contracts and/or senders.
792783 self . select_contract_artifacts ( invariant_contract. address ) ?;
793784 let ( targeted_senders, targeted_contracts) =
@@ -880,7 +871,6 @@ impl<'a, FEN: FoundryEvmNetwork> InvariantExecutor<'a, FEN> {
880871 fuzz_state,
881872 targeted_contracts,
882873 failures,
883- None ,
884874 self . runner . clone ( ) ,
885875 ) ;
886876
@@ -1228,7 +1218,7 @@ impl<'a, FEN: FoundryEvmNetwork> InvariantExecutor<'a, FEN> {
12281218/// before inserting it into the dictionary. Otherwise, we flood the dictionary with
12291219/// randomly generated addresses.
12301220fn collect_data < FEN : FoundryEvmNetwork > (
1231- invariant_test : & InvariantTest < FEN > ,
1221+ invariant_test : & InvariantTest ,
12321222 state_changeset : & mut AddressMap < Account > ,
12331223 tx : & BasicTxDetails ,
12341224 call_result : & RawCallResult < FEN > ,
0 commit comments