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
f5c29ddd
Commit
f5c29ddd
authored
Apr 30, 2021
by
Liam Horne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: use mocha globals for integration test docker setup
parent
5a1cd418
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
55 additions
and
74 deletions
+55
-74
mocha.opts
integration-tests/mocha.opts
+1
-0
basic-l1-l2-communication.spec.ts
integration-tests/test/basic-l1-l2-communication.spec.ts
+0
-6
erc20.spec.ts
integration-tests/test/erc20.spec.ts
+0
-6
fee-payment.spec.ts
integration-tests/test/fee-payment.spec.ts
+0
-5
native-eth.spec.ts
integration-tests/test/native-eth.spec.ts
+0
-6
ovmcontext.spec.ts
integration-tests/test/ovmcontext.spec.ts
+13
-14
queue-ingestion.spec.ts
integration-tests/test/queue-ingestion.spec.ts
+0
-5
read-proxy-event.spec.ts
integration-tests/test/read-proxy-event.spec.ts
+0
-6
rpc.spec.ts
integration-tests/test/rpc.spec.ts
+2
-8
setup-docker-compose-network.js
integration-tests/test/setup-docker-compose-network.js
+6
-0
docker-compose.ts
integration-tests/test/shared/docker-compose.ts
+24
-14
utils.ts
integration-tests/test/shared/utils.ts
+9
-4
No files found.
integration-tests/mocha.opts
0 → 100644
View file @
f5c29ddd
--file ./test/setup-docker-compose-network.js
\ No newline at end of file
integration-tests/test/basic-l1-l2-communication.spec.ts
View file @
f5c29ddd
...
...
@@ -8,12 +8,6 @@ import { Direction } from './shared/watcher-utils'
import
l1SimpleStorageJson
from
'
../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json
'
import
l2SimpleStorageJson
from
'
../artifacts-ovm/contracts/SimpleStorage.sol/SimpleStorage.json
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DockerComposeNetwork
}
from
'
./shared/docker-compose
'
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
describe
(
'
Basic L1<>L2 Communication
'
,
async
()
=>
{
let
Factory__L1SimpleStorage
:
ContractFactory
...
...
integration-tests/test/erc20.spec.ts
View file @
f5c29ddd
...
...
@@ -3,12 +3,6 @@ import { ethers } from 'hardhat'
import
{
expect
}
from
'
chai
'
import
{
GWEI
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DockerComposeNetwork
}
from
'
./shared/docker-compose
'
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
describe
(
'
Basic ERC20 interactions
'
,
async
()
=>
{
const
initialAmount
=
1000
...
...
integration-tests/test/fee-payment.spec.ts
View file @
f5c29ddd
...
...
@@ -3,11 +3,6 @@ import chaiAsPromised from 'chai-as-promised'
chai
.
use
(
chaiAsPromised
)
import
{
BigNumber
,
utils
}
from
'
ethers
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DockerComposeNetwork
}
from
'
./shared/docker-compose
'
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
describe
(
'
Fee Payment Integration Tests
'
,
async
()
=>
{
let
env
:
OptimismEnv
...
...
integration-tests/test/native-eth.spec.ts
View file @
f5c29ddd
...
...
@@ -2,15 +2,9 @@ import { expect } from 'chai'
import
{
Wallet
,
utils
,
BigNumber
}
from
'
ethers
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
DockerComposeNetwork
}
from
'
./shared/docker-compose
'
import
{
PROXY_SEQUENCER_ENTRYPOINT_ADDRESS
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
describe
(
'
Native ETH Integration Tests
'
,
async
()
=>
{
let
env
:
OptimismEnv
let
l1Bob
:
Wallet
...
...
integration-tests/test/ovmcontext.spec.ts
View file @
f5c29ddd
...
...
@@ -8,15 +8,9 @@ import {
getAddressManager
,
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DockerComposeNetwork
}
from
'
./shared/docker-compose
'
import
{
getContractFactory
}
from
'
@eth-optimism/contracts
'
import
{
Contract
,
ContractFactory
,
Wallet
,
BigNumber
}
from
'
ethers
'
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
/**
* These tests cover the OVM execution contexts. In the OVM execution
* of a L1 to L2 transaction, both `block.number` and `block.timestamp`
...
...
@@ -111,16 +105,21 @@ describe('OVM Context: Layer 2 EVM Context', () => {
for
(
let
i
=
start
;
i
<
tip
.
number
;
i
++
)
{
const
block
=
await
L2Provider
.
getBlockWithTransactions
(
i
)
const
[,
returnData
]
=
await
OVMMulticall
.
callStatic
.
aggregate
([
[
OVMMulticall
.
address
,
OVMMulticall
.
interface
.
encodeFunctionData
(
'
getCurrentBlockTimestamp
'
),
],
const
[,
returnData
]
=
await
OVMMulticall
.
callStatic
.
aggregate
(
[
OVMMulticall
.
address
,
OVMMulticall
.
interface
.
encodeFunctionData
(
'
getCurrentBlockNumber
'
),
[
OVMMulticall
.
address
,
OVMMulticall
.
interface
.
encodeFunctionData
(
'
getCurrentBlockTimestamp
'
),
],
[
OVMMulticall
.
address
,
OVMMulticall
.
interface
.
encodeFunctionData
(
'
getCurrentBlockNumber
'
),
],
],
],
{
blockTag
:
i
})
{
blockTag
:
i
}
)
const
timestamp
=
BigNumber
.
from
(
returnData
[
0
])
const
blockNumber
=
BigNumber
.
from
(
returnData
[
1
])
...
...
integration-tests/test/queue-ingestion.spec.ts
View file @
f5c29ddd
...
...
@@ -2,16 +2,11 @@
import
{
injectL2Context
}
from
'
@eth-optimism/core-utils
'
import
{
sleep
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DockerComposeNetwork
}
from
'
./shared/docker-compose
'
/* Imports: External */
import
{
providers
}
from
'
ethers
'
import
{
expect
}
from
'
chai
'
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
// This test ensures that the transactions which get `enqueue`d get
// added to the L2 blocks by the Sync Service (which queries the DTL)
describe
(
'
Queue Ingestion
'
,
()
=>
{
...
...
integration-tests/test/read-proxy-event.spec.ts
View file @
f5c29ddd
...
...
@@ -4,12 +4,6 @@ import { ethers } from 'hardhat'
/* Imports: External */
import
{
Contract
,
Wallet
}
from
'
ethers
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DockerComposeNetwork
}
from
'
./shared/docker-compose
'
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
describe
(
'
Reading events from proxy contracts
'
,
()
=>
{
let
l2Wallet
:
Wallet
...
...
integration-tests/test/rpc.spec.ts
View file @
f5c29ddd
import
{
injectL2Context
}
from
'
@eth-optimism/core-utils
'
import
{
Wallet
,
BigNumber
}
from
'
ethers
'
import
chai
,
{
expect
}
from
'
chai
'
import
{
sleep
,
l2Provider
,
GWEI
}
from
'
./shared/utils
'
import
chaiAsPromised
from
'
chai-as-promised
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DockerComposeNetwork
}
from
'
./shared/docker-compose
'
chai
.
use
(
chaiAsPromised
)
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
describe
(
'
Basic RPC tests
'
,
()
=>
{
let
env
:
OptimismEnv
...
...
@@ -161,8 +155,8 @@ describe('Basic RPC tests', () => {
// 96 bytes * 16 per non zero byte
const
onesCost
=
BigNumber
.
from
(
96
).
mul
(
16
)
const
expectedCost
=
dataLen
.
map
(
len
=>
BigNumber
.
from
(
len
).
mul
(
4
))
.
map
(
zerosCost
=>
zerosCost
.
add
(
onesCost
))
.
map
(
(
len
)
=>
BigNumber
.
from
(
len
).
mul
(
4
))
.
map
(
(
zerosCost
)
=>
zerosCost
.
add
(
onesCost
))
// Repeat this test for a series of possible transaction sizes.
for
(
let
i
=
0
;
i
<
dataLen
.
length
;
i
++
)
{
...
...
integration-tests/test/setup-docker-compose-network.js
0 → 100644
View file @
f5c29ddd
const
{
DockerComposeNetwork
}
=
require
(
"
./shared/docker-compose
"
)
before
(
async
()
=>
{
await
new
DockerComposeNetwork
().
up
()
})
\ No newline at end of file
integration-tests/test/shared/docker-compose.ts
View file @
f5c29ddd
...
...
@@ -2,28 +2,38 @@ import * as compose from 'docker-compose'
import
*
as
shell
from
'
shelljs
'
import
*
as
path
from
'
path
'
type
ServiceNames
=
'
batch_submitter
'
|
'
dtl
'
|
'
l2geth
'
|
'
relayer
'
const
OPS_DIRECTORY
=
path
.
join
(
process
.
cwd
(),
'
../ops
'
)
const
DEFAULT_SERVICES
:
ServiceNames
[]
=
[
'
batch_submitter
'
,
'
dtl
'
,
'
l2geth
'
,
'
relayer
'
]
const
DEFAULT_SERVICES
:
ServiceNames
[]
=
[
'
batch_submitter
'
,
'
dtl
'
,
'
l2geth
'
,
'
relayer
'
,
]
export
class
DockerComposeNetwork
{
constructor
(
private
readonly
services
:
ServiceNames
[]
=
DEFAULT_SERVICES
)
{}
constructor
(
private
readonly
services
:
ServiceNames
[]
=
DEFAULT_SERVICES
)
{}
async
up
()
{
const
out
=
await
compose
.
upMany
(
this
.
services
,
{
cwd
:
OPS_DIRECTORY
})
async
up
()
{
const
out
=
await
compose
.
upMany
(
this
.
services
,
{
cwd
:
OPS_DIRECTORY
})
const
{
err
,
exitCode
}
=
out
;
const
{
err
,
exitCode
}
=
out
if
(
!
err
||
exitCode
)
{
console
.
error
(
err
)
throw
new
Error
(
'
Unexpected error when starting docker-compose network, dumping output
'
)
}
if
(
!
err
||
exitCode
)
{
console
.
error
(
err
)
throw
new
Error
(
'
Unexpected error when starting docker-compose network, dumping output
'
)
}
if
(
err
.
includes
(
'
Creating
'
))
{
console
.
info
(
'
🐳 Tests required starting containers. Waiting for sequencer to ready.
'
)
shell
.
exec
(
`
${
OPS_DIRECTORY
}
/scripts/wait-for-sequencer.sh`
,
{
cwd
:
OPS_DIRECTORY
})
}
if
(
err
.
includes
(
'
Creating
'
))
{
console
.
info
(
'
🐳 Tests required starting containers. Waiting for sequencer to ready.
'
)
shell
.
exec
(
`
${
OPS_DIRECTORY
}
/scripts/wait-for-sequencer.sh`
,
{
cwd
:
OPS_DIRECTORY
,
})
}
}
}
integration-tests/test/shared/utils.ts
View file @
f5c29ddd
...
...
@@ -18,12 +18,17 @@ import { cleanEnv, str, num } from 'envalid'
export
const
GWEI
=
BigNumber
.
from
(
1
e9
)
const
env
=
cleanEnv
(
process
.
env
,
{
L1_URL
:
str
({
default
:
"
http://localhost:9545
"
}),
L2_URL
:
str
({
default
:
"
http://localhost:8545
"
}),
L1_URL
:
str
({
default
:
'
http://localhost:9545
'
}),
L2_URL
:
str
({
default
:
'
http://localhost:8545
'
}),
L1_POLLING_INTERVAL
:
num
({
default
:
10
}),
L2_POLLING_INTERVAL
:
num
({
default
:
10
}),
PRIVATE_KEY
:
str
({
default
:
'
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
'
}),
ADDRESS_MANAGER
:
str
({
default
:
'
0x5FbDB2315678afecb367f032d93F642f64180aa3
'
})
PRIVATE_KEY
:
str
({
default
:
'
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
'
,
}),
ADDRESS_MANAGER
:
str
({
default
:
'
0x5FbDB2315678afecb367f032d93F642f64180aa3
'
,
}),
})
// The hardhat instance
...
...
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