Open
Description
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge Version: 1.2.2-nightly
What version of Foundryup are you on?
forge Version: 1.2.2-nightly
What command(s) is the bug in?
forge test
Operating System
macOS (Apple Silicon)
Describe the bug
If I do the following, it will revert:
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;
import "forge-std/Test.sol";
interface IExample {
function foo(uint a) external;
}
contract MyTest is Test {
function testFoo() public {
IExample(address(1)).foo(42);
}
}
because address(1)
is not a contract.
Nevertheless, if I use mockCall
like this:
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;
import "forge-std/Test.sol";
interface IExample {
function foo(uint a) external;
}
contract MyTest is Test {
function testFoo() public {
vm.mockCall(address(1), "randomvalue", abi.encode());
IExample(address(1)).foo(42); // passes, but foo is not mocked
}
}
it will pass and I do not understand why. This behavior is pretty obscure and makes tests pass when they shouldn't.
NOTE: this only happens when methods does not return a value. It works as expected in the method return some value
Metadata
Metadata
Assignees
Type
Projects
Status
Backlog