Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
7b5ccb36
Unverified
Commit
7b5ccb36
authored
Nov 05, 2021
by
Matthew Slipper
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integration-tests: Test a bridged token transfer too
parent
35d97956
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
9 deletions
+49
-9
bridged-tokens.ts
integration-tests/test/bridged-tokens.ts
+49
-9
No files found.
integration-tests/test/bridged-tokens.ts
View file @
7b5ccb36
import
{
BigNumber
,
Contract
,
ContractFactory
}
from
'
ethers
'
import
{
BigNumber
,
Contract
,
ContractFactory
,
utils
,
Wallet
}
from
'
ethers
'
import
{
ethers
}
from
'
hardhat
'
import
*
as
L2Artifact
from
'
@eth-optimism/contracts/artifacts/contracts/standards/L2StandardERC20.sol/L2StandardERC20.json
'
import
{
expect
}
from
'
chai
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
isLiveNetwork
,
l1Wallet
}
from
'
./shared/utils
'
import
{
isLiveNetwork
}
from
'
./shared/utils
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
describe
(
'
Bridged tokens
'
,
()
=>
{
let
env
:
OptimismEnv
let
otherWalletL1
:
Wallet
let
otherWalletL2
:
Wallet
let
L1Factory__ERC20
:
ContractFactory
let
L1__ERC20
:
Contract
let
L2Factory__ERC20
:
ContractFactory
...
...
@@ -18,6 +21,18 @@ describe('Bridged tokens', () => {
before
(
async
()
=>
{
env
=
await
OptimismEnv
.
new
()
const
other
=
Wallet
.
createRandom
()
otherWalletL1
=
other
.
connect
(
env
.
l1Wallet
.
provider
)
otherWalletL2
=
other
.
connect
(
env
.
l2Wallet
.
provider
)
await
env
.
l1Wallet
.
sendTransaction
({
to
:
otherWalletL1
.
address
,
value
:
utils
.
parseEther
(
'
0.01
'
),
})
await
env
.
l2Wallet
.
sendTransaction
({
to
:
otherWalletL2
.
address
,
value
:
utils
.
parseEther
(
'
0.01
'
),
})
L1Factory__ERC20
=
await
ethers
.
getContractFactory
(
'
ERC20
'
,
env
.
l1Wallet
)
L2Factory__ERC20
=
new
ethers
.
ContractFactory
(
L2Artifact
.
abi
,
...
...
@@ -55,27 +70,52 @@ describe('Bridged tokens', () => {
'
0x
'
)
await
env
.
waitForXDomainTransaction
(
tx
,
Direction
.
L1ToL2
)
expect
(
await
L1__ERC20
.
balanceOf
(
l1Wallet
.
address
)).
to
.
deep
.
equal
(
expect
(
await
L1__ERC20
.
balanceOf
(
env
.
l1Wallet
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
999000
)
)
expect
(
await
L2__ERC20
.
balanceOf
(
l1
Wallet
.
address
)).
to
.
deep
.
equal
(
expect
(
await
L2__ERC20
.
balanceOf
(
env
.
l2
Wallet
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
1000
)
)
}).
timeout
(
isLiveNetwork
()
?
300
_000
:
120
_000
)
it
(
'
should withdraw tokens from L2
'
,
async
()
=>
{
it
(
'
should transfer tokens on L2
'
,
async
()
=>
{
const
tx
=
await
L2__ERC20
.
transfer
(
otherWalletL1
.
address
,
500
)
await
tx
.
wait
()
expect
(
await
L2__ERC20
.
balanceOf
(
env
.
l2Wallet
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
500
)
)
expect
(
await
L2__ERC20
.
balanceOf
(
otherWalletL2
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
500
)
)
})
it
(
'
should withdraw tokens from L2 to the depositor
'
,
async
()
=>
{
const
tx
=
await
env
.
l2Bridge
.
withdraw
(
L2__ERC20
.
address
,
10
00
,
5
00
,
2000000
,
'
0x
'
)
await
env
.
relayXDomainMessages
(
tx
)
await
env
.
waitForXDomainTransaction
(
tx
,
Direction
.
L2ToL1
)
expect
(
await
L1__ERC20
.
balanceOf
(
l1Wallet
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
1000000
)
expect
(
await
L1__ERC20
.
balanceOf
(
env
.
l1Wallet
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
999500
)
)
expect
(
await
L2__ERC20
.
balanceOf
(
env
.
l2Wallet
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
0
)
)
}).
timeout
(
isLiveNetwork
()
?
300
_000
:
120
_000
)
it
(
'
should withdraw tokens from L2 to the transfer recipient
'
,
async
()
=>
{
const
tx
=
await
env
.
l2Bridge
.
connect
(
otherWalletL2
)
.
withdraw
(
L2__ERC20
.
address
,
500
,
2000000
,
'
0x
'
)
await
env
.
relayXDomainMessages
(
tx
)
await
env
.
waitForXDomainTransaction
(
tx
,
Direction
.
L2ToL1
)
expect
(
await
L1__ERC20
.
balanceOf
(
otherWalletL1
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
500
)
)
expect
(
await
L2__ERC20
.
balanceOf
(
l1Wallet
.
address
)).
to
.
deep
.
equal
(
expect
(
await
L2__ERC20
.
balanceOf
(
otherWalletL2
.
address
)).
to
.
deep
.
equal
(
BigNumber
.
from
(
0
)
)
}).
timeout
(
isLiveNetwork
()
?
300
_000
:
120
_000
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment