Commit 892b1d16 authored by Will Cory's avatar Will Cory Committed by Mark Tyneway

test: Add failing test to sdk.proveMessage

parent efa4013e
......@@ -535,6 +535,40 @@ jobs:
name: Upload coverage
command: codecov --verbose --clean --flags <<parameters.coverage_flag>>
sdk-next-tests:
docker:
- image: ethereumoptimism/ci-builder:latest
resource_class: large
steps:
- checkout
- attach_workspace: { at: '.' }
- check-changed:
patterns: sdk,contracts-bedrock,contracts
- run:
name: anvil-l1
background: true
command: anvil --fork-url $ANVIL_L1_FORK_URL
- run:
name: anvil-l2
background: true
command: anvil --fork-url $ANVIL_L2_FORK_URL --port 9545
- run:
name: make sure anvil l1 is up
command: cast block-number --rpc-url http://localhost:8545
- run:
name: make sure anvil l2 is up
command: cast block-number --rpc-url http://localhost:9545
- run:
name: test:next
command: yarn test:next
no_output_timeout: 5m
working_directory: packages/sdk
environment:
# anvil[0] test private key
VITE_E2E_PRIVATE_KEY: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
VITE_E2E_RPC_URLS_L1: http://localhost:8545
VITE_E2E_RPC_URLS_L2: http://localhost:9545
bedrock-markdown:
machine:
image: ubuntu-2204:2022.07.1
......
......@@ -46,7 +46,8 @@
"hardhat-deploy": "^0.11.4",
"nyc": "^15.1.0",
"typedoc": "^0.22.13",
"mocha": "^10.0.0"
"mocha": "^10.0.0",
"vitest": "^0.28.3"
},
"dependencies": {
"@eth-optimism/contracts": "0.5.40",
......@@ -55,7 +56,7 @@
"lodash": "^4.17.21",
"merkletreejs": "^0.2.27",
"rlp": "^2.2.7",
"vitest": "^0.28.3"
"zod": "^3.11.6"
},
"peerDependencies": {
"ethers": "^5"
......
......@@ -572,6 +572,9 @@ export class CrossChainMessenger {
public async toCrossChainMessage(
message: MessageLike
): Promise<CrossChainMessage> {
if (!message) {
throw new Error('message is undefined')
}
// TODO: Convert these checks into proper type checks.
if ((message as CrossChainMessage).message) {
return message as CrossChainMessage
......
This diff is collapsed.
import ethers from 'ethers'
import { describe, expect, it } from 'vitest'
import { z } from 'zod'
import { CrossChainMessenger } from '../src'
/**
* This test repros the bug where legacy withdrawals are not provable
*/
/**
/*******
Cast results from runnning cast tx and cast receipt on the l2 tx hash
cast tx 0xd66fda632b51a8b25a9d260d70da8be57b9930c4616370861526335c3e8eef81 --rpc-url https://goerli.optimism.io
......@@ -42,25 +48,33 @@ transactionHash 0xd66fda632b51a8b25a9d260d70da8be57b9930c461637086152633
transactionIndex 0
type
*/
import { CrossChainMessenger } from '../src'
import ethers from 'ethers'
import { describe, expect, it } from 'vitest'
import {z} from 'zod'
const E2E_RPC_URL_L1= z.string().url().describe('L1 ethereum rpc Url').parse(import.meta.env.VITE_E2E_RPC_URL_L1)
const E2E_RPC_URL_L2= z.string().url().describe('L1 ethereum rpc Url').parse(import.meta.env.VITE_E2E_RPC_URL_L2)
const E2E_PRIVATE_KEY= z.string().describe('Private key').parse(import.meta.env.VITE_E2E_PRIVATE_KEY)
const E2E_RPC_URL_L1 = z
.string()
.url()
.describe('L1 ethereum rpc Url')
.parse(import.meta.env.VITE_E2E_RPC_URL_L1)
const E2E_RPC_URL_L2 = z
.string()
.url()
.describe('L1 ethereum rpc Url')
.parse(import.meta.env.VITE_E2E_RPC_URL_L2)
const E2E_PRIVATE_KEY = z
.string()
.describe('Private key')
.parse(import.meta.env.VITE_E2E_PRIVATE_KEY)
const jsonRpcHeaders = { 'User-Agent': 'eth-optimism/@gateway/backend' }
/**
* Initialize the signer, prover, and cross chain messenger
*/
const l2Provider = new ethers.providers.JsonRpcProvider(
E2E_RPC_URL_L1
)
const l1Provider = new ethers.providers.JsonRpcProvider(
E2E_RPC_URL_L2
)
const l1Provider = new ethers.providers.JsonRpcProvider({
url: E2E_RPC_URL_L1,
headers: jsonRpcHeaders,
})
const l2Provider = new ethers.providers.JsonRpcProvider({
url: E2E_RPC_URL_L2,
headers: jsonRpcHeaders,
})
const l1Wallet = new ethers.Wallet(E2E_PRIVATE_KEY, l1Provider)
const crossChainMessenger = new CrossChainMessenger({
l1SignerOrProvider: l1Wallet,
......@@ -83,9 +97,10 @@ describe('prove message', () => {
const txReceipt = await l2Provider.getTransactionReceipt(txWithdrawalHash)
expect(txReceipt).toBeDefined()
expect(
await crossChainMessenger.proveMessage(txReceipt)
).toMatchInlineSnapshot(
)
await crossChainMessenger.proveMessage(txWithdrawalHash)
).toMatchInlineSnapshot()
}, 20_000)
})
\ No newline at end of file
})
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