Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsoncusack committed Sep 1, 2023
1 parent b213241 commit 50cc047
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/actions/public/L1/getL2HashesForDepositTx.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { test, expect } from 'vitest'
import { publicClient } from '../../../_test/utils'
import { getL2HashesForDepositTx } from './getL2HashesForDepositTx'
import { ethers } from 'ethers'
import { ethers, providers } from 'ethers'
import { optimism } from '@roninjin10/rollup-chains'
import { optimismPortalABI } from '@eth-optimism/contracts-ts'
import { ethersProvider } from '../../../_test/bench'
import { DepositTx } from '@eth-optimism/core-utils'
import { mainnet } from '@wagmi/chains'

test('correctly retrieves L2 hash', async () => {
const hashes = await getL2HashesForDepositTx(publicClient, {
Expand All @@ -29,13 +29,15 @@ test('matches @eth-optimism/core-utils', async () => {
const contract = new ethers.Contract(
optimism.opContracts.OptimismPortalProxy,
optimismPortalABI,
ethersProvider,
// using live provider rather than fork because was giving rate limit issues in CI
new providers.JsonRpcProvider(mainnet.rpcUrls.public.http[0]),
)
const filter = contract.filters['TransactionDeposited'](
'0x36BDE71C97B33Cc4729cf772aE268934f7AB70B2',
'0x4200000000000000000000000000000000000007',
)
const events = await contract.queryFilter(filter, 18033412, 18033413)
console.log(events[0])
const depositTx = DepositTx.fromL1Event(events[0])
expect(depositTx.hash()).toEqual(hashes[0])
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { optimismPortalABI } from '@eth-optimism/contracts-ts'
import { optimism } from '@roninjin10/rollup-chains'
import { BigNumber, ethers } from 'ethers'
import { BigNumber, ethers, providers } from 'ethers'
import { expect, test } from 'vitest'
import { ethersProvider } from '../_test/bench'
import { DepositTx } from '@eth-optimism/core-utils'
Expand All @@ -10,6 +10,7 @@ import { getDepositEventsInfoFromTxReceipt } from './getDepositEventsInfoFromTxR
import { getDepositTransactionFromTransactionDepositedEvent } from './getDepositTransactionFromTransactionDepositedEvent'
import { getSourceHash } from './getSourceHash'
import { SourceHashDomain } from '../types/depositTransaction'
import { mainnet } from '@wagmi/chains'

// Simply testing against another implementation is not the best practice
// but I added these after debugging a difference. They will be useful to have
Expand All @@ -18,7 +19,8 @@ test('derives same values as op-ethereum/core-utils', async () => {
const contract = new ethers.Contract(
optimism.opContracts.OptimismPortalProxy,
optimismPortalABI,
ethersProvider,
// using live provider rather than fork because was giving rate limit issues in CI
new providers.JsonRpcProvider(mainnet.rpcUrls.public.http[0]),
)
const filter = contract.filters['TransactionDeposited'](
'0x36BDE71C97B33Cc4729cf772aE268934f7AB70B2',
Expand Down

0 comments on commit 50cc047

Please sign in to comment.