Skip to content

Commit 59da939

Browse files
committed
tests fixup
1 parent 8a65543 commit 59da939

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

crates/forge/src/runner.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -544,18 +544,12 @@ impl<'a> FunctionRunner<'a> {
544544
/// State modifications of before test txes and unit test function call are discarded after
545545
/// test ends, similar to `eth_call`.
546546
fn run_unit_test(mut self, func: &Function) -> TestResult {
547-
let executor = self.executor.into_owned();
548-
self.executor = Cow::Owned(executor);
549-
self.executor.strategy.runner.start_transaction(self.executor.strategy.context.as_ref());
550547
// Prepare unit test execution.
551548
if self.prepare_test(func).is_err() {
552-
self.executor
553-
.strategy
554-
.runner
555-
.rollback_transaction(self.executor.strategy.context.as_ref());
556-
557549
return self.result;
558550
}
551+
self.executor.strategy.runner.start_transaction(self.executor.strategy.context.as_ref());
552+
559553
// Run current unit test.
560554
let (mut raw_call_result, reason) = match self.executor.call(
561555
self.sender,
@@ -602,13 +596,8 @@ impl<'a> FunctionRunner<'a> {
602596
/// - `bool[] public fixtureSwap = [true, false]` The `table_test` is then called with the pair
603597
/// of args `(2, true)` and `(5, false)`.
604598
fn run_table_test(mut self, func: &Function) -> TestResult {
605-
self.executor.strategy.runner.start_transaction(self.executor.strategy.context.as_ref());
606599
// Prepare unit test execution.
607600
if self.prepare_test(func).is_err() {
608-
self.executor
609-
.strategy
610-
.runner
611-
.rollback_transaction(self.executor.strategy.context.as_ref());
612601
return self.result;
613602
}
614603

crates/forge/tests/cli/revive_vm.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,14 @@ contract CounterTest is DSTest {
15131513
beforeTestCalldata = new bytes[](1);
15141514
beforeTestCalldata[0] = abi.encodeWithSignature("callMe(uint256,uint256)", 15, 4);
15151515
}
1516+
if (testSelector == this.testFuzz_SetNumber.selector) {
1517+
beforeTestCalldata = new bytes[](1);
1518+
beforeTestCalldata[0] = abi.encodeWithSignature("callMe(uint256,uint256)", 15, 4);
1519+
}
1520+
if (testSelector == this.testFuzz_SetNumber2.selector) {
1521+
beforeTestCalldata = new bytes[](1);
1522+
beforeTestCalldata[0] = abi.encodeWithSignature("callMe(uint256,uint256)", 1, 4);
1523+
}
15161524
}
15171525
15181526
function testA() public {
@@ -1541,13 +1549,13 @@ function testC() public {
15411549
}
15421550
15431551
function testFuzz_SetNumber(uint256 x) public {
1544-
assertEq(counter.number(), 5);
1552+
assertEq(counter.number(), 15);
15451553
counter.setNumber(x);
15461554
assertEq(counter.number(), x);
15471555
}
15481556
15491557
function testFuzz_SetNumber2(uint256 x) public {
1550-
assertEq(counter.number(), 5);
1558+
assertEq(counter.number(), 1);
15511559
counter.setNumber(x);
15521560
assertEq(counter.number(), x);
15531561
}

0 commit comments

Comments
 (0)