You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on a Slack discussion with @hjorthjort and @anvacaru: in Foundry, prank is not effective when the test contract calls a function that is defined in a contract that the test is inherited from. With Foundry, all tests in the following contract pass:
// SPDX-License-Identifier: UNLICENSEDpragma solidity>=0.6.2<0.9.0;
import"forge-std/Test.sol";
import"forge-std/Vm.sol";
import"../src/timetravel/CallBreaker.sol";
contractPrankParentisTest {
function parentFunction(addressp) public {
assertEq(p,msg.sender);
}
}
contractExternalisTest {
constructor(addressp) {
assertEq(p,msg.sender);
}
function externalFunction(addressp) public {
assertEq(p,msg.sender);
}
}
contractPrankTestisPrankParent {
function test_startP(addressp) public {
address sender =msg.sender;
vm.startPrank(p);
assertEq(msg.sender, sender);
localFunc(sender);
parentFunction(sender);
External e =newExternal(p);
e.externalFunction(p);
vm.stopPrank();
}
function test_p(addressp) public {
vm.prank(p); External e =newExternal(p);
address sender =msg.sender;
vm.prank(p); assertEq(msg.sender, sender); e.externalFunction(p);
vm.prank(p); localFunc(sender); e.externalFunction(p);
vm.prank(p); parentFunction(sender); e.externalFunction(p);
vm.prank(p); e.externalFunction(p);
}
function localFunc(addressp) public {
assertEq(p,msg.sender);
}
}
In addition, vm.prank(x); vm.prank(x); causes a runtime failure in Foundry, while, in Kontrol, we insert a prank only if no other is active (source); this specific scenario is not handled, so the configuration would get stuck. We have a test for this here.
We should align prank-related behavior of Kontrol with Foundry.
The text was updated successfully, but these errors were encountered:
Follow up to #120 and #110.
Related: #124.
Based on a Slack discussion with @hjorthjort and @anvacaru: in Foundry,
prank
is not effective when the test contract calls a function that is defined in a contract that the test is inherited from. With Foundry, all tests in the following contract pass:In addition,
vm.prank(x); vm.prank(x);
causes a runtime failure in Foundry, while, in Kontrol, we insert a prank only if no other is active (source); this specific scenario is not handled, so the configuration would get stuck. We have a test for this here.We should align
prank
-related behavior of Kontrol with Foundry.The text was updated successfully, but these errors were encountered: