Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/contracts-bedrock/test/L1/L2OutputOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,31 @@ contract L2OutputOracle_getter_Test is L2OutputOracle_TestBase {
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
/// when the input is the exact block number of the proposal.
function test_getL2OutputIndexAfter_sameBlock_succeeds() external {
Expand Down
20 changes: 20 additions & 0 deletions packages/contracts-bedrock/test/L2/GasPriceOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ contract GasPriceOracleBedrock_Test is GasPriceOracle_Test {
vm.expectRevert("GasPriceOracle: Fjord can only be activated after Ecotone");
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 {
Expand Down