Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
386df4dc
Unverified
Commit
386df4dc
authored
Feb 28, 2022
by
Antonis Kogias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary contract references in integration-tets
parent
bdb8de13
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
240 additions
and
283 deletions
+240
-283
rare-onions-bathe.md
.changeset/rare-onions-bathe.md
+5
-0
bridged-tokens.spec.ts
integration-tests/test/bridged-tokens.spec.ts
+6
-1
fee-payment.spec.ts
integration-tests/test/fee-payment.spec.ts
+32
-16
native-eth-ovm-calls.spec.ts
integration-tests/test/native-eth-ovm-calls.spec.ts
+6
-2
native-eth.spec.ts
integration-tests/test/native-eth.spec.ts
+85
-54
ovmcontext.spec.ts
integration-tests/test/ovmcontext.spec.ts
+9
-8
queue-ingestion.spec.ts
integration-tests/test/queue-ingestion.spec.ts
+17
-13
rpc.spec.ts
integration-tests/test/rpc.spec.ts
+43
-13
env.ts
integration-tests/test/shared/env.ts
+1
-95
stress-test-helpers.ts
integration-tests/test/shared/stress-test-helpers.ts
+26
-26
utils.ts
integration-tests/test/shared/utils.ts
+2
-49
stress-tests.spec.ts
integration-tests/test/stress-tests.spec.ts
+8
-6
No files found.
.changeset/rare-onions-bathe.md
0 → 100644
View file @
386df4dc
---
'
@eth-optimism/integration-tests'
:
patch
---
Replaces contract references in integration tests with SDK CrossChainMessenger objects.
integration-tests/test/bridged-tokens.spec.ts
View file @
386df4dc
/* Imports: External */
import
{
BigNumber
,
Contract
,
ContractFactory
,
utils
,
Wallet
}
from
'
ethers
'
import
{
ethers
}
from
'
hardhat
'
import
{
getContractFactory
}
from
'
@eth-optimism/contracts
'
import
{
MessageStatus
}
from
'
@eth-optimism/sdk
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
/* Imports: Internal */
import
{
expect
}
from
'
./shared/setup
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
withdrawalTest
}
from
'
./shared/utils
'
...
...
@@ -61,7 +63,10 @@ describe('Bridged tokens', () => {
await
L2__ERC20
.
deployed
()
// Approve the L1 ERC20 to spend our money
const
tx
=
await
L1__ERC20
.
approve
(
env
.
l1Bridge
.
address
,
1000000
)
const
tx
=
await
L1__ERC20
.
approve
(
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
address
,
1000000
)
await
tx
.
wait
()
})
...
...
integration-tests/test/fee-payment.spec.ts
View file @
386df4dc
...
...
@@ -5,13 +5,17 @@ import { predeploys, getContractFactory } from '@eth-optimism/contracts'
/* Imports: Internal */
import
{
expect
}
from
'
./shared/setup
'
import
{
hardhatTest
}
from
'
./shared/utils
'
import
{
hardhatTest
,
gasPriceOracleWallet
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
const
setPrices
=
async
(
env
:
OptimismEnv
,
value
:
number
|
BigNumber
)
=>
{
const
gasPrice
=
await
env
.
gasPriceOracle
.
setGasPrice
(
value
)
const
gasPrice
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
setGasPrice
(
value
)
await
gasPrice
.
wait
()
const
baseFee
=
await
env
.
gasPriceOracle
.
setL1BaseFee
(
value
)
const
baseFee
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
setL1BaseFee
(
value
)
await
baseFee
.
wait
()
}
...
...
@@ -28,13 +32,18 @@ describe('Fee Payment Integration Tests', async () => {
async
()
=>
{
const
assertGasPrice
=
async
()
=>
{
const
gasPrice
=
await
env
.
l2Wallet
.
getGasPrice
()
const
oracleGasPrice
=
await
env
.
gasPriceOracle
.
gasPrice
()
const
oracleGasPrice
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
gasPrice
()
expect
(
gasPrice
).
to
.
deep
.
equal
(
oracleGasPrice
)
}
await
assertGasPrice
()
// update the gas price
const
tx
=
await
env
.
gasPriceOracle
.
setGasPrice
(
1000
)
const
tx
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
setGasPrice
(
1000
)
await
tx
.
wait
()
await
assertGasPrice
()
...
...
@@ -47,7 +56,7 @@ describe('Fee Payment Integration Tests', async () => {
const
amount
=
utils
.
parseEther
(
'
0.0000001
'
)
const
balanceBefore
=
await
env
.
l2Wallet
.
getBalance
()
const
feeVaultBalanceBefore
=
await
env
.
l2Wallet
.
provider
.
getBalance
(
env
.
s
equencerFeeVault
.
address
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
address
)
expect
(
balanceBefore
.
gt
(
amount
))
...
...
@@ -66,7 +75,9 @@ describe('Fee Payment Integration Tests', async () => {
data
:
unsigned
.
data
,
})
const
l1Fee
=
await
env
.
gasPriceOracle
.
getL1Fee
(
raw
)
const
l1Fee
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
getL1Fee
(
raw
)
const
tx
=
await
env
.
l2Wallet
.
sendTransaction
(
unsigned
)
const
receipt
=
await
tx
.
wait
()
...
...
@@ -74,7 +85,7 @@ describe('Fee Payment Integration Tests', async () => {
const
balanceAfter
=
await
env
.
l2Wallet
.
getBalance
()
const
feeVaultBalanceAfter
=
await
env
.
l2Wallet
.
provider
.
getBalance
(
env
.
s
equencerFeeVault
.
address
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
address
)
const
l2Fee
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
...
@@ -124,7 +135,9 @@ describe('Fee Payment Integration Tests', async () => {
data
:
unsigned
.
data
,
})
const
l1Fee
=
await
OVM_GasPriceOracle
.
getL1Fee
(
raw
)
const
l1Fee
=
await
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
getL1Fee
(
raw
)
const
tx
=
await
env
.
l2Wallet
.
sendTransaction
(
unsigned
)
const
receipt
=
await
tx
.
wait
()
...
...
@@ -142,30 +155,33 @@ describe('Fee Payment Integration Tests', async () => {
})
it
(
'
should not be able to withdraw fees before the minimum is met
'
,
async
()
=>
{
await
expect
(
env
.
sequencerFeeVault
.
withdraw
()).
to
.
be
.
rejected
await
expect
(
env
.
messenger
.
contracts
.
l2
.
OVM_SequencerFeeVault
.
withdraw
()).
to
.
be
.
rejected
})
hardhatTest
(
'
should be able to withdraw fees back to L1 once the minimum is met
'
,
async
()
=>
{
const
l1FeeWallet
=
await
env
.
sequencerFeeVault
.
l1FeeWallet
()
const
l1FeeWallet
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_SequencerFeeVault
.
l1FeeWallet
()
const
balanceBefore
=
await
env
.
l1Wallet
.
provider
.
getBalance
(
l1FeeWallet
)
const
withdrawalAmount
=
await
env
.
s
equencerFeeVault
.
MIN_WITHDRAWAL_AMOUNT
()
await
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
MIN_WITHDRAWAL_AMOUNT
()
// Transfer the minimum required to withdraw.
const
tx
=
await
env
.
l2Wallet
.
sendTransaction
({
to
:
env
.
s
equencerFeeVault
.
address
,
to
:
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
address
,
value
:
withdrawalAmount
,
gasLimit
:
500000
,
})
await
tx
.
wait
()
const
vaultBalance
=
await
env
.
ovmEth
.
balanceOf
(
env
.
s
equencerFeeVault
.
address
const
vaultBalance
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_ETH
.
balanceOf
(
env
.
messenger
.
contracts
.
l2
.
OVM_S
equencerFeeVault
.
address
)
const
withdrawTx
=
await
env
.
sequencerFeeVault
.
withdraw
()
const
withdrawTx
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_SequencerFeeVault
.
withdraw
()
// Wait for the withdrawal to be relayed to L1.
await
withdrawTx
.
wait
()
...
...
integration-tests/test/native-eth-ovm-calls.spec.ts
View file @
386df4dc
/* Imports: External */
import
{
BigNumber
,
Contract
,
ContractFactory
,
Wallet
}
from
'
ethers
'
import
{
ethers
}
from
'
hardhat
'
/* Imports: Internal */
import
{
expect
}
from
'
./shared/setup
'
import
{
fundUser
,
...
...
@@ -121,8 +123,10 @@ describe('Native ETH value integration tests', () => {
'
geth RPC does not match ovmSELFBALANCE
'
)
// query ovmSELFBALANCE() opcode via eth_call as another check
const
ovmEthBalanceOf0
=
await
env
.
ovmEth
.
balanceOf
(
ValueCalls0
.
address
)
const
ovmEthBalanceOf1
=
await
env
.
ovmEth
.
balanceOf
(
ValueCalls1
.
address
)
const
ovmEthBalanceOf0
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_ETH
.
balanceOf
(
ValueCalls0
.
address
)
const
ovmEthBalanceOf1
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_ETH
.
balanceOf
(
ValueCalls1
.
address
)
expect
(
ovmEthBalanceOf0
).
to
.
deep
.
eq
(
BigNumber
.
from
(
expectedBalances
[
0
]),
'
geth RPC does not match OVM_ETH.balanceOf
'
...
...
integration-tests/test/native-eth.spec.ts
View file @
386df4dc
...
...
@@ -11,6 +11,7 @@ import {
DEFAULT_TEST_GAS_L2
,
envConfig
,
withdrawalTest
,
gasPriceOracleWallet
,
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
...
...
@@ -30,7 +31,7 @@ describe('Native ETH Integration Tests', async () => {
const
l2BobBalance
=
await
l2Bob
.
getBalance
()
const
l1BridgeBalance
=
await
_env
.
l1Wallet
.
provider
.
getBalance
(
_env
.
l1
Bridge
.
address
_env
.
messenger
.
contracts
.
l1
.
L1Standard
Bridge
.
address
)
return
{
...
...
@@ -51,7 +52,8 @@ describe('Native ETH Integration Tests', async () => {
describe
(
'
estimateGas
'
,
()
=>
{
it
(
'
Should estimate gas for ETH withdraw
'
,
async
()
=>
{
const
amount
=
utils
.
parseEther
(
'
0.0000001
'
)
const
gas
=
await
env
.
l2Bridge
.
estimateGas
.
withdraw
(
const
gas
=
await
env
.
messenger
.
contracts
.
l2
.
L2StandardBridge
.
estimateGas
.
withdraw
(
predeploys
.
OVM_ETH
,
amount
,
0
,
...
...
@@ -67,7 +69,7 @@ describe('Native ETH Integration Tests', async () => {
const
preBalances
=
await
getBalances
(
env
)
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
env
.
l1Wallet
.
sendTransaction
({
to
:
env
.
l1
Bridge
.
address
,
to
:
env
.
messenger
.
contracts
.
l1
.
L1Standard
Bridge
.
address
,
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
})
...
...
@@ -91,10 +93,14 @@ describe('Native ETH Integration Tests', async () => {
const
depositAmount
=
10
const
preBalances
=
await
getBalances
(
env
)
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
})
}
)
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
...
@@ -115,10 +121,15 @@ describe('Native ETH Integration Tests', async () => {
const
depositAmount
=
10
const
preBalances
=
await
getBalances
(
env
)
const
depositReceipts
=
await
env
.
waitForXDomainTransaction
(
env
.
l1Bridge
.
depositETHTo
(
l2Bob
.
address
,
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETHTo
(
l2Bob
.
address
,
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
})
}
)
)
const
l1FeePaid
=
depositReceipts
.
receipt
.
gasUsed
.
mul
(
...
...
@@ -145,10 +156,14 @@ describe('Native ETH Integration Tests', async () => {
// to allow for encoding and other arguments
const
data
=
`0x`
+
'
ab
'
.
repeat
(
MAX_ROLLUP_TX_SIZE
-
500
)
const
{
tx
,
receipt
}
=
await
env
.
waitForXDomainTransaction
(
env
.
l1Bridge
.
depositETH
(
ASSUMED_L2_GAS_LIMIT
,
data
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETH
(
ASSUMED_L2_GAS_LIMIT
,
data
,
{
value
:
depositAmount
,
gasLimit
:
4
_000_000
,
})
}
)
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
...
@@ -169,9 +184,13 @@ describe('Native ETH Integration Tests', async () => {
const
data
=
`0x`
+
'
ab
'
.
repeat
(
MAX_ROLLUP_TX_SIZE
+
1
)
await
expect
(
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
data
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
data
,
{
value
:
depositAmount
,
})
}
)
).
to
.
be
.
reverted
})
...
...
@@ -183,7 +202,8 @@ describe('Native ETH Integration Tests', async () => {
'
Cannot run withdrawal test before any deposits...
'
)
const
transaction
=
await
env
.
l2Bridge
.
withdraw
(
const
transaction
=
await
env
.
messenger
.
contracts
.
l2
.
L2StandardBridge
.
withdraw
(
predeploys
.
OVM_ETH
,
withdrawAmount
,
DEFAULT_TEST_GAS_L2
,
...
...
@@ -224,7 +244,8 @@ describe('Native ETH Integration Tests', async () => {
'
Cannot run withdrawal test before any deposits...
'
)
const
transaction
=
await
env
.
l2Bridge
.
withdrawTo
(
const
transaction
=
await
env
.
messenger
.
contracts
.
l2
.
L2StandardBridge
.
withdrawTo
(
predeploys
.
OVM_ETH
,
l1Bob
.
address
,
withdrawAmount
,
...
...
@@ -248,7 +269,9 @@ describe('Native ETH Integration Tests', async () => {
data
:
transaction
.
data
,
})
const
l1Fee
=
await
env
.
gasPriceOracle
.
getL1Fee
(
raw
)
const
l1Fee
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
getL1Fee
(
raw
)
const
fee
=
l2Fee
.
add
(
l1Fee
)
const
postBalances
=
await
getBalances
(
env
)
...
...
@@ -275,10 +298,14 @@ describe('Native ETH Integration Tests', async () => {
// 1. deposit
const
amount
=
utils
.
parseEther
(
'
1
'
)
await
env
.
waitForXDomainTransaction
(
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
messenger
.
contracts
.
l1
.
L1StandardBridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
value
:
amount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
})
}
)
)
// 2. transfer to another address
...
...
@@ -295,9 +322,10 @@ describe('Native ETH Integration Tests', async () => {
// 3. do withdrawal
const
withdrawnAmount
=
utils
.
parseEther
(
'
0.95
'
)
const
transaction
=
await
env
.
l2Bridge
.
connect
(
other
)
.
withdraw
(
const
transaction
=
await
env
.
messenger
.
contracts
.
l2
.
L2StandardBridge
.
connect
(
other
).
withdraw
(
predeploys
.
OVM_ETH
,
withdrawnAmount
,
DEFAULT_TEST_GAS_L1
,
...
...
@@ -308,7 +336,10 @@ describe('Native ETH Integration Tests', async () => {
const
receipts
=
await
env
.
waitForXDomainTransaction
(
transaction
)
// Compute the L1 portion of the fee
const
l1Fee
=
await
env
.
gasPriceOracle
.
getL1Fee
(
const
l1Fee
=
await
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
getL1Fee
(
serialize
({
nonce
:
transaction
.
nonce
,
value
:
transaction
.
value
,
...
...
integration-tests/test/ovmcontext.spec.ts
View file @
386df4dc
...
...
@@ -44,7 +44,8 @@ describe('OVM Context: Layer 2 EVM Context', () => {
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
// Send a transaction from L1 to L2. This will automatically update the L1 contextual
// information like the L1 block number and L1 timestamp.
const
tx
=
await
env
.
l1Messenger
.
sendMessage
(
const
tx
=
await
env
.
messenger
.
contracts
.
l1
.
L1CrossDomainMessenger
.
sendMessage
(
OVMContextStorage
.
address
,
'
0x
'
,
2
_000_000
,
...
...
integration-tests/test/queue-ingestion.spec.ts
View file @
386df4dc
...
...
@@ -26,7 +26,8 @@ describe('Queue Ingestion', () => {
// the transaction to Layer 1
const
txs
=
[]
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
const
tx
=
await
env
.
l1Messenger
.
sendMessage
(
const
tx
=
await
env
.
messenger
.
contracts
.
l1
.
L1CrossDomainMessenger
.
sendMessage
(
`0x
${
`
${
i
}
`
.
repeat
(
40
)}
`
,
`0x0
${
i
}
`
,
1
_000_000
,
...
...
@@ -46,7 +47,8 @@ describe('Queue Ingestion', () => {
receipt
.
remoteTx
.
hash
))
as
any
const
params
=
env
.
l2Messenger
.
interface
.
decodeFunctionData
(
const
params
=
env
.
messenger
.
contracts
.
l2
.
L2CrossDomainMessenger
.
interface
.
decodeFunctionData
(
'
relayMessage
'
,
l2Tx
.
data
)
...
...
@@ -57,7 +59,9 @@ describe('Queue Ingestion', () => {
expect
(
params
.
_target
).
to
.
equal
(
'
0x
'
+
`
${
i
}
`
.
repeat
(
40
))
expect
(
l2Tx
.
queueOrigin
).
to
.
equal
(
'
l1
'
)
expect
(
l2Tx
.
l1TxOrigin
.
toLowerCase
()).
to
.
equal
(
applyL1ToL2Alias
(
env
.
l1Messenger
.
address
).
toLowerCase
()
applyL1ToL2Alias
(
env
.
messenger
.
contracts
.
l1
.
L1CrossDomainMessenger
.
address
).
toLowerCase
()
)
expect
(
l2Tx
.
l1BlockNumber
).
to
.
equal
(
l1TxReceipt
.
blockNumber
)
}
...
...
integration-tests/test/rpc.spec.ts
View file @
386df4dc
...
...
@@ -17,6 +17,7 @@ import {
isHardhat
,
hardhatTest
,
envConfig
,
gasPriceOracleWallet
,
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
expect
}
from
'
./shared/setup
'
...
...
@@ -149,8 +150,12 @@ describe('Basic RPC tests', () => {
const
isHH
=
await
isHardhat
()
let
gasPrice
if
(
isHH
)
{
gasPrice
=
await
env
.
gasPriceOracle
.
gasPrice
()
await
env
.
gasPriceOracle
.
setGasPrice
(
1000
)
gasPrice
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
gasPrice
()
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
setGasPrice
(
1000
)
}
const
tx
=
{
...
...
@@ -164,12 +169,17 @@ describe('Basic RPC tests', () => {
if
(
isHH
)
{
// Reset the gas price to its original price
await
env
.
gasPriceOracle
.
setGasPrice
(
gasPrice
)
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
setGasPrice
(
gasPrice
)
}
})
it
(
'
should reject a transaction with too high of a fee
'
,
async
()
=>
{
const
gasPrice
=
await
env
.
gasPriceOracle
.
gasPrice
()
const
gasPrice
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
gasPrice
()
const
largeGasPrice
=
gasPrice
.
mul
(
10
)
const
tx
=
{
...
defaultTransactionFactory
(),
...
...
@@ -341,11 +351,25 @@ describe('Basic RPC tests', () => {
data
:
tx
.
data
,
})
const
l1Fee
=
await
env
.
gasPriceOracle
.
getL1Fee
(
raw
)
const
l1GasPrice
=
await
env
.
gasPriceOracle
.
l1BaseFee
()
const
l1GasUsed
=
await
env
.
gasPriceOracle
.
getL1GasUsed
(
raw
)
const
scalar
=
await
env
.
gasPriceOracle
.
scalar
()
const
decimals
=
await
env
.
gasPriceOracle
.
decimals
()
const
l1Fee
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
getL1Fee
(
raw
)
const
l1GasPrice
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
l1BaseFee
()
const
l1GasUsed
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
getL1GasUsed
(
raw
)
const
scalar
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
scalar
()
const
decimals
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
decimals
()
const
scaled
=
scalar
.
toNumber
()
/
10
**
decimals
.
toNumber
()
...
...
@@ -439,7 +463,8 @@ describe('Basic RPC tests', () => {
describe
(
'
eth_getBalance
'
,
()
=>
{
it
(
'
should get the OVM_ETH balance
'
,
async
()
=>
{
const
rpcBalance
=
await
env
.
l2Provider
.
getBalance
(
env
.
l2Wallet
.
address
)
const
contractBalance
=
await
env
.
ovmEth
.
balanceOf
(
env
.
l2Wallet
.
address
)
const
contractBalance
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_ETH
.
balanceOf
(
env
.
l2Wallet
.
address
)
expect
(
rpcBalance
).
to
.
be
.
deep
.
eq
(
contractBalance
)
})
})
...
...
@@ -525,9 +550,14 @@ describe('Basic RPC tests', () => {
describe
(
'
rollup_gasPrices
'
,
()
=>
{
it
(
'
should return the L1 and L2 gas prices
'
,
async
()
=>
{
const
result
=
await
env
.
l2Provider
.
send
(
'
rollup_gasPrices
'
,
[])
const
l1GasPrice
=
await
env
.
gasPriceOracle
.
l1BaseFee
()
const
l2GasPrice
=
await
env
.
gasPriceOracle
.
gasPrice
()
const
l1GasPrice
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
l1BaseFee
()
const
l2GasPrice
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_GasPriceOracle
.
connect
(
gasPriceOracleWallet
).
gasPrice
()
expect
(
BigNumber
.
from
(
result
.
l1GasPrice
)).
to
.
deep
.
eq
(
l1GasPrice
)
expect
(
BigNumber
.
from
(
result
.
l2GasPrice
)).
to
.
deep
.
eq
(
l2GasPrice
)
})
...
...
integration-tests/test/shared/env.ts
View file @
386df4dc
/* Imports: External */
import
{
Contract
,
utils
,
Wallet
,
providers
,
Transaction
}
from
'
ethers
'
import
{
utils
,
Wallet
,
providers
,
Transaction
}
from
'
ethers
'
import
{
TransactionResponse
,
TransactionReceipt
,
}
from
'
@ethersproject/providers
'
import
{
getContractFactory
,
predeploys
}
from
'
@eth-optimism/contracts
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
CrossChainMessenger
,
...
...
@@ -14,18 +13,13 @@ import {
/* Imports: Internal */
import
{
getAddressManager
,
l1Provider
,
l2Provider
,
replicaProvider
,
verifierProvider
,
l1Wallet
,
l2Wallet
,
gasPriceOracleWallet
,
fundUser
,
getOvmEth
,
getL1Bridge
,
getL2Bridge
,
envConfig
,
}
from
'
./utils
'
...
...
@@ -38,21 +32,6 @@ export interface CrossDomainMessagePair {
/// Helper class for instantiating a test environment with a funded account
export
class
OptimismEnv
{
// L1 Contracts
addressManager
:
Contract
l1Bridge
:
Contract
l1Messenger
:
Contract
l1BlockNumber
:
Contract
ctc
:
Contract
scc
:
Contract
// L2 Contracts
ovmEth
:
Contract
l2Bridge
:
Contract
l2Messenger
:
Contract
gasPriceOracle
:
Contract
sequencerFeeVault
:
Contract
// The wallets
l1Wallet
:
Wallet
l2Wallet
:
Wallet
...
...
@@ -65,15 +44,6 @@ export class OptimismEnv {
verifierProvider
:
providers
.
JsonRpcProvider
constructor
(
args
:
any
)
{
this
.
addressManager
=
args
.
addressManager
this
.
l1Bridge
=
args
.
l1Bridge
this
.
l1Messenger
=
args
.
l1Messenger
this
.
l1BlockNumber
=
args
.
l1BlockNumber
this
.
ovmEth
=
args
.
ovmEth
this
.
l2Bridge
=
args
.
l2Bridge
this
.
l2Messenger
=
args
.
l2Messenger
this
.
gasPriceOracle
=
args
.
gasPriceOracle
this
.
sequencerFeeVault
=
args
.
sequencerFeeVault
this
.
l1Wallet
=
args
.
l1Wallet
this
.
l2Wallet
=
args
.
l2Wallet
this
.
messenger
=
args
.
messenger
...
...
@@ -81,68 +51,15 @@ export class OptimismEnv {
this
.
l2Provider
=
args
.
l2Provider
this
.
replicaProvider
=
args
.
replicaProvider
this
.
verifierProvider
=
args
.
verifierProvider
this
.
ctc
=
args
.
ctc
this
.
scc
=
args
.
scc
}
static
async
new
():
Promise
<
OptimismEnv
>
{
const
network
=
await
l1Provider
.
getNetwork
()
const
addressManager
=
getAddressManager
(
l1Wallet
)
const
l1Bridge
=
await
getL1Bridge
(
l1Wallet
,
addressManager
)
const
l1MessengerAddress
=
await
addressManager
.
getAddress
(
'
Proxy__OVM_L1CrossDomainMessenger
'
)
const
l2MessengerAddress
=
await
addressManager
.
getAddress
(
'
L2CrossDomainMessenger
'
)
const
l1Messenger
=
getContractFactory
(
'
L1CrossDomainMessenger
'
)
.
connect
(
l1Wallet
)
.
attach
(
l1MessengerAddress
)
const
ovmEth
=
getOvmEth
(
l2Wallet
)
const
l2Bridge
=
await
getL2Bridge
(
l2Wallet
)
const
l2Messenger
=
getContractFactory
(
'
L2CrossDomainMessenger
'
)
.
connect
(
l2Wallet
)
.
attach
(
l2MessengerAddress
)
const
ctcAddress
=
await
addressManager
.
getAddress
(
'
CanonicalTransactionChain
'
)
const
ctc
=
getContractFactory
(
'
CanonicalTransactionChain
'
)
.
connect
(
l1Wallet
)
.
attach
(
ctcAddress
)
const
gasPriceOracle
=
getContractFactory
(
'
OVM_GasPriceOracle
'
)
.
connect
(
gasPriceOracleWallet
)
.
attach
(
predeploys
.
OVM_GasPriceOracle
)
const
sccAddress
=
await
addressManager
.
getAddress
(
'
StateCommitmentChain
'
)
const
scc
=
getContractFactory
(
'
StateCommitmentChain
'
)
.
connect
(
l1Wallet
)
.
attach
(
sccAddress
)
const
sequencerFeeVault
=
getContractFactory
(
'
OVM_SequencerFeeVault
'
)
.
connect
(
l2Wallet
)
.
attach
(
predeploys
.
OVM_SequencerFeeVault
)
const
l1BlockNumber
=
getContractFactory
(
'
iOVM_L1BlockNumber
'
)
.
connect
(
l2Wallet
)
.
attach
(
predeploys
.
OVM_L1BlockNumber
)
const
messenger
=
new
CrossChainMessenger
({
l1SignerOrProvider
:
l1Wallet
,
l2SignerOrProvider
:
l2Wallet
,
l1ChainId
:
network
.
chainId
,
contracts
:
{
l1
:
{
AddressManager
:
envConfig
.
ADDRESS_MANAGER
,
L1CrossDomainMessenger
:
l1Messenger
.
address
,
L1StandardBridge
:
l1Bridge
.
address
,
StateCommitmentChain
:
sccAddress
,
CanonicalTransactionChain
:
ctcAddress
,
BondManager
:
await
addressManager
.
getAddress
(
'
BondManager
'
),
},
},
})
// fund the user if needed
...
...
@@ -154,17 +71,6 @@ export class OptimismEnv {
}
return
new
OptimismEnv
({
addressManager
,
l1Bridge
,
ctc
,
scc
,
l1Messenger
,
l1BlockNumber
,
ovmEth
,
gasPriceOracle
,
sequencerFeeVault
,
l2Bridge
,
l2Messenger
,
l1Wallet
,
l2Wallet
,
messenger
,
...
...
integration-tests/test/shared/stress-test-helpers.ts
View file @
386df4dc
...
...
@@ -37,9 +37,9 @@ export const executeL1ToL2Transaction = async (
)
=>
{
const
signer
=
wallet
.
connect
(
env
.
l1Wallet
.
provider
)
const
receipt
=
await
retryOnNonceError
(
async
()
=>
env
.
l1Messenger
.
connect
(
signer
)
.
sendMessage
(
env
.
messenger
.
contracts
.
l1
.
L1CrossDomainMessenger
.
connect
(
signer
)
.
sendMessage
(
tx
.
contract
.
address
,
tx
.
contract
.
interface
.
encodeFunctionData
(
tx
.
functionName
,
...
...
@@ -61,9 +61,9 @@ export const executeL2ToL1Transaction = async (
)
=>
{
const
signer
=
wallet
.
connect
(
env
.
l2Wallet
.
provider
)
const
receipt
=
await
retryOnNonceError
(()
=>
env
.
l2Messenger
.
connect
(
signer
)
.
sendMessage
(
env
.
messenger
.
contracts
.
l2
.
L2CrossDomainMessenger
.
connect
(
signer
)
.
sendMessage
(
tx
.
contract
.
address
,
tx
.
contract
.
interface
.
encodeFunctionData
(
tx
.
functionName
,
...
...
integration-tests/test/shared/utils.ts
View file @
386df4dc
/* Imports: External */
import
{
Contract
,
Wallet
,
constants
,
providers
,
BigNumber
,
utils
,
}
from
'
ethers
'
import
{
getContractFactory
,
getContractInterface
,
predeploys
,
}
from
'
@eth-optimism/contracts
'
import
{
Wallet
,
providers
,
BigNumber
,
utils
}
from
'
ethers
'
import
{
predeploys
}
from
'
@eth-optimism/contracts
'
import
{
remove0x
}
from
'
@eth-optimism/core-utils
'
import
{
CrossChainMessenger
,
...
...
@@ -71,9 +60,6 @@ const procEnv = cleanEnv(process.env, {
default
:
'
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
'
,
}),
ADDRESS_MANAGER
:
str
({
default
:
'
0x5FbDB2315678afecb367f032d93F642f64180aa3
'
,
}),
GAS_PRICE_ORACLE_PRIVATE_KEY
:
str
({
default
:
'
0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
'
,
...
...
@@ -149,39 +135,6 @@ export const OVM_ETH_ADDRESS = predeploys.OVM_ETH
export
const
L2_CHAINID
=
procEnv
.
L2_CHAINID
export
const
getAddressManager
=
(
provider
:
any
)
=>
{
return
getContractFactory
(
'
Lib_AddressManager
'
)
.
connect
(
provider
)
.
attach
(
procEnv
.
ADDRESS_MANAGER
)
}
// Gets the bridge contract
export
const
getL1Bridge
=
async
(
wallet
:
Wallet
,
AddressManager
:
Contract
)
=>
{
const
l1BridgeInterface
=
getContractInterface
(
'
L1StandardBridge
'
)
const
ProxyBridgeAddress
=
await
AddressManager
.
getAddress
(
'
Proxy__OVM_L1StandardBridge
'
)
if
(
!
utils
.
isAddress
(
ProxyBridgeAddress
)
||
ProxyBridgeAddress
===
constants
.
AddressZero
)
{
throw
new
Error
(
'
Proxy__OVM_L1StandardBridge not found
'
)
}
return
new
Contract
(
ProxyBridgeAddress
,
l1BridgeInterface
,
wallet
)
}
export
const
getL2Bridge
=
async
(
wallet
:
Wallet
)
=>
{
const
L2BridgeInterface
=
getContractInterface
(
'
L2StandardBridge
'
)
return
new
Contract
(
predeploys
.
L2StandardBridge
,
L2BridgeInterface
,
wallet
)
}
export
const
getOvmEth
=
(
wallet
:
Wallet
)
=>
{
return
new
Contract
(
OVM_ETH_ADDRESS
,
getContractInterface
(
'
OVM_ETH
'
),
wallet
)
}
export
const
fundUser
=
async
(
messenger
:
CrossChainMessenger
,
amount
:
NumberLike
,
...
...
integration-tests/test/stress-tests.spec.ts
View file @
386df4dc
...
...
@@ -210,7 +210,8 @@ describe('stress tests', () => {
const
tip
=
await
env
.
l2Provider
.
getBlock
(
'
latest
'
)
const
prev
=
{
block
:
await
env
.
l2Provider
.
getBlock
(
0
),
l1BlockNumber
:
await
env
.
l1BlockNumber
.
getL1BlockNumber
({
l1BlockNumber
:
await
env
.
messenger
.
contracts
.
l2
.
OVM_L1BlockNumber
.
getL1BlockNumber
({
blockTag
:
0
,
}),
}
...
...
@@ -218,7 +219,8 @@ describe('stress tests', () => {
const
block
=
await
env
.
l2Provider
.
getBlock
(
i
)
expect
(
block
.
timestamp
).
to
.
be
.
gte
(
prev
.
block
.
timestamp
)
const
l1BlockNumber
=
await
env
.
l1BlockNumber
.
getL1BlockNumber
({
const
l1BlockNumber
=
await
env
.
messenger
.
contracts
.
l2
.
OVM_L1BlockNumber
.
getL1BlockNumber
({
blockTag
:
i
,
})
expect
(
l1BlockNumber
.
gt
(
prev
.
l1BlockNumber
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment