@@ -514,6 +514,8 @@ impl<'a> FunctionRunner<'a> {
514514 call_after_invariant : bool ,
515515 identified_contracts : Option < & ContractsByAddress > ,
516516 ) -> TestResult {
517+ self . executor . strategy . runner . rollback_transaction ( self . executor . strategy . context . as_ref ( ) ) ;
518+ self . executor . strategy . runner . start_transaction ( self . executor . strategy . context . as_ref ( ) ) ;
517519 if let Err ( e) = self . apply_function_inline_config ( func) {
518520 self . result . single_fail ( Some ( e. to_string ( ) ) ) ;
519521 return self . result ;
@@ -544,15 +546,8 @@ impl<'a> FunctionRunner<'a> {
544546 /// State modifications of before test txes and unit test function call are discarded after
545547 /// test ends, similar to `eth_call`.
546548 fn run_unit_test ( mut self , func : & Function ) -> TestResult {
547- let binding = self . executor . into_owned ( ) ;
548- self . executor = Cow :: Owned ( binding) ;
549- self . executor . strategy . runner . start_transaction ( self . executor . strategy . context . as_ref ( ) ) ;
550549 // Prepare unit test execution.
551550 if self . prepare_test ( func) . is_err ( ) {
552- self . executor
553- . strategy
554- . runner
555- . rollback_transaction ( self . executor . strategy . context . as_ref ( ) ) ;
556551 return self . result ;
557552 }
558553
@@ -569,22 +564,14 @@ impl<'a> FunctionRunner<'a> {
569564 Err ( EvmError :: Execution ( err) ) => ( err. raw , Some ( err. reason ) ) ,
570565 Err ( EvmError :: Skip ( reason) ) => {
571566 self . result . single_skip ( reason) ;
572- self . executor
573- . strategy
574- . runner
575- . rollback_transaction ( self . executor . strategy . context . as_ref ( ) ) ;
576567 return self . result ;
577568 }
578569 Err ( err) => {
579570 self . result . single_fail ( Some ( err. to_string ( ) ) ) ;
580- self . executor
581- . strategy
582- . runner
583- . rollback_transaction ( self . executor . strategy . context . as_ref ( ) ) ;
571+
584572 return self . result ;
585573 }
586574 } ;
587- self . executor . strategy . runner . rollback_transaction ( self . executor . strategy . context . as_ref ( ) ) ;
588575
589576 let success =
590577 self . executor . is_raw_call_mut_success ( self . address , & mut raw_call_result, false ) ;
@@ -602,8 +589,6 @@ impl<'a> FunctionRunner<'a> {
602589 /// - `bool[] public fixtureSwap = [true, false]` The `table_test` is then called with the pair
603590 /// of args `(2, true)` and `(5, false)`.
604591 fn run_table_test ( mut self , func : & Function ) -> TestResult {
605- let binding = self . executor . into_owned ( ) ;
606- self . executor = Cow :: Owned ( binding) ; // Prepare unit test execution.
607592 if self . prepare_test ( func) . is_err ( ) {
608593 return self . result ;
609594 }
@@ -733,8 +718,6 @@ impl<'a> FunctionRunner<'a> {
733718 identified_contracts : & ContractsByAddress ,
734719 test_bytecode : & Bytes ,
735720 ) -> TestResult {
736- let binding = self . executor . into_owned ( ) ;
737- self . executor = Cow :: Owned ( binding) ;
738721 // First, run the test normally to see if it needs to be skipped.
739722 if let Err ( EvmError :: Skip ( reason) ) = self . executor . call (
740723 self . sender ,
@@ -959,8 +942,6 @@ impl<'a> FunctionRunner<'a> {
959942 /// State modifications of before test txes and fuzz test are discarded after test ends,
960943 /// similar to `eth_call`.
961944 fn run_fuzz_test ( mut self , func : & Function ) -> TestResult {
962- let binding = self . executor . into_owned ( ) ;
963- self . executor = Cow :: Owned ( binding) ;
964945 // Prepare fuzz test execution.
965946 if self . prepare_test ( func) . is_err ( ) {
966947 return self . result ;
0 commit comments