Skip to content

Commit

Permalink
improve tests SystemConfig (#12938)
Browse files Browse the repository at this point in the history
* improve tests

* improve tests

* fixes
  • Loading branch information
AmadiMichael authored Nov 15, 2024
1 parent b01b93e commit c267d98
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/contracts-bedrock/test/L1/SystemConfig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,19 @@ contract SystemConfig_Init_ResourceConfig is SystemConfig_Init {
_initializeWithResourceConfig(config, "SystemConfig: gas limit too low");
}

/// @dev Tests that `setResourceConfig` reverts if the gas limit is too low.
function test_setResourceConfig_elasticityMultiplierIs0_reverts() external {
IResourceMetering.ResourceConfig memory config = IResourceMetering.ResourceConfig({
maxResourceLimit: 20_000_000,
elasticityMultiplier: 0,
baseFeeMaxChangeDenominator: 8,
systemTxMaxGas: 1_000_000,
minimumBaseFee: 1 gwei,
maximumBaseFee: 2 gwei
});
_initializeWithResourceConfig(config, "SystemConfig: elasticity multiplier cannot be 0");
}

/// @dev Tests that `setResourceConfig` reverts if the elasticity multiplier
/// and max resource limit are configured such that there is a loss of precision.
function test_setResourceConfig_badPrecision_reverts() external {
Expand Down
13 changes: 13 additions & 0 deletions packages/contracts-bedrock/test/L1/SystemConfigInterop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ contract SystemConfigInterop_Test is CommonTest {
super.setUp();
}

/// @dev Tests that when the decimals is not 18, initialization reverts.
function test_initialize_decimalsIsNot18_reverts(uint8 decimals) external {
vm.assume(decimals != 18);
address _token = address(L1Token);

vm.mockCall(_token, abi.encodeCall(ERC20.name, ()), abi.encode("Token"));
vm.mockCall(_token, abi.encodeCall(ERC20.symbol, ()), abi.encode("TKN"));
vm.mockCall(_token, abi.encodeCall(ERC20.decimals, ()), abi.encode(decimals));

vm.expectRevert("SystemConfig: bad decimals of gas paying token");
_cleanStorageAndInit(_token);
}

/// @dev Tests that the gas paying token can be set.
function testFuzz_setGasPayingToken_succeeds(
address _token,
Expand Down

0 comments on commit c267d98

Please sign in to comment.