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
27452790
Commit
27452790
authored
Nov 08, 2021
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: add replica tests
parent
128e0f84
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
6 deletions
+80
-6
replica.spec.ts
integration-tests/test/replica.spec.ts
+64
-0
env.ts
integration-tests/test/shared/env.ts
+4
-0
utils.ts
integration-tests/test/shared/utils.ts
+9
-3
docker-compose.yml
ops/docker-compose.yml
+3
-3
No files found.
integration-tests/test/replica.spec.ts
0 → 100644
View file @
27452790
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
defaultTransactionFactory
,
gasPriceForL2
,
sleep
}
from
'
./shared/utils
'
import
{
expect
}
from
'
chai
'
describe
(
'
Replica Tests
'
,
()
=>
{
let
env
:
OptimismEnv
before
(
async
()
=>
{
env
=
await
OptimismEnv
.
new
()
})
describe
(
'
Matching blocks
'
,
()
=>
{
it
(
'
should sync a transaction
'
,
async
()
=>
{
const
tx
=
defaultTransactionFactory
()
tx
.
gasPrice
=
await
gasPriceForL2
()
const
result
=
await
env
.
l2Wallet
.
sendTransaction
(
tx
)
let
receipt
while
(
!
receipt
)
{
receipt
=
await
env
.
replicaProvider
.
getTransactionReceipt
(
result
.
hash
)
await
sleep
(
200
)
}
const
sequencerBlock
=
(
await
env
.
l2Provider
.
getBlock
(
result
.
blockNumber
))
as
any
const
replicaBlock
=
(
await
env
.
replicaProvider
.
getBlock
(
result
.
blockNumber
))
as
any
expect
(
sequencerBlock
.
stateRoot
).
to
.
deep
.
eq
(
replicaBlock
.
stateRoot
)
expect
(
sequencerBlock
.
hash
).
to
.
deep
.
eq
(
replicaBlock
.
hash
)
})
it
(
'
sync an unprotected tx (eip155)
'
,
async
()
=>
{
const
tx
=
{
...
defaultTransactionFactory
(),
nonce
:
await
env
.
l2Wallet
.
getTransactionCount
(),
gasPrice
:
await
gasPriceForL2
(),
chainId
:
null
,
// Disables EIP155 transaction signing.
}
const
signed
=
await
env
.
l2Wallet
.
signTransaction
(
tx
)
const
result
=
await
env
.
l2Provider
.
sendTransaction
(
signed
)
let
receipt
while
(
!
receipt
)
{
receipt
=
await
env
.
replicaProvider
.
getTransactionReceipt
(
result
.
hash
)
await
sleep
(
200
)
}
const
sequencerBlock
=
(
await
env
.
l2Provider
.
getBlock
(
result
.
blockNumber
))
as
any
const
replicaBlock
=
(
await
env
.
replicaProvider
.
getBlock
(
result
.
blockNumber
))
as
any
expect
(
sequencerBlock
.
stateRoot
).
to
.
deep
.
eq
(
replicaBlock
.
stateRoot
)
expect
(
sequencerBlock
.
hash
).
to
.
deep
.
eq
(
replicaBlock
.
hash
)
})
})
})
integration-tests/test/shared/env.ts
View file @
27452790
...
@@ -10,6 +10,7 @@ import {
...
@@ -10,6 +10,7 @@ import {
getAddressManager
,
getAddressManager
,
l1Provider
,
l1Provider
,
l2Provider
,
l2Provider
,
replicaProvider
,
l1Wallet
,
l1Wallet
,
l2Wallet
,
l2Wallet
,
fundUser
,
fundUser
,
...
@@ -52,6 +53,7 @@ export class OptimismEnv {
...
@@ -52,6 +53,7 @@ export class OptimismEnv {
// The providers
// The providers
l1Provider
:
providers
.
JsonRpcProvider
l1Provider
:
providers
.
JsonRpcProvider
l2Provider
:
providers
.
JsonRpcProvider
l2Provider
:
providers
.
JsonRpcProvider
replicaProvider
:
providers
.
JsonRpcProvider
constructor
(
args
:
any
)
{
constructor
(
args
:
any
)
{
this
.
addressManager
=
args
.
addressManager
this
.
addressManager
=
args
.
addressManager
...
@@ -67,6 +69,7 @@ export class OptimismEnv {
...
@@ -67,6 +69,7 @@ export class OptimismEnv {
this
.
l2Wallet
=
args
.
l2Wallet
this
.
l2Wallet
=
args
.
l2Wallet
this
.
l1Provider
=
args
.
l1Provider
this
.
l1Provider
=
args
.
l1Provider
this
.
l2Provider
=
args
.
l2Provider
this
.
l2Provider
=
args
.
l2Provider
this
.
replicaProvider
=
args
.
replicaProvider
this
.
ctc
=
args
.
ctc
this
.
ctc
=
args
.
ctc
this
.
scc
=
args
.
scc
this
.
scc
=
args
.
scc
}
}
...
@@ -126,6 +129,7 @@ export class OptimismEnv {
...
@@ -126,6 +129,7 @@ export class OptimismEnv {
l2Wallet
,
l2Wallet
,
l1Provider
,
l1Provider
,
l2Provider
,
l2Provider
,
replicaProvider
,
})
})
}
}
...
...
integration-tests/test/shared/utils.ts
View file @
27452790
...
@@ -55,13 +55,19 @@ const env = cleanEnv(process.env, {
...
@@ -55,13 +55,19 @@ const env = cleanEnv(process.env, {
export
const
l1Provider
=
new
providers
.
JsonRpcProvider
(
env
.
L1_URL
)
export
const
l1Provider
=
new
providers
.
JsonRpcProvider
(
env
.
L1_URL
)
l1Provider
.
pollingInterval
=
env
.
L1_POLLING_INTERVAL
l1Provider
.
pollingInterval
=
env
.
L1_POLLING_INTERVAL
export
const
l2Provider
=
new
providers
.
JsonRpcProvider
(
env
.
L2_URL
)
export
const
l2Provider
=
injectL2Context
(
new
providers
.
JsonRpcProvider
(
env
.
L2_URL
)
)
l2Provider
.
pollingInterval
=
env
.
L2_POLLING_INTERVAL
l2Provider
.
pollingInterval
=
env
.
L2_POLLING_INTERVAL
export
const
verifierProvider
=
new
providers
.
JsonRpcProvider
(
env
.
VERIFIER_URL
)
export
const
verifierProvider
=
injectL2Context
(
new
providers
.
JsonRpcProvider
(
env
.
VERIFIER_URL
)
)
verifierProvider
.
pollingInterval
=
env
.
VERIFIER_POLLING_INTERVAL
verifierProvider
.
pollingInterval
=
env
.
VERIFIER_POLLING_INTERVAL
export
const
replicaProvider
=
new
providers
.
JsonRpcProvider
(
env
.
REPLICA_URL
)
export
const
replicaProvider
=
injectL2Context
(
new
providers
.
JsonRpcProvider
(
env
.
REPLICA_URL
)
)
replicaProvider
.
pollingInterval
=
env
.
REPLICA_POLLING_INTERVAL
replicaProvider
.
pollingInterval
=
env
.
REPLICA_POLLING_INTERVAL
// The sequencer private key which is funded on L1
// The sequencer private key which is funded on L1
...
...
ops/docker-compose.yml
View file @
27452790
...
@@ -165,7 +165,7 @@ services:
...
@@ -165,7 +165,7 @@ services:
depends_on
:
depends_on
:
-
dtl
-
dtl
deploy
:
deploy
:
replicas
:
0
replicas
:
1
build
:
build
:
context
:
..
context
:
..
dockerfile
:
./ops/docker/Dockerfile.geth
dockerfile
:
./ops/docker/Dockerfile.geth
...
@@ -181,8 +181,8 @@ services:
...
@@ -181,8 +181,8 @@ services:
ETH1_CTC_DEPLOYMENT_HEIGHT
:
8
ETH1_CTC_DEPLOYMENT_HEIGHT
:
8
RETRIES
:
60
RETRIES
:
60
ports
:
ports
:
-
${
L2GETH
_HTTP_PORT:-8549}:8545
-
${
REPLICA
_HTTP_PORT:-8549}:8545
-
${
L2GETH
_WS_PORT:-8550}:8546
-
${
REPLICA
_WS_PORT:-8550}:8546
integration_tests
:
integration_tests
:
deploy
:
deploy
:
...
...
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