github.com/ethereum-optimism/optimism@v1.7.2/packages/sdk/test-next/messageStatus.spec.ts (about) 1 import { describe, expect, it } from 'vitest' 2 3 import { CrossChainMessenger, MessageStatus } from '../src' 4 import { l1Provider, l2Provider } from './testUtils/ethersProviders' 5 6 const crossChainMessenger = new CrossChainMessenger({ 7 l1SignerOrProvider: l1Provider, 8 l2SignerOrProvider: l2Provider, 9 l1ChainId: 5, 10 l2ChainId: 420, 11 bedrock: true, 12 }) 13 14 describe('getMessageStatus', () => { 15 it(`should be able to correctly find a finalized withdrawal`, async () => { 16 /** 17 * Tx hash of a withdrawal 18 * 19 * @see https://goerli-optimism.etherscan.io/tx/0x8fb235a61079f3fa87da66e78c9da075281bc4ba5f1af4b95197dd9480e03bb5 20 */ 21 const txWithdrawalHash = 22 '0x8fb235a61079f3fa87da66e78c9da075281bc4ba5f1af4b95197dd9480e03bb5' 23 24 const txReceipt = await l2Provider.getTransactionReceipt(txWithdrawalHash) 25 26 expect(txReceipt).toBeDefined() 27 28 expect( 29 await crossChainMessenger.getMessageStatus( 30 txWithdrawalHash, 31 0, 32 9370789 - 1000, 33 9370789 34 ) 35 ).toBe(MessageStatus.RELAYED) 36 }, 20_000) 37 38 it(`should return READY_FOR_RELAY if not in block range`, async () => { 39 const txWithdrawalHash = 40 '0x8fb235a61079f3fa87da66e78c9da075281bc4ba5f1af4b95197dd9480e03bb5' 41 42 const txReceipt = await l2Provider.getTransactionReceipt(txWithdrawalHash) 43 44 expect(txReceipt).toBeDefined() 45 46 expect( 47 await crossChainMessenger.getMessageStatus(txWithdrawalHash, 0, 0, 0) 48 ).toBe(MessageStatus.READY_FOR_RELAY) 49 }, 20_000) 50 })