Commit 36a91c30 authored by Murphy Law's avatar Murphy Law Committed by GitHub

integration-tests: Fix various actor tests (#2517)

Several tests were failing with out of gas errors because they began executing before their
wallets were adequately funded.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 1bcee8f1
---
'@eth-optimism/integration-tests': patch
---
Fix various actor tests
...@@ -49,10 +49,11 @@ actor('Value sender', () => { ...@@ -49,10 +49,11 @@ actor('Value sender', () => {
setupRun(async () => { setupRun(async () => {
const wallet = Wallet.createRandom() const wallet = Wallet.createRandom()
await env.l2Wallet.sendTransaction({ const tx = await env.l2Wallet.sendTransaction({
to: wallet.address, to: wallet.address,
value: utils.parseEther('0.01'), value: utils.parseEther('0.01'),
}) })
await tx.wait()
return { return {
wallet: wallet.connect(env.l2Wallet.provider), wallet: wallet.connect(env.l2Wallet.provider),
} }
...@@ -61,10 +62,11 @@ actor('Value sender', () => { ...@@ -61,10 +62,11 @@ actor('Value sender', () => {
run(async (b, ctx: Context) => { run(async (b, ctx: Context) => {
const randWallet = Wallet.createRandom().connect(env.l2Wallet.provider) const randWallet = Wallet.createRandom().connect(env.l2Wallet.provider)
await b.bench('send funds', async () => { await b.bench('send funds', async () => {
await ctx.wallet.sendTransaction({ const tx = await ctx.wallet.sendTransaction({
to: randWallet.address, to: randWallet.address,
value: 0x42, value: 0x42,
}) })
await tx.wait()
}) })
expect(await randWallet.getBalance()).to.deep.equal(BigNumber.from(0x42)) expect(await randWallet.getBalance()).to.deep.equal(BigNumber.from(0x42))
}) })
...@@ -163,4 +165,4 @@ actor_successful_actor_runs_total{actor_name="value_sender"} 40 ...@@ -163,4 +165,4 @@ actor_successful_actor_runs_total{actor_name="value_sender"} 40
# HELP actor_failed_actor_runs_total Count of total failed actor runs. # HELP actor_failed_actor_runs_total Count of total failed actor runs.
# TYPE actor_failed_actor_runs_total counter # TYPE actor_failed_actor_runs_total counter
``` ```
\ No newline at end of file
...@@ -21,10 +21,11 @@ actor('Funds depositor', () => { ...@@ -21,10 +21,11 @@ actor('Funds depositor', () => {
setupRun(async () => { setupRun(async () => {
const wallet = Wallet.createRandom() const wallet = Wallet.createRandom()
await env.l1Wallet.sendTransaction({ const tx = await env.l1Wallet.sendTransaction({
to: wallet.address, to: wallet.address,
value: utils.parseEther('0.01'), value: utils.parseEther('0.01'),
}) })
await tx.wait()
return { return {
l1Wallet: wallet.connect(env.l1Wallet.provider), l1Wallet: wallet.connect(env.l1Wallet.provider),
l2Wallet: wallet.connect(env.l2Wallet.provider), l2Wallet: wallet.connect(env.l2Wallet.provider),
...@@ -36,7 +37,7 @@ actor('Funds depositor', () => { ...@@ -36,7 +37,7 @@ actor('Funds depositor', () => {
const balBefore = await l2Wallet.getBalance() const balBefore = await l2Wallet.getBalance()
await b.bench('deposit', async () => { await b.bench('deposit', async () => {
await env.waitForXDomainTransaction( await env.waitForXDomainTransaction(
env.l1Bridge env.messenger.contracts.l1.L1StandardBridge
.connect(l1Wallet) .connect(l1Wallet)
.depositETH(DEFAULT_TEST_GAS_L2, '0xFFFF', { .depositETH(DEFAULT_TEST_GAS_L2, '0xFFFF', {
value: 0x42, value: 0x42,
...@@ -44,8 +45,10 @@ actor('Funds depositor', () => { ...@@ -44,8 +45,10 @@ actor('Funds depositor', () => {
}) })
) )
}) })
expect((await l2Wallet.getBalance()).sub(balBefore)).to.deep.equal( // Converting BigNumber to hex string prevents chai from incorrectly considering inherited properties
BigNumber.from(0x42) // for strict equality - https://github.com/chaijs/chai/issues/948
expect((await l2Wallet.getBalance()).sub(balBefore).toString()).to.deep.equal(
BigNumber.from(0x42).toString()
) )
}) })
}) })
...@@ -22,10 +22,11 @@ actor('NFT claimer', () => { ...@@ -22,10 +22,11 @@ actor('NFT claimer', () => {
setupRun(async () => { setupRun(async () => {
const wallet = Wallet.createRandom().connect(env.l2Wallet.provider) const wallet = Wallet.createRandom().connect(env.l2Wallet.provider)
await env.l2Wallet.sendTransaction({ const tx = await env.l2Wallet.sendTransaction({
to: wallet.address, to: wallet.address,
value: utils.parseEther('0.01'), value: utils.parseEther('0.01'),
}) })
await tx.wait()
return { return {
wallet, wallet,
contract: contract.connect(wallet), contract: contract.connect(wallet),
......
...@@ -17,10 +17,11 @@ actor('Value sender', () => { ...@@ -17,10 +17,11 @@ actor('Value sender', () => {
setupRun(async () => { setupRun(async () => {
const wallet = Wallet.createRandom() const wallet = Wallet.createRandom()
await env.l2Wallet.sendTransaction({ const tx = await env.l2Wallet.sendTransaction({
to: wallet.address, to: wallet.address,
value: utils.parseEther('0.01'), value: utils.parseEther('0.01'),
}) })
await tx.wait()
return { return {
wallet: wallet.connect(env.l2Wallet.provider), wallet: wallet.connect(env.l2Wallet.provider),
} }
...@@ -29,10 +30,11 @@ actor('Value sender', () => { ...@@ -29,10 +30,11 @@ actor('Value sender', () => {
run(async (b, ctx: Context) => { run(async (b, ctx: Context) => {
const randWallet = Wallet.createRandom().connect(env.l2Wallet.provider) const randWallet = Wallet.createRandom().connect(env.l2Wallet.provider)
await b.bench('send funds', async () => { await b.bench('send funds', async () => {
await ctx.wallet.sendTransaction({ const tx = await ctx.wallet.sendTransaction({
to: randWallet.address, to: randWallet.address,
value: 0x42, value: 0x42,
}) })
await tx.wait()
}) })
expect((await randWallet.getBalance()).toString()).to.deep.equal('66') expect((await randWallet.getBalance()).toString()).to.deep.equal('66')
}) })
......
...@@ -24,10 +24,11 @@ actor('Trie DoS accounts', () => { ...@@ -24,10 +24,11 @@ actor('Trie DoS accounts', () => {
setupRun(async () => { setupRun(async () => {
const wallet = Wallet.createRandom() const wallet = Wallet.createRandom()
await env.l2Wallet.sendTransaction({ const tx = await env.l2Wallet.sendTransaction({
to: wallet.address, to: wallet.address,
value: utils.parseEther('1'), value: utils.parseEther('1'),
}) })
await tx.wait()
return { return {
wallet: wallet.connect(env.l2Wallet.provider), wallet: wallet.connect(env.l2Wallet.provider),
} }
......
...@@ -50,10 +50,11 @@ actor('Uniswap swapper', () => { ...@@ -50,10 +50,11 @@ actor('Uniswap swapper', () => {
setupRun(async () => { setupRun(async () => {
const wallet = Wallet.createRandom().connect(env.l2Provider) const wallet = Wallet.createRandom().connect(env.l2Provider)
await env.l2Wallet.sendTransaction({ const sendTx = await env.l2Wallet.sendTransaction({
to: wallet.address, to: wallet.address,
value: utils.parseEther('0.1'), value: utils.parseEther('0.1'),
}) })
await sendTx.wait()
for (const token of tokens) { for (const token of tokens) {
let tx = await token.transfer(wallet.address, 1000000) let tx = await token.transfer(wallet.address, 1000000)
......
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