Commit 2aa20c92 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: fix invariant test

New version of forge is more strict in how it does invariant testing,
need to specify the ABI using a special `targetInterfaces` function.

https://github.com/foundry-rs/foundry/pull/5605

h/t msolomon
parent 8f2c9e19
...@@ -8,6 +8,11 @@ import { ResourceMetering } from "../../src/L1/ResourceMetering.sol"; ...@@ -8,6 +8,11 @@ import { ResourceMetering } from "../../src/L1/ResourceMetering.sol";
import { Constants } from "../../src/libraries/Constants.sol"; import { Constants } from "../../src/libraries/Constants.sol";
contract SystemConfig_GasLimitLowerBound_Invariant is Test { contract SystemConfig_GasLimitLowerBound_Invariant is Test {
struct FuzzInterface {
address target;
string[] artifacts;
}
SystemConfig public config; SystemConfig public config;
function setUp() external { function setUp() external {
...@@ -56,6 +61,19 @@ contract SystemConfig_GasLimitLowerBound_Invariant is Test { ...@@ -56,6 +61,19 @@ contract SystemConfig_GasLimitLowerBound_Invariant is Test {
targetSelector(selector); targetSelector(selector);
} }
/// @dev Allows the SystemConfig contract to be the target of the invariant test
/// when it is behind a proxy. Foundry calls this function under the hood to
/// know the ABI to use when calling the target contract.
function targetInterfaces() public view returns (FuzzInterface[] memory) {
require(address(config) != address(0), "SystemConfig not initialized");
FuzzInterface[] memory targets = new FuzzInterface[](1);
string[] memory artifacts = new string[](1);
artifacts[0] = "SystemConfig";
targets[0] = FuzzInterface(address(config), artifacts);
return targets;
}
/// @custom:invariant The gas limit of the `SystemConfig` contract can never be lower /// @custom:invariant The gas limit of the `SystemConfig` contract can never be lower
/// than the hard-coded lower bound. /// than the hard-coded lower bound.
function invariant_gasLimitLowerBound() external { function invariant_gasLimitLowerBound() external {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment