forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ethereum-optimism#91 from ethereum-optimism/m/add-…
…l1-attributes-contract Add L1Block values contract
- Loading branch information
Showing
5 changed files
with
103 additions
and
18 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.10; | ||
|
||
/** | ||
* @title L1Block | ||
*/ | ||
contract L1Block { | ||
address constant depositorAccount = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001; | ||
|
||
uint256 public number; | ||
uint256 public timestamp; | ||
uint256 public basefee; | ||
bytes32 public hash; | ||
|
||
function setL1BlockValues( | ||
uint256 _number, | ||
uint256 _timestamp, | ||
uint256 _basefee, | ||
bytes32 _hash | ||
) external { | ||
require( | ||
msg.sender == depositorAccount, | ||
"Only callable by L1 Attributes Depositor Account" | ||
); | ||
|
||
number = _number; | ||
timestamp = _timestamp; | ||
basefee = _basefee; | ||
hash = _hash; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { expect } from 'chai' | ||
import { ethers } from 'hardhat' | ||
import { Signer } from 'ethers' | ||
|
||
import { L1Block__factory, L1Block } from '../../typechain' | ||
|
||
const DEPOSITOR_ACCOUNT = '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001' | ||
const NON_ZERO_HASH = '0x' + 'ab'.repeat(32) | ||
|
||
describe('L1Block contract', () => { | ||
let signer: Signer | ||
let signerAddress: string | ||
let l1Block: L1Block | ||
let depositor: Signer | ||
before(async () => { | ||
;[signer] = await ethers.getSigners() | ||
signerAddress = await signer.getAddress() | ||
l1Block = await new L1Block__factory(signer).deploy() | ||
await l1Block.deployed() | ||
|
||
depositor = await ethers.getSigner(DEPOSITOR_ACCOUNT) | ||
|
||
}) | ||
|
||
it('setL1BlockValues: Should revert if not called by L1 Attributes Depositor Account', async () => { | ||
|
||
}) | ||
|
||
describe('Should return the correct block values for:', async () => { | ||
before(async () => { | ||
await ethers.provider.send('hardhat_impersonateAccount', [ | ||
DEPOSITOR_ACCOUNT | ||
]) | ||
await ethers.provider.send('hardhat_setBalance', [ | ||
DEPOSITOR_ACCOUNT, '0xFFFFFFFFFFFF' | ||
]) | ||
await l1Block.connect(depositor).setL1BlockValues(1, 2, 3, NON_ZERO_HASH) | ||
await ethers.provider.send('hardhat_stopImpersonatingAccount', [ | ||
DEPOSITOR_ACCOUNT | ||
]) | ||
l1Block.connect(signer) | ||
}) | ||
|
||
it('number', async () => { | ||
expect(await l1Block.number()).to.equal(1) | ||
}) | ||
|
||
it('timestamp', async () => { | ||
expect(await l1Block.timestamp()).to.equal(2) | ||
}) | ||
|
||
it('basefee', async () => { | ||
expect(await l1Block.basefee()).to.equal(3) | ||
}) | ||
|
||
it('hash', async () => { | ||
expect(await l1Block.hash()).to.equal(NON_ZERO_HASH) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters