Commit 453e8c53 authored by smartcontracts's avatar smartcontracts Committed by GitHub

Merge pull request #2153 from ethereum-optimism/sc/sdk-integration-3

feat(itests): remove Watcher from fundUser
parents c826fddb 3535fb2f
......@@ -38,7 +38,7 @@ describe('Native ETH value integration tests', () => {
}
const value = ethers.utils.parseEther('0.01')
await fundUser(env.watcher, env.l1Bridge, value, wallet.address)
await fundUser(env.messenger, value, wallet.address)
const initialBalances = await getBalances()
......@@ -156,12 +156,7 @@ describe('Native ETH value integration tests', () => {
beforeEach(async () => {
ValueCalls0 = await Factory__ValueCalls.deploy()
ValueCalls1 = await Factory__ValueCalls.deploy()
await fundUser(
env.watcher,
env.l1Bridge,
initialBalance0,
ValueCalls0.address
)
await fundUser(env.messenger, initialBalance0, ValueCalls0.address)
// These tests ass assume ValueCalls0 starts with a balance, but ValueCalls1 does not.
await checkBalances([initialBalance0, 0])
})
......@@ -203,12 +198,7 @@ describe('Native ETH value integration tests', () => {
it('should have the correct ovmSELFBALANCE which includes the msg.value', async () => {
// give an initial balance which the ovmCALLVALUE should be added to when calculating ovmSELFBALANCE
const initialBalance = 10
await fundUser(
env.watcher,
env.l1Bridge,
initialBalance,
ValueCalls1.address
)
await fundUser(env.messenger, initialBalance, ValueCalls1.address)
const sendAmount = 15
const [success, returndata] = await ValueCalls0.callStatic.sendWithData(
......
......@@ -219,7 +219,7 @@ describe('Basic RPC tests', () => {
// Fund account to call from
const from = wallet.address
const value = 15
await fundUser(env.watcher, env.l1Bridge, value, from)
await fundUser(env.messenger, value, from)
// Do the call and check msg.value
const data = ValueContext.interface.encodeFunctionData('getCallValue')
......
......@@ -85,6 +85,13 @@ export class OptimismEnv {
}
static async new(): Promise<OptimismEnv> {
const network = await l1Provider.getNetwork()
const messenger = new CrossChainMessenger({
l1SignerOrProvider: l1Wallet,
l2SignerOrProvider: l2Wallet,
l1ChainId: network.chainId,
})
const addressManager = getAddressManager(l1Wallet)
const watcher = await initWatcher(l1Provider, l2Provider, addressManager)
const l1Bridge = await getL1Bridge(l1Wallet, addressManager)
......@@ -94,7 +101,7 @@ export class OptimismEnv {
const min = envConfig.L2_WALLET_MIN_BALANCE_ETH.toString()
const topUp = envConfig.L2_WALLET_TOP_UP_AMOUNT_ETH.toString()
if (balance.lt(utils.parseEther(min))) {
await fundUser(watcher, l1Bridge, utils.parseEther(topUp))
await fundUser(messenger, utils.parseEther(topUp))
}
const l1Messenger = getContractFactory('L1CrossDomainMessenger')
.connect(l1Wallet)
......@@ -129,13 +136,6 @@ 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,
......
......@@ -4,7 +4,6 @@ import {
Wallet,
constants,
providers,
BigNumberish,
BigNumber,
utils,
} from 'ethers'
......@@ -13,13 +12,13 @@ import {
getContractInterface,
predeploys,
} from '@eth-optimism/contracts'
import { injectL2Context, remove0x, Watcher } from '@eth-optimism/core-utils'
import { injectL2Context, remove0x } from '@eth-optimism/core-utils'
import { CrossChainMessenger, NumberLike } from '@eth-optimism/sdk'
import { cleanEnv, str, num, bool, makeValidator } from 'envalid'
import dotenv from 'dotenv'
dotenv.config()
/* Imports: Internal */
import { Direction, waitForXDomainTransaction } from './watcher-utils'
import { OptimismEnv } from './env'
export const isLiveNetwork = () => {
......@@ -180,23 +179,26 @@ export const getOvmEth = (wallet: Wallet) => {
}
export const fundUser = async (
watcher: Watcher,
bridge: Contract,
amount: BigNumberish,
messenger: CrossChainMessenger,
amount: NumberLike,
recipient?: string
) => {
const value = BigNumber.from(amount)
const tx = recipient
? bridge.depositETHTo(recipient, DEFAULT_TEST_GAS_L2, '0x', {
value,
gasLimit: DEFAULT_TEST_GAS_L1,
})
: bridge.depositETH(DEFAULT_TEST_GAS_L2, '0x', {
value,
gasLimit: DEFAULT_TEST_GAS_L1,
})
await waitForXDomainTransaction(watcher, tx, Direction.L1ToL2)
await messenger.waitForMessageReceipt(
await messenger.depositETH(amount, {
l2GasLimit: DEFAULT_TEST_GAS_L2,
overrides: {
gasPrice: DEFAULT_TEST_GAS_L1,
},
})
)
if (recipient !== undefined) {
const tx = await messenger.l2Signer.sendTransaction({
to: recipient,
value: amount,
})
await tx.wait()
}
}
export const conditionalTest = (
......
......@@ -47,12 +47,7 @@ describe('stress tests', () => {
}
for (const wallet of wallets) {
await fundUser(
env.watcher,
env.l1Bridge,
utils.parseEther('0.1'),
wallet.address
)
await fundUser(env.messenger, utils.parseEther('0.1'), wallet.address)
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment