Skip to content

Commit

Permalink
eth test works
Browse files Browse the repository at this point in the history
  • Loading branch information
godzillaba committed Jan 25, 2024
1 parent 19a3cc0 commit 6d66564
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tests/integration/eth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ import { L2ToL1MessageStatus } from '../../src/lib/dataEntities/message'
import { L2TransactionReceipt } from '../../src/lib/message/L2Transaction'
import { L1ToL2MessageStatus } from '../../src/lib/message/L1ToL2Message'
import { testSetup } from '../../scripts/testSetup'
import {
fundL1CustomFeeToken,
isL2NetworkWithCustomFeeToken,
} from './custom-fee-token/customFeeTokenTestHelpers'
import { ERC20__factory } from '../../src/lib/abi/factories/ERC20__factory'
dotenv.config()

describe('Ether', async () => {
Expand Down Expand Up @@ -79,6 +84,8 @@ describe('Ether', async () => {
})

it('"EthBridger.approveFeeToken" throws when eth is used as native/fee token', async () => {
if (isL2NetworkWithCustomFeeToken()) return

const { ethBridger, l1Signer } = await testSetup()

try {
Expand All @@ -93,6 +100,12 @@ describe('Ether', async () => {
const { ethBridger, l1Signer, l2Signer } = await testSetup()

await fundL1(l1Signer)

if (isL2NetworkWithCustomFeeToken()) {
await fundL1CustomFeeToken(l1Signer)
await (await ethBridger.approveFeeToken({ l1Signer })).wait()
}

const inboxAddress = ethBridger.l2Network.ethBridge.inbox

const initialInboxBalance = await l1Signer.provider!.getBalance(
Expand Down Expand Up @@ -140,6 +153,12 @@ describe('Ether', async () => {
const { ethBridger, l1Signer, l2Signer } = await testSetup()

await fundL1(l1Signer)

if (isL2NetworkWithCustomFeeToken()) {
await fundL1CustomFeeToken(l1Signer)
await (await ethBridger.approveFeeToken({ l1Signer })).wait()
}

const inboxAddress = ethBridger.l2Network.ethBridge.inbox
const destWallet = Wallet.createRandom()

Expand Down Expand Up @@ -300,9 +319,13 @@ describe('Ether', async () => {
'executed status'
).to.eq(L2ToL1MessageStatus.EXECUTED)

const finalRandomBalance = await l1Signer.provider!.getBalance(
randomAddress
)
const finalRandomBalance = isL2NetworkWithCustomFeeToken()
? await ERC20__factory.connect(
ethBridger.nativeToken!,
l1Signer.provider!
).balanceOf(randomAddress)
: await l1Signer.provider!.getBalance(randomAddress)

expect(finalRandomBalance.toString(), 'L1 final balance').to.eq(
ethToWithdraw.toString()
)
Expand Down

0 comments on commit 6d66564

Please sign in to comment.