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
a8a74a98
Commit
a8a74a98
authored
Feb 04, 2022
by
Johns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
itest: replace watcher with sdk CrossChainMessenger
parent
57c66bb9
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
50 additions
and
105 deletions
+50
-105
fresh-planes-report.md
.changeset/fresh-planes-report.md
+5
-0
deposits.test.ts
integration-tests/actor-tests/deposits.test.ts
+1
-3
fee-payment.spec.ts
integration-tests/test/fee-payment.spec.ts
+1
-2
native-eth.spec.ts
integration-tests/test/native-eth.spec.ts
+8
-23
ovmcontext.spec.ts
integration-tests/test/ovmcontext.spec.ts
+1
-2
queue-ingestion.spec.ts
integration-tests/test/queue-ingestion.spec.ts
+1
-5
env.ts
integration-tests/test/shared/env.ts
+11
-15
stress-test-helpers.ts
integration-tests/test/shared/stress-test-helpers.ts
+2
-3
watcher-utils.ts
integration-tests/test/shared/watcher-utils.ts
+20
-52
No files found.
.changeset/fresh-planes-report.md
0 → 100644
View file @
a8a74a98
---
'
@eth-optimism/integration-tests'
:
patch
---
Remove Watcher usage from itests
integration-tests/actor-tests/deposits.test.ts
View file @
a8a74a98
...
@@ -3,7 +3,6 @@ import { expect } from 'chai'
...
@@ -3,7 +3,6 @@ import { expect } from 'chai'
import
{
setupActor
,
setupRun
,
actor
,
run
}
from
'
./lib/convenience
'
import
{
setupActor
,
setupRun
,
actor
,
run
}
from
'
./lib/convenience
'
import
{
OptimismEnv
}
from
'
../test/shared/env
'
import
{
OptimismEnv
}
from
'
../test/shared/env
'
import
{
Direction
}
from
'
../test/shared/watcher-utils
'
interface
BenchContext
{
interface
BenchContext
{
l1Wallet
:
Wallet
l1Wallet
:
Wallet
...
@@ -42,8 +41,7 @@ actor('Funds depositor', () => {
...
@@ -42,8 +41,7 @@ actor('Funds depositor', () => {
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
value
:
0x42
,
value
:
0x42
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}),
})
Direction
.
L1ToL2
)
)
})
})
expect
((
await
l2Wallet
.
getBalance
()).
sub
(
balBefore
)).
to
.
deep
.
equal
(
expect
((
await
l2Wallet
.
getBalance
()).
sub
(
balBefore
)).
to
.
deep
.
equal
(
...
...
integration-tests/test/fee-payment.spec.ts
View file @
a8a74a98
...
@@ -7,7 +7,6 @@ import { predeploys, getContractFactory } from '@eth-optimism/contracts'
...
@@ -7,7 +7,6 @@ import { predeploys, getContractFactory } from '@eth-optimism/contracts'
import
{
expect
}
from
'
./shared/setup
'
import
{
expect
}
from
'
./shared/setup
'
import
{
hardhatTest
}
from
'
./shared/utils
'
import
{
hardhatTest
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
const
setPrices
=
async
(
env
:
OptimismEnv
,
value
:
number
|
BigNumber
)
=>
{
const
setPrices
=
async
(
env
:
OptimismEnv
,
value
:
number
|
BigNumber
)
=>
{
const
gasPrice
=
await
env
.
gasPriceOracle
.
setGasPrice
(
value
)
const
gasPrice
=
await
env
.
gasPriceOracle
.
setGasPrice
(
value
)
...
@@ -171,7 +170,7 @@ describe('Fee Payment Integration Tests', async () => {
...
@@ -171,7 +170,7 @@ describe('Fee Payment Integration Tests', async () => {
// Wait for the withdrawal to be relayed to L1.
// Wait for the withdrawal to be relayed to L1.
await
withdrawTx
.
wait
()
await
withdrawTx
.
wait
()
await
env
.
relayXDomainMessages
(
withdrawTx
)
await
env
.
relayXDomainMessages
(
withdrawTx
)
await
env
.
waitForXDomainTransaction
(
withdrawTx
,
Direction
.
L2ToL1
)
await
env
.
waitForXDomainTransaction
(
withdrawTx
)
// Balance difference should be equal to old L2 balance.
// Balance difference should be equal to old L2 balance.
const
balanceAfter
=
await
env
.
l1Wallet
.
provider
.
getBalance
(
l1FeeWallet
)
const
balanceAfter
=
await
env
.
l1Wallet
.
provider
.
getBalance
(
l1FeeWallet
)
...
...
integration-tests/test/native-eth.spec.ts
View file @
a8a74a98
...
@@ -6,7 +6,6 @@ import { expectApprox } from '@eth-optimism/core-utils'
...
@@ -6,7 +6,6 @@ import { expectApprox } from '@eth-optimism/core-utils'
/* Imports: Internal */
/* Imports: Internal */
import
{
expect
}
from
'
./shared/setup
'
import
{
expect
}
from
'
./shared/setup
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
import
{
DEFAULT_TEST_GAS_L1
,
DEFAULT_TEST_GAS_L1
,
DEFAULT_TEST_GAS_L2
,
DEFAULT_TEST_GAS_L2
,
...
@@ -71,8 +70,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -71,8 +70,7 @@ describe('Native ETH Integration Tests', async () => {
to
:
env
.
l1Bridge
.
address
,
to
:
env
.
l1Bridge
.
address
,
value
:
depositAmount
,
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}),
})
Direction
.
L1ToL2
)
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
@@ -96,8 +94,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -96,8 +94,7 @@ describe('Native ETH Integration Tests', async () => {
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
value
:
depositAmount
,
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}),
})
Direction
.
L1ToL2
)
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
@@ -121,8 +118,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -121,8 +118,7 @@ describe('Native ETH Integration Tests', async () => {
env
.
l1Bridge
.
depositETHTo
(
l2Bob
.
address
,
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
l1Bridge
.
depositETHTo
(
l2Bob
.
address
,
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
value
:
depositAmount
,
value
:
depositAmount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}),
})
Direction
.
L1ToL2
)
)
const
l1FeePaid
=
depositReceipts
.
receipt
.
gasUsed
.
mul
(
const
l1FeePaid
=
depositReceipts
.
receipt
.
gasUsed
.
mul
(
...
@@ -152,8 +148,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -152,8 +148,7 @@ describe('Native ETH Integration Tests', async () => {
env
.
l1Bridge
.
depositETH
(
ASSUMED_L2_GAS_LIMIT
,
data
,
{
env
.
l1Bridge
.
depositETH
(
ASSUMED_L2_GAS_LIMIT
,
data
,
{
value
:
depositAmount
,
value
:
depositAmount
,
gasLimit
:
4
_000_000
,
gasLimit
:
4
_000_000
,
}),
})
Direction
.
L1ToL2
)
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
const
l1FeePaid
=
receipt
.
gasUsed
.
mul
(
tx
.
gasPrice
)
...
@@ -196,10 +191,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -196,10 +191,7 @@ describe('Native ETH Integration Tests', async () => {
)
)
await
transaction
.
wait
()
await
transaction
.
wait
()
await
env
.
relayXDomainMessages
(
transaction
)
await
env
.
relayXDomainMessages
(
transaction
)
const
receipts
=
await
env
.
waitForXDomainTransaction
(
const
receipts
=
await
env
.
waitForXDomainTransaction
(
transaction
)
transaction
,
Direction
.
L2ToL1
)
const
fee
=
receipts
.
tx
.
gasLimit
.
mul
(
receipts
.
tx
.
gasPrice
)
const
fee
=
receipts
.
tx
.
gasLimit
.
mul
(
receipts
.
tx
.
gasPrice
)
const
postBalances
=
await
getBalances
(
env
)
const
postBalances
=
await
getBalances
(
env
)
...
@@ -242,10 +234,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -242,10 +234,7 @@ describe('Native ETH Integration Tests', async () => {
await
transaction
.
wait
()
await
transaction
.
wait
()
await
env
.
relayXDomainMessages
(
transaction
)
await
env
.
relayXDomainMessages
(
transaction
)
const
receipts
=
await
env
.
waitForXDomainTransaction
(
const
receipts
=
await
env
.
waitForXDomainTransaction
(
transaction
)
transaction
,
Direction
.
L2ToL1
)
const
l2Fee
=
receipts
.
tx
.
gasPrice
.
mul
(
receipts
.
receipt
.
gasUsed
)
const
l2Fee
=
receipts
.
tx
.
gasPrice
.
mul
(
receipts
.
receipt
.
gasUsed
)
...
@@ -289,8 +278,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -289,8 +278,7 @@ describe('Native ETH Integration Tests', async () => {
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
env
.
l1Bridge
.
depositETH
(
DEFAULT_TEST_GAS_L2
,
'
0xFFFF
'
,
{
value
:
amount
,
value
:
amount
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
gasLimit
:
DEFAULT_TEST_GAS_L1
,
}),
})
Direction
.
L1ToL2
)
)
// 2. transfer to another address
// 2. transfer to another address
...
@@ -317,10 +305,7 @@ describe('Native ETH Integration Tests', async () => {
...
@@ -317,10 +305,7 @@ describe('Native ETH Integration Tests', async () => {
)
)
await
transaction
.
wait
()
await
transaction
.
wait
()
await
env
.
relayXDomainMessages
(
transaction
)
await
env
.
relayXDomainMessages
(
transaction
)
const
receipts
=
await
env
.
waitForXDomainTransaction
(
const
receipts
=
await
env
.
waitForXDomainTransaction
(
transaction
)
transaction
,
Direction
.
L2ToL1
)
// Compute the L1 portion of the fee
// Compute the L1 portion of the fee
const
l1Fee
=
await
env
.
gasPriceOracle
.
getL1Fee
(
const
l1Fee
=
await
env
.
gasPriceOracle
.
getL1Fee
(
...
...
integration-tests/test/ovmcontext.spec.ts
View file @
a8a74a98
...
@@ -14,7 +14,6 @@ import {
...
@@ -14,7 +14,6 @@ import {
DEFAULT_TEST_GAS_L1
,
DEFAULT_TEST_GAS_L1
,
}
from
'
./shared/utils
'
}
from
'
./shared/utils
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
/**
/**
* These tests cover the OVM execution contexts. In the OVM execution
* These tests cover the OVM execution contexts. In the OVM execution
...
@@ -63,7 +62,7 @@ describe('OVM Context: Layer 2 EVM Context', () => {
...
@@ -63,7 +62,7 @@ describe('OVM Context: Layer 2 EVM Context', () => {
// Wait for the transaction to be sent over to L2.
// Wait for the transaction to be sent over to L2.
await
tx
.
wait
()
await
tx
.
wait
()
const
pair
=
await
env
.
waitForXDomainTransaction
(
tx
,
Direction
.
L1ToL2
)
const
pair
=
await
env
.
waitForXDomainTransaction
(
tx
)
// Get the L1 block that the enqueue transaction was in so that
// Get the L1 block that the enqueue transaction was in so that
// the timestamp can be compared against the layer two contract
// the timestamp can be compared against the layer two contract
...
...
integration-tests/test/queue-ingestion.spec.ts
View file @
a8a74a98
...
@@ -6,7 +6,6 @@ import { asL2Provider } from '@eth-optimism/sdk'
...
@@ -6,7 +6,6 @@ import { asL2Provider } from '@eth-optimism/sdk'
/* Imports: External */
/* Imports: External */
import
{
expect
}
from
'
./shared/setup
'
import
{
expect
}
from
'
./shared/setup
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
DEFAULT_TEST_GAS_L1
,
envConfig
}
from
'
./shared/utils
'
import
{
DEFAULT_TEST_GAS_L1
,
envConfig
}
from
'
./shared/utils
'
describe
(
'
Queue Ingestion
'
,
()
=>
{
describe
(
'
Queue Ingestion
'
,
()
=>
{
...
@@ -42,10 +41,7 @@ describe('Queue Ingestion', () => {
...
@@ -42,10 +41,7 @@ describe('Queue Ingestion', () => {
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
for
(
let
i
=
0
;
i
<
numTxs
;
i
++
)
{
const
l1Tx
=
txs
[
i
]
const
l1Tx
=
txs
[
i
]
const
l1TxReceipt
=
await
txs
[
i
].
wait
()
const
l1TxReceipt
=
await
txs
[
i
].
wait
()
const
receipt
=
await
env
.
waitForXDomainTransaction
(
const
receipt
=
await
env
.
waitForXDomainTransaction
(
l1Tx
)
l1Tx
,
Direction
.
L1ToL2
)
const
l2Tx
=
(
await
l2Provider
.
getTransaction
(
const
l2Tx
=
(
await
l2Provider
.
getTransaction
(
receipt
.
remoteTx
.
hash
receipt
.
remoteTx
.
hash
))
as
any
))
as
any
...
...
integration-tests/test/shared/env.ts
View file @
a8a74a98
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
{
Contract
,
utils
,
Wallet
,
providers
}
from
'
ethers
'
import
{
Contract
,
utils
,
Wallet
,
providers
}
from
'
ethers
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
getContractFactory
,
predeploys
}
from
'
@eth-optimism/contracts
'
import
{
getContractFactory
,
predeploys
}
from
'
@eth-optimism/contracts
'
import
{
Watcher
,
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
getMessagesAndProofsForL2Transaction
}
from
'
@eth-optimism/message-relayer
'
import
{
getMessagesAndProofsForL2Transaction
}
from
'
@eth-optimism/message-relayer
'
import
{
CrossChainMessenger
}
from
'
@eth-optimism/sdk
'
import
{
CrossChainMessenger
}
from
'
@eth-optimism/sdk
'
...
@@ -24,9 +24,7 @@ import {
...
@@ -24,9 +24,7 @@ import {
DEFAULT_TEST_GAS_L1
,
DEFAULT_TEST_GAS_L1
,
}
from
'
./utils
'
}
from
'
./utils
'
import
{
import
{
initWatcher
,
CrossDomainMessagePair
,
CrossDomainMessagePair
,
Direction
,
waitForXDomainTransaction
,
waitForXDomainTransaction
,
}
from
'
./watcher-utils
'
}
from
'
./watcher-utils
'
...
@@ -47,9 +45,6 @@ export class OptimismEnv {
...
@@ -47,9 +45,6 @@ export class OptimismEnv {
gasPriceOracle
:
Contract
gasPriceOracle
:
Contract
sequencerFeeVault
:
Contract
sequencerFeeVault
:
Contract
// The L1 <> L2 State watcher
watcher
:
Watcher
// The wallets
// The wallets
l1Wallet
:
Wallet
l1Wallet
:
Wallet
l2Wallet
:
Wallet
l2Wallet
:
Wallet
...
@@ -71,7 +66,6 @@ export class OptimismEnv {
...
@@ -71,7 +66,6 @@ export class OptimismEnv {
this
.
l2Messenger
=
args
.
l2Messenger
this
.
l2Messenger
=
args
.
l2Messenger
this
.
gasPriceOracle
=
args
.
gasPriceOracle
this
.
gasPriceOracle
=
args
.
gasPriceOracle
this
.
sequencerFeeVault
=
args
.
sequencerFeeVault
this
.
sequencerFeeVault
=
args
.
sequencerFeeVault
this
.
watcher
=
args
.
watcher
this
.
l1Wallet
=
args
.
l1Wallet
this
.
l1Wallet
=
args
.
l1Wallet
this
.
l2Wallet
=
args
.
l2Wallet
this
.
l2Wallet
=
args
.
l2Wallet
this
.
messenger
=
args
.
messenger
this
.
messenger
=
args
.
messenger
...
@@ -87,18 +81,22 @@ export class OptimismEnv {
...
@@ -87,18 +81,22 @@ export class OptimismEnv {
const
network
=
await
l1Provider
.
getNetwork
()
const
network
=
await
l1Provider
.
getNetwork
()
const
addressManager
=
getAddressManager
(
l1Wallet
)
const
addressManager
=
getAddressManager
(
l1Wallet
)
const
watcher
=
await
initWatcher
(
l1Provider
,
l2Provider
,
addressManager
)
const
l1Bridge
=
await
getL1Bridge
(
l1Wallet
,
addressManager
)
const
l1Bridge
=
await
getL1Bridge
(
l1Wallet
,
addressManager
)
const
l1MessengerAddress
=
await
addressManager
.
getAddress
(
'
Proxy__OVM_L1CrossDomainMessenger
'
)
const
l2MessengerAddress
=
await
addressManager
.
getAddress
(
'
L2CrossDomainMessenger
'
)
const
l1Messenger
=
getContractFactory
(
'
L1CrossDomainMessenger
'
)
const
l1Messenger
=
getContractFactory
(
'
L1CrossDomainMessenger
'
)
.
connect
(
l1Wallet
)
.
connect
(
l1Wallet
)
.
attach
(
watcher
.
l1
.
m
essengerAddress
)
.
attach
(
l1M
essengerAddress
)
const
ovmEth
=
getOvmEth
(
l2Wallet
)
const
ovmEth
=
getOvmEth
(
l2Wallet
)
const
l2Bridge
=
await
getL2Bridge
(
l2Wallet
)
const
l2Bridge
=
await
getL2Bridge
(
l2Wallet
)
const
l2Messenger
=
getContractFactory
(
'
L2CrossDomainMessenger
'
)
const
l2Messenger
=
getContractFactory
(
'
L2CrossDomainMessenger
'
)
.
connect
(
l2Wallet
)
.
connect
(
l2Wallet
)
.
attach
(
watcher
.
l2
.
messengerAddress
)
.
attach
(
l2MessengerAddress
)
const
ctcAddress
=
await
addressManager
.
getAddress
(
const
ctcAddress
=
await
addressManager
.
getAddress
(
'
CanonicalTransactionChain
'
'
CanonicalTransactionChain
'
)
)
...
@@ -159,7 +157,6 @@ export class OptimismEnv {
...
@@ -159,7 +157,6 @@ export class OptimismEnv {
sequencerFeeVault
,
sequencerFeeVault
,
l2Bridge
,
l2Bridge
,
l2Messenger
,
l2Messenger
,
watcher
,
l1Wallet
,
l1Wallet
,
l2Wallet
,
l2Wallet
,
messenger
,
messenger
,
...
@@ -171,10 +168,9 @@ export class OptimismEnv {
...
@@ -171,10 +168,9 @@ export class OptimismEnv {
}
}
async
waitForXDomainTransaction
(
async
waitForXDomainTransaction
(
tx
:
Promise
<
TransactionResponse
>
|
TransactionResponse
,
tx
:
Promise
<
TransactionResponse
>
|
TransactionResponse
direction
:
Direction
):
Promise
<
CrossDomainMessagePair
>
{
):
Promise
<
CrossDomainMessagePair
>
{
return
waitForXDomainTransaction
(
this
.
watcher
,
tx
,
direction
)
return
waitForXDomainTransaction
(
this
.
messenger
,
tx
)
}
}
/**
/**
...
...
integration-tests/test/shared/stress-test-helpers.ts
View file @
a8a74a98
...
@@ -4,7 +4,6 @@ import { sleep } from '@eth-optimism/core-utils'
...
@@ -4,7 +4,6 @@ import { sleep } from '@eth-optimism/core-utils'
/* Imports: Internal */
/* Imports: Internal */
import
{
OptimismEnv
}
from
'
./env
'
import
{
OptimismEnv
}
from
'
./env
'
import
{
Direction
}
from
'
./watcher-utils
'
import
{
gasPriceForL1
,
gasPriceForL2
}
from
'
./utils
'
import
{
gasPriceForL1
,
gasPriceForL2
}
from
'
./utils
'
interface
TransactionParams
{
interface
TransactionParams
{
...
@@ -52,7 +51,7 @@ export const executeL1ToL2Transaction = async (
...
@@ -52,7 +51,7 @@ export const executeL1ToL2Transaction = async (
}
}
)
)
)
)
await
env
.
waitForXDomainTransaction
(
receipt
,
Direction
.
L1ToL2
)
await
env
.
waitForXDomainTransaction
(
receipt
)
}
}
export
const
executeL2ToL1Transaction
=
async
(
export
const
executeL2ToL1Transaction
=
async
(
...
@@ -78,7 +77,7 @@ export const executeL2ToL1Transaction = async (
...
@@ -78,7 +77,7 @@ export const executeL2ToL1Transaction = async (
)
)
await
env
.
relayXDomainMessages
(
receipt
)
await
env
.
relayXDomainMessages
(
receipt
)
await
env
.
waitForXDomainTransaction
(
receipt
,
Direction
.
L2ToL1
)
await
env
.
waitForXDomainTransaction
(
receipt
)
}
}
export
const
executeL2Transaction
=
async
(
export
const
executeL2Transaction
=
async
(
...
...
integration-tests/test/shared/watcher-utils.ts
View file @
a8a74a98
import
{
import
{
JsonRpcProvider
,
TransactionReceipt
,
TransactionReceipt
,
TransactionResponse
,
TransactionResponse
,
}
from
'
@ethersproject/providers
'
}
from
'
@ethersproject/providers
'
import
{
Watcher
}
from
'
@eth-optimism/core-utils
'
import
{
Transaction
}
from
'
ethers
'
import
{
Contract
,
Transaction
}
from
'
ethers
'
import
{
CrossChainMessenger
,
MessageDirection
}
from
'
@eth-optimism/sdk
'
export
const
initWatcher
=
async
(
l1Provider
:
JsonRpcProvider
,
l2Provider
:
JsonRpcProvider
,
AddressManager
:
Contract
)
=>
{
const
l1MessengerAddress
=
await
AddressManager
.
getAddress
(
'
Proxy__OVM_L1CrossDomainMessenger
'
)
const
l2MessengerAddress
=
await
AddressManager
.
getAddress
(
'
L2CrossDomainMessenger
'
)
return
new
Watcher
({
l1
:
{
provider
:
l1Provider
,
messengerAddress
:
l1MessengerAddress
,
},
l2
:
{
provider
:
l2Provider
,
messengerAddress
:
l2MessengerAddress
,
},
})
}
export
interface
CrossDomainMessagePair
{
export
interface
CrossDomainMessagePair
{
tx
:
Transaction
tx
:
Transaction
...
@@ -42,41 +18,33 @@ export enum Direction {
...
@@ -42,41 +18,33 @@ export enum Direction {
}
}
export
const
waitForXDomainTransaction
=
async
(
export
const
waitForXDomainTransaction
=
async
(
watcher
:
Watcher
,
messenger
:
CrossChainMessenger
,
tx
:
Promise
<
TransactionResponse
>
|
TransactionResponse
,
tx
:
Promise
<
TransactionResponse
>
|
TransactionResponse
direction
:
Direction
):
Promise
<
CrossDomainMessagePair
>
=>
{
):
Promise
<
CrossDomainMessagePair
>
=>
{
const
{
src
,
dest
}
=
direction
===
Direction
.
L1ToL2
?
{
src
:
watcher
.
l1
,
dest
:
watcher
.
l2
}
:
{
src
:
watcher
.
l2
,
dest
:
watcher
.
l1
}
// await it if needed
// await it if needed
tx
=
await
tx
tx
=
await
tx
// get the receipt and the full transaction
const
receipt
=
await
tx
.
wait
()
const
fullTx
=
await
src
.
provider
.
getTransaction
(
tx
.
hash
)
// get the message hash which was created on the SentMessage
const
receipt
=
await
tx
.
wait
()
const
[
xDomainMsgHash
]
=
await
watcher
.
getMessageHashesFromTx
(
src
,
tx
.
hash
)
const
resolved
=
await
messenger
.
toCrossChainMessage
(
tx
)
const
messageReceipt
=
await
messenger
.
waitForMessageReceipt
(
tx
)
if
(
!
xDomainMsgHash
)
{
let
fullTx
:
any
throw
new
Error
(
`No x-domain message hash for tx hash
${
tx
.
hash
}
, bailing.`
)
let
remoteTx
:
any
if
(
resolved
.
direction
===
MessageDirection
.
L1_TO_L2
)
{
fullTx
=
await
messenger
.
l1Provider
.
getTransaction
(
tx
.
hash
)
remoteTx
=
await
messenger
.
l2Provider
.
getTransaction
(
messageReceipt
.
transactionReceipt
.
transactionHash
)
}
else
{
fullTx
=
await
messenger
.
l2Provider
.
getTransaction
(
tx
.
hash
)
remoteTx
=
await
messenger
.
l1Provider
.
getTransaction
(
messageReceipt
.
transactionReceipt
.
transactionHash
)
}
}
// Get the transaction and receipt on the remote layer
const
remoteReceipt
=
await
watcher
.
getTransactionReceipt
(
dest
,
xDomainMsgHash
)
const
remoteTx
=
await
dest
.
provider
.
getTransaction
(
remoteReceipt
.
transactionHash
)
return
{
return
{
tx
:
fullTx
,
tx
:
fullTx
,
receipt
,
receipt
,
remoteTx
,
remoteTx
,
remoteReceipt
,
remoteReceipt
:
messageReceipt
.
transactionReceipt
,
}
}
}
}
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