Commit 43ccf8ea authored by Michael Amadi's avatar Michael Amadi Committed by GitHub

add more tests (#13036)

parent 38db6529
...@@ -99,6 +99,31 @@ contract L2OutputOracle_getter_Test is L2OutputOracle_TestBase { ...@@ -99,6 +99,31 @@ contract L2OutputOracle_getter_Test is L2OutputOracle_TestBase {
l2OutputOracle.getL2Output(nextOutputIndex + 1); l2OutputOracle.getL2Output(nextOutputIndex + 1);
} }
/// @dev Tests that `getL2OutputAfter` of an L2 block number returns the L2 output of the `getL2OutputIndexAfter` of
/// that block number.
function test_getL2OutputAfter_succeeds() external {
uint8 iterations = 5;
Types.OutputProposal memory output;
Types.OutputProposal memory expectedOutput;
for (uint8 i; i < iterations; i++) {
proposeAnotherOutput();
}
uint256 latestBlockNumber = l2OutputOracle.latestBlockNumber();
for (uint8 i = iterations - 1; i > 0; i--) {
uint256 index = l2OutputOracle.getL2OutputIndexAfter(latestBlockNumber);
output = l2OutputOracle.getL2OutputAfter(latestBlockNumber);
expectedOutput = l2OutputOracle.getL2Output(index);
assertEq(output.outputRoot, expectedOutput.outputRoot);
assertEq(output.timestamp, expectedOutput.timestamp);
assertEq(output.l2BlockNumber, expectedOutput.l2BlockNumber);
latestBlockNumber -= l2OutputOracle.SUBMISSION_INTERVAL();
}
}
/// @dev Tests that `getL2OutputIndexAfter` returns the correct value /// @dev Tests that `getL2OutputIndexAfter` returns the correct value
/// when the input is the exact block number of the proposal. /// when the input is the exact block number of the proposal.
function test_getL2OutputIndexAfter_sameBlock_succeeds() external { function test_getL2OutputIndexAfter_sameBlock_succeeds() external {
......
...@@ -117,6 +117,26 @@ contract GasPriceOracleBedrock_Test is GasPriceOracle_Test { ...@@ -117,6 +117,26 @@ contract GasPriceOracleBedrock_Test is GasPriceOracle_Test {
vm.expectRevert("GasPriceOracle: Fjord can only be activated after Ecotone"); vm.expectRevert("GasPriceOracle: Fjord can only be activated after Ecotone");
gasPriceOracle.setFjord(); gasPriceOracle.setFjord();
} }
/// @dev Tests that `getL1Fee` returns the expected value when both fjord and ecotone are not active
function test_getL1Fee_whenFjordAndEcotoneNotActive_succeeds() external {
vm.store(address(gasPriceOracle), bytes32(uint256(0)), bytes32(0));
bytes memory data = hex"1111";
uint256 price = gasPriceOracle.getL1Fee(data);
assertEq(price, 28_600); // ((((16 * data.length(i.e 2)) * (68 * 16)) + l1FeeOverhead(i.e. 310)) *
// l1BaseFee(i.e. 2M) *
// l1FeeScalar(i.e. 10)) / 1e6
}
/// @dev Tests that `getL1GasUsed` returns the expected value when both fjord and ecotone are not active
function test_getL1GasUsed_whenFjordAndEcotoneNotActive_succeeds() external {
vm.store(address(gasPriceOracle), bytes32(uint256(0)), bytes32(0));
bytes memory data = hex"1111";
uint256 gas = gasPriceOracle.getL1GasUsed(data);
assertEq(gas, 1_430); // 1398 + (16 * data.length(i.e 2))
}
} }
contract GasPriceOracleEcotone_Test is GasPriceOracle_Test { contract GasPriceOracleEcotone_Test is GasPriceOracle_Test {
......
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