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
edb21845
Commit
edb21845
authored
Feb 02, 2022
by
Kelvin Fichter
Committed by
smartcontracts
Feb 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(sdk): start using sdk in integration tests
parent
adce9c2c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
81 deletions
+90
-81
tricky-bees-sneeze.md
.changeset/tricky-bees-sneeze.md
+5
-0
package.json
integration-tests/package.json
+1
-0
basic-l1-l2-communication.spec.ts
integration-tests/test/basic-l1-l2-communication.spec.ts
+62
-72
env.ts
integration-tests/test/shared/env.ts
+11
-0
Dockerfile.integration-tests
ops/docker/Dockerfile.integration-tests
+3
-0
Dockerfile.packages
ops/docker/Dockerfile.packages
+1
-0
contracts.ts
packages/sdk/src/utils/contracts.ts
+6
-8
merkle-utils.ts
packages/sdk/src/utils/merkle-utils.ts
+1
-1
No files found.
.changeset/tricky-bees-sneeze.md
0 → 100644
View file @
edb21845
---
'
@eth-optimism/integration-tests'
:
patch
---
Updates integration tests to start using SDK
integration-tests/package.json
View file @
edb21845
...
...
@@ -31,6 +31,7 @@
"@eth-optimism/contracts"
:
"0.5.11"
,
"@eth-optimism/core-utils"
:
"0.7.5"
,
"@eth-optimism/message-relayer"
:
"0.2.15"
,
"@eth-optimism/sdk"
:
"0.0.7"
,
"@ethersproject/abstract-provider"
:
"^5.5.1"
,
"@ethersproject/providers"
:
"^5.4.5"
,
"@ethersproject/transactions"
:
"^5.4.0"
,
...
...
integration-tests/test/basic-l1-l2-communication.spec.ts
View file @
edb21845
/* Imports: External */
import
{
Contract
,
ContractFactory
}
from
'
ethers
'
import
{
ethers
}
from
'
hardhat
'
import
{
applyL1ToL2Alias
,
awaitCondition
}
from
'
@eth-optimism/core-utils
'
import
{
MessageDirection
,
MessageStatus
}
from
'
@eth-optimism/sdk
'
import
{
applyL1ToL2Alias
,
awaitCondition
,
sleep
,
}
from
'
@eth-optimism/core-utils
'
/* Imports: Internal */
import
{
expect
}
from
'
./shared/setup
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
DEFAULT_TEST_GAS_L1
,
DEFAULT_TEST_GAS_L2
,
envConfig
,
sleep
,
withdrawalTest
,
}
from
'
./shared/utils
'
...
...
@@ -56,23 +59,35 @@ describe('Basic L1<>L2 Communication', async () => {
const
value
=
`0x
${
'
77
'
.
repeat
(
32
)}
`
// Send L2 -> L1 message.
const
transaction
=
await
env
.
l2Messenger
.
sendMessage
(
L1SimpleStorage
.
address
,
L1SimpleStorage
.
interface
.
encodeFunctionData
(
'
setValue
'
,
[
value
]),
5000000
,
const
transaction
=
await
env
.
messenger
.
sendMessage
(
{
direction
:
MessageDirection
.
L2_TO_L1
,
target
:
L1SimpleStorage
.
address
,
message
:
L1SimpleStorage
.
interface
.
encodeFunctionData
(
'
setValue
'
,
[
value
,
]),
},
{
overrides
:
{
gasLimit
:
DEFAULT_TEST_GAS_L2
,
},
}
)
await
transaction
.
wait
()
await
env
.
relayXDomainMessages
(
transaction
)
await
env
.
waitForXDomainTransaction
(
transaction
,
Direction
.
L2ToL1
)
let
status
:
MessageStatus
while
(
status
!==
MessageStatus
.
READY_FOR_RELAY
)
{
status
=
await
env
.
messenger
.
getMessageStatus
(
transaction
)
await
sleep
(
1000
)
}
await
env
.
messenger
.
finalizeMessage
(
transaction
)
await
env
.
messenger
.
waitForMessageReceipt
(
transaction
)
expect
(
await
L1SimpleStorage
.
msgSender
()).
to
.
equal
(
env
.
l1
Messenger
.
address
env
.
messenger
.
contracts
.
l1
.
L1CrossDomain
Messenger
.
address
)
expect
(
await
L1SimpleStorage
.
xDomainSender
()).
to
.
equal
(
env
.
l2Wallet
.
address
await
env
.
messenger
.
l2Signer
.
getAddress
()
)
expect
(
await
L1SimpleStorage
.
value
()).
to
.
equal
(
value
)
expect
((
await
L1SimpleStorage
.
totalCount
()).
toNumber
()).
to
.
equal
(
1
)
...
...
@@ -85,25 +100,36 @@ describe('Basic L1<>L2 Communication', async () => {
const
value
=
`0x
${
'
42
'
.
repeat
(
32
)}
`
// Send L1 -> L2 message.
const
transaction
=
await
env
.
l1Messenger
.
sendMessage
(
L2SimpleStorage
.
address
,
L2SimpleStorage
.
interface
.
encodeFunctionData
(
'
setValue
'
,
[
value
]),
5000000
,
const
transaction
=
await
env
.
messenger
.
sendMessage
(
{
direction
:
MessageDirection
.
L1_TO_L2
,
target
:
L2SimpleStorage
.
address
,
message
:
L2SimpleStorage
.
interface
.
encodeFunctionData
(
'
setValue
'
,
[
value
,
]),
},
{
l2GasLimit
:
5000000
,
overrides
:
{
gasLimit
:
DEFAULT_TEST_GAS_L1
,
},
}
)
await
env
.
waitForXDomainTransaction
(
transaction
,
Direction
.
L1ToL2
)
const
receipt
=
await
env
.
messenger
.
waitForMessageReceipt
(
transaction
)
console
.
log
(
await
env
.
messenger
.
l2Signer
.
getAddress
())
expect
(
receipt
.
transactionReceipt
.
status
).
to
.
equal
(
1
)
expect
(
await
L2SimpleStorage
.
msgSender
()).
to
.
equal
(
env
.
l2
Messenger
.
address
env
.
messenger
.
contracts
.
l2
.
L2CrossDomain
Messenger
.
address
)
expect
(
await
L2SimpleStorage
.
txOrigin
()).
to
.
equal
(
applyL1ToL2Alias
(
env
.
l1Messenger
.
address
)
applyL1ToL2Alias
(
env
.
messenger
.
contracts
.
l1
.
L1CrossDomainMessenger
.
address
)
)
expect
(
await
L2SimpleStorage
.
xDomainSender
()).
to
.
equal
(
env
.
l1Wallet
.
address
await
env
.
messenger
.
l1Signer
.
getAddress
()
)
expect
(
await
L2SimpleStorage
.
value
()).
to
.
equal
(
value
)
expect
((
await
L2SimpleStorage
.
totalCount
()).
toNumber
()).
to
.
equal
(
1
)
...
...
@@ -117,9 +143,10 @@ describe('Basic L1<>L2 Communication', async () => {
const
value
=
`0x
${
'
42
'
.
repeat
(
32
)}
`
// Send L1 -> L2 message.
const
tx
=
await
env
.
ctc
.
connect
(
env
.
l1Wallet
)
.
enqueue
(
const
tx
=
await
env
.
messenger
.
contracts
.
l1
.
CanonicalTransactionChain
.
connect
(
env
.
messenger
.
l1Signer
).
enqueue
(
L2SimpleStorage
.
address
,
5000000
,
L2SimpleStorage
.
interface
.
encodeFunctionData
(
'
setValueNotXDomain
'
,
[
...
...
@@ -129,11 +156,12 @@ describe('Basic L1<>L2 Communication', async () => {
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}
)
const
receipt
=
await
tx
.
wait
()
const
waitUntilBlock
=
receipt
.
blockNumber
+
envConfig
.
DTL_ENQUEUE_CONFIRMATIONS
let
currBlock
=
await
env
.
l1Provider
.
getBlockNumber
()
let
currBlock
=
await
env
.
messenger
.
l1Provider
.
getBlockNumber
()
while
(
currBlock
<=
waitUntilBlock
)
{
const
progress
=
envConfig
.
DTL_ENQUEUE_CONFIRMATIONS
-
(
waitUntilBlock
-
currBlock
)
...
...
@@ -141,66 +169,28 @@ describe('Basic L1<>L2 Communication', async () => {
`Waiting for
${
progress
}
/
${
envConfig
.
DTL_ENQUEUE_CONFIRMATIONS
}
confirmations.`
)
await
sleep
(
5000
)
currBlock
=
await
env
.
l1Provider
.
getBlockNumber
()
currBlock
=
await
env
.
messenger
.
l1Provider
.
getBlockNumber
()
}
console
.
log
(
'
Enqueue should be confirmed.
'
)
await
awaitCondition
(
async
()
=>
{
const
sender
=
await
L2SimpleStorage
.
msgSender
()
return
sender
===
env
.
l1Wallet
.
address
return
sender
===
(
await
env
.
messenger
.
l1Signer
.
getAddress
())
},
2000
,
60
)
// No aliasing when an EOA goes directly to L2.
expect
(
await
L2SimpleStorage
.
msgSender
()).
to
.
equal
(
env
.
l1Wallet
.
address
)
expect
(
await
L2SimpleStorage
.
txOrigin
()).
to
.
equal
(
env
.
l1Wallet
.
address
)
expect
(
await
L2SimpleStorage
.
value
()).
to
.
equal
(
value
)
expect
((
await
L2SimpleStorage
.
totalCount
()).
toNumber
()).
to
.
equal
(
1
)
})
it
(
'
should have a receipt with a status of 1 for a successful message
'
,
async
()
=>
{
const
value
=
`0x
${
'
42
'
.
repeat
(
32
)}
`
// Send L1 -> L2 message.
const
transaction
=
await
env
.
l1Messenger
.
sendMessage
(
L2SimpleStorage
.
address
,
L2SimpleStorage
.
interface
.
encodeFunctionData
(
'
setValue
'
,
[
value
]),
5000000
,
{
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}
)
await
transaction
.
wait
()
const
{
remoteReceipt
}
=
await
env
.
waitForXDomainTransaction
(
transaction
,
Direction
.
L1ToL2
)
expect
(
remoteReceipt
.
status
).
to
.
equal
(
1
)
})
// SKIP: until we decide what should be done in this case
it
.
skip
(
'
should have a receipt with a status of 0 for a failed message
'
,
async
()
=>
{
// Send L1 -> L2 message.
const
transaction
=
await
env
.
l1Messenger
.
sendMessage
(
L2Reverter
.
address
,
L2Reverter
.
interface
.
encodeFunctionData
(
'
doRevert
'
,
[]),
5000000
,
{
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}
expect
(
await
L2SimpleStorage
.
msgSender
()).
to
.
equal
(
await
env
.
messenger
.
l1Signer
.
getAddress
()
)
const
{
remoteReceipt
}
=
await
env
.
waitForXDomainTransaction
(
transaction
,
Direction
.
L1ToL2
expect
(
await
L2SimpleStorage
.
txOrigin
()).
to
.
equal
(
await
env
.
messenger
.
l1Signer
.
getAddress
()
)
expect
(
remoteReceipt
.
status
).
to
.
equal
(
0
)
expect
(
await
L2SimpleStorage
.
value
()).
to
.
equal
(
value
)
expect
(
(
await
L2SimpleStorage
.
totalCount
()).
toNumber
()).
to
.
equal
(
1
)
})
})
})
integration-tests/test/shared/env.ts
View file @
edb21845
...
...
@@ -4,6 +4,7 @@ import { TransactionResponse } from '@ethersproject/providers'
import
{
getContractFactory
,
predeploys
}
from
'
@eth-optimism/contracts
'
import
{
Watcher
}
from
'
@eth-optimism/core-utils
'
import
{
getMessagesAndProofsForL2Transaction
}
from
'
@eth-optimism/message-relayer
'
import
{
CrossChainMessenger
}
from
'
@eth-optimism/sdk
'
/* Imports: Internal */
import
{
...
...
@@ -55,6 +56,7 @@ export class OptimismEnv {
l2Wallet
:
Wallet
// The providers
messenger
:
CrossChainMessenger
l1Provider
:
providers
.
JsonRpcProvider
l2Provider
:
providers
.
JsonRpcProvider
replicaProvider
:
providers
.
JsonRpcProvider
...
...
@@ -73,6 +75,7 @@ export class OptimismEnv {
this
.
watcher
=
args
.
watcher
this
.
l1Wallet
=
args
.
l1Wallet
this
.
l2Wallet
=
args
.
l2Wallet
this
.
messenger
=
args
.
messenger
this
.
l1Provider
=
args
.
l1Provider
this
.
l2Provider
=
args
.
l2Provider
this
.
replicaProvider
=
args
.
replicaProvider
...
...
@@ -126,6 +129,13 @@ export class OptimismEnv {
.
connect
(
l2Wallet
)
.
attach
(
predeploys
.
OVM_L1BlockNumber
)
const
network
=
await
l1Provider
.
getNetwork
()
const
messenger
=
new
CrossChainMessenger
({
l1SignerOrProvider
:
l1Wallet
,
l2SignerOrProvider
:
l2Wallet
,
l1ChainId
:
network
.
chainId
,
})
return
new
OptimismEnv
({
addressManager
,
l1Bridge
,
...
...
@@ -141,6 +151,7 @@ export class OptimismEnv {
watcher
,
l1Wallet
,
l2Wallet
,
messenger
,
l1Provider
,
l2Provider
,
verifierProvider
,
...
...
ops/docker/Dockerfile.integration-tests
View file @
edb21845
...
...
@@ -12,6 +12,9 @@ COPY --from=builder /optimism/*.json /optimism/yarn.lock ./
COPY --from=builder /optimism/node_modules ./node_modules
# copy deps (would have been nice if docker followed the symlinks required)
COPY --from=builder /optimism/packages/sdk/package.json ./packages/sdk/package.json
COPY --from=builder /optimism/packages/sdk/dist ./packages/sdk/dist
COPY --from=builder /optimism/packages/core-utils/package.json ./packages/core-utils/package.json
COPY --from=builder /optimism/packages/core-utils/dist ./packages/core-utils/dist
...
...
ops/docker/Dockerfile.packages
View file @
edb21845
...
...
@@ -13,6 +13,7 @@ RUN apt-get update -y && apt-get install -y git curl jq python3
# us to cache the installation steps
WORKDIR /opt/optimism
COPY *.json yarn.lock ./
COPY packages/sdk/package.json ./packages/sdk/package.json
COPY packages/core-utils/package.json ./packages/core-utils/package.json
COPY packages/common-ts/package.json ./packages/common-ts/package.json
COPY packages/contracts/package.json ./packages/contracts/package.json
...
...
packages/sdk/src/utils/contracts.ts
View file @
edb21845
...
...
@@ -90,16 +90,14 @@ export const CONTRACT_ADDRESSES: {
l2
:
DEFAULT_L2_CONTRACT_ADDRESSES
,
},
// Hardhat local
// TODO: Get the actual addresses for this, temporary addresses here are fine for now until we
// start using this package in the integration tests.
31337
:
{
l1
:
{
AddressManager
:
'
0x
2F7E3cAC91b5148d336BbffB224B4dC79F09f01D
'
,
L1CrossDomainMessenger
:
'
0x
EcC89b9EDD804850C4F343A278Be902be11AaF42
'
,
L1StandardBridge
:
'
0x
73298186A143a54c20ae98EEE5a025bD5979De02
'
,
StateCommitmentChain
:
'
0x
1afcA918eff169eE20fF8AB6Be75f3E872eE1C1A
'
,
CanonicalTransactionChain
:
'
0x
2ebA8c4EfDB39A8Cd8f9eD65c50ec079f7CEBD81
'
,
BondManager
:
'
0x
E5AE60bD6F8DEe4D0c2BC9268e23B92F1cacC58F
'
,
AddressManager
:
'
0x
5FbDB2315678afecb367f032d93F642f64180aa3
'
,
L1CrossDomainMessenger
:
'
0x
8A791620dd6260079BF849Dc5567aDC3F2FdC318
'
,
L1StandardBridge
:
'
0x
610178dA211FEF7D417bC0e6FeD39F05609AD788
'
,
StateCommitmentChain
:
'
0x
Dc64a140Aa3E981100a9becA4E685f962f0cF6C9
'
,
CanonicalTransactionChain
:
'
0x
Cf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
'
,
BondManager
:
'
0x
5FC8d32690cc91D4c39d9d3abcBD16989F875707
'
,
},
l2
:
DEFAULT_L2_CONTRACT_ADDRESSES
,
},
...
...
packages/sdk/src/utils/merkle-utils.ts
View file @
edb21845
...
...
@@ -6,7 +6,7 @@ import {
toRpcHexString
,
}
from
'
@eth-optimism/core-utils
'
import
{
MerkleTree
}
from
'
merkletreejs
'
import
rlp
from
'
rlp
'
import
*
as
rlp
from
'
rlp
'
/**
* Generates a Merkle proof (using the particular scheme we use within Lib_MerkleTree).
...
...
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