-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update depositTo
to use standard deposit
#432
Changes from 23 commits
a46d10c
46eef8c
e4fe0e9
b6e3367
ef23805
3643277
558d3b2
3ebcf97
095e32f
bd81133
dc785a3
d60496b
b3a75ae
c5f8f44
b7bc453
a5d57c1
bdb0ddb
d3adcad
a62d213
5f350b8
1d39c00
3999758
fc061af
10e67e3
eff5d4d
030e190
5f71fef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,6 +21,7 @@ | |||||||||||||||||||
|
||||||||||||||||||||
import { Wallet } from '@ethersproject/wallet' | ||||||||||||||||||||
import { parseEther } from '@ethersproject/units' | ||||||||||||||||||||
import { constants } from 'ethers' | ||||||||||||||||||||
|
||||||||||||||||||||
import { | ||||||||||||||||||||
fundL1, | ||||||||||||||||||||
|
@@ -32,11 +33,15 @@ | |||||||||||||||||||
import { L2ToL1Message } from '../../src/lib/message/L2ToL1Message' | ||||||||||||||||||||
import { L2ToL1MessageStatus } from '../../src/lib/dataEntities/message' | ||||||||||||||||||||
import { L2TransactionReceipt } from '../../src/lib/message/L2Transaction' | ||||||||||||||||||||
import { L1ToL2MessageStatus } from '../../src/lib/message/L1ToL2Message' | ||||||||||||||||||||
import { | ||||||||||||||||||||
L1ToL2MessageStatus, | ||||||||||||||||||||
L1ToL2MessageWriter, | ||||||||||||||||||||
} from '../../src/lib/message/L1ToL2Message' | ||||||||||||||||||||
import { testSetup } from '../../scripts/testSetup' | ||||||||||||||||||||
import { isL2NetworkWithCustomFeeToken } from './custom-fee-token/customFeeTokenTestHelpers' | ||||||||||||||||||||
import { ERC20__factory } from '../../src/lib/abi/factories/ERC20__factory' | ||||||||||||||||||||
import { itOnlyWhenEth } from './custom-fee-token/mochaExtensions' | ||||||||||||||||||||
import { L1TransactionReceipt } from '../../src' | ||||||||||||||||||||
|
||||||||||||||||||||
dotenv.config() | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -211,6 +216,60 @@ | |||||||||||||||||||
) | ||||||||||||||||||||
}) | ||||||||||||||||||||
|
||||||||||||||||||||
it('deposit ether to a specific L2 address and check balance before auto-redeem', async () => { | ||||||||||||||||||||
const { ethBridger, l1Signer, l2Signer } = await testSetup() | ||||||||||||||||||||
|
||||||||||||||||||||
await fundL1(l1Signer) | ||||||||||||||||||||
const destWallet = Wallet.createRandom() | ||||||||||||||||||||
|
||||||||||||||||||||
const ethToDeposit = parseEther('0.0002') | ||||||||||||||||||||
const res = await ethBridger.depositTo({ | ||||||||||||||||||||
amount: ethToDeposit, | ||||||||||||||||||||
l1Signer: l1Signer, | ||||||||||||||||||||
destinationAddress: destWallet.address, | ||||||||||||||||||||
l2Provider: l2Signer.provider!, | ||||||||||||||||||||
retryableGasOverrides: { | ||||||||||||||||||||
gasLimit: { | ||||||||||||||||||||
// causes auto-redeem to fail which allows us to check balances before it happens | ||||||||||||||||||||
base: constants.Zero, | ||||||||||||||||||||
}, | ||||||||||||||||||||
}, | ||||||||||||||||||||
}) | ||||||||||||||||||||
const rec = await res.wait() | ||||||||||||||||||||
const l1ToL2Messages = await rec.getL1ToL2Messages(l2Signer.provider!) | ||||||||||||||||||||
expect(l1ToL2Messages.length).to.eq(1, 'failed to find 1 l1 to l2 message') | ||||||||||||||||||||
let l1ToL2Message = l1ToL2Messages[0] | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
const retryableTicketResult = await l1ToL2Message.waitForStatus() | ||||||||||||||||||||
|
||||||||||||||||||||
expect(retryableTicketResult.status).to.eq( | ||||||||||||||||||||
L1ToL2MessageStatus.FUNDS_DEPOSITED_ON_L2, | ||||||||||||||||||||
'unexpected status, expected auto-redeem to fail' | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
const testWalletL2EthBalance = await l2Signer.provider!.getBalance( | ||||||||||||||||||||
destWallet.address | ||||||||||||||||||||
) | ||||||||||||||||||||
expect( | ||||||||||||||||||||
testWalletL2EthBalance.lt(ethToDeposit), | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets assert it's zero |
||||||||||||||||||||
'balance before auto-redeem' | ||||||||||||||||||||
).to.be.true | ||||||||||||||||||||
|
||||||||||||||||||||
const l1TxHash = await l1Signer.provider!.getTransactionReceipt(res.hash) | ||||||||||||||||||||
const l1Receipt = new L1TransactionReceipt(l1TxHash) | ||||||||||||||||||||
l1ToL2Message = l1Receipt.getL1ToL2Messages(l2Signer)[0] | ||||||||||||||||||||
Check failure on line 260 in tests/integration/eth.test.ts
|
||||||||||||||||||||
|
||||||||||||||||||||
if (l1ToL2Message instanceof L1ToL2MessageWriter) { | ||||||||||||||||||||
const res = await l1ToL2Message.redeem() | ||||||||||||||||||||
await res.wait() | ||||||||||||||||||||
} | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
expect( | ||||||||||||||||||||
testWalletL2EthBalance.toString(), | ||||||||||||||||||||
'balance after manual redeem' | ||||||||||||||||||||
).to.eq(ethToDeposit.toString()) | ||||||||||||||||||||
}) | ||||||||||||||||||||
|
||||||||||||||||||||
it('withdraw Ether transaction succeeds', async () => { | ||||||||||||||||||||
const { l2Signer, l1Signer, ethBridger } = await testSetup() | ||||||||||||||||||||
await fundL2(l2Signer) | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.