Commit b4dcfdf3 authored by smartcontracts's avatar smartcontracts Committed by GitHub

maint(ct): clean up L2StdTokenFac tests (#2492)

Cleans up the L2StandardTokenFactory tests using the same technique as
previous cleanup PRs.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 75c5f54d
/* External Imports */
import { ethers } from 'hardhat' import { ethers } from 'hardhat'
import { Signer, ContractFactory, Contract } from 'ethers' import { ContractFactory, Contract } from 'ethers'
import { import {
smock, smock,
MockContractFactory, MockContractFactory,
MockContract, MockContract,
} from '@defi-wonderland/smock' } from '@defi-wonderland/smock'
/* Internal Imports */
import { expect } from '../../../setup' import { expect } from '../../../setup'
import { predeploys, getContractInterface } from '../../../../src' import { deploy } from '../../../helpers'
import { predeploys } from '../../../../src'
describe('L2StandardTokenFactory', () => { describe('L2StandardTokenFactory', () => {
let signer: Signer
let Factory__L1ERC20: MockContractFactory<ContractFactory> let Factory__L1ERC20: MockContractFactory<ContractFactory>
let L1ERC20: MockContract<Contract> let L1ERC20: MockContract<Contract>
let L2StandardTokenFactory: Contract let L2StandardTokenFactory: Contract
before(async () => { before(async () => {
;[signer] = await ethers.getSigners() Factory__L1ERC20 = await smock.mock('ERC20')
// deploy an ERC20 contract on L1
Factory__L1ERC20 = await smock.mock(
'@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20'
)
L1ERC20 = await Factory__L1ERC20.deploy('L1ERC20', 'ERC') L1ERC20 = await Factory__L1ERC20.deploy('L1ERC20', 'ERC')
L2StandardTokenFactory = await deploy('L2StandardTokenFactory')
L2StandardTokenFactory = await (
await ethers.getContractFactory('L2StandardTokenFactory')
).deploy()
}) })
describe('Standard token factory', () => { describe('Standard token factory', () => {
...@@ -36,18 +27,18 @@ describe('L2StandardTokenFactory', () => { ...@@ -36,18 +27,18 @@ describe('L2StandardTokenFactory', () => {
'L2ERC20', 'L2ERC20',
'ERC' 'ERC'
) )
// Pull the token creation event from the receipt
const receipt = await tx.wait() const receipt = await tx.wait()
const [tokenCreatedEvent] = receipt.events const tokenCreatedEvent = receipt.events[0]
// Expect there to be an event emmited for the standard token creation // Expect there to be an event emitted for the standard token creation
expect(tokenCreatedEvent.event).to.be.eq('StandardL2TokenCreated') expect(tokenCreatedEvent.event).to.be.eq('StandardL2TokenCreated')
// Get the L2 token address from the emmited event and check it was created correctly // Get the L2 token address from the emitted event and check it was created correctly
const l2TokenAddress = tokenCreatedEvent.args._l2Token const l2Token = await ethers.getContractAt(
const l2Token = new Contract( 'L2StandardERC20',
l2TokenAddress, tokenCreatedEvent.args._l2Token
getContractInterface('L2StandardERC20'),
signer
) )
expect(await l2Token.l2Bridge()).to.equal(predeploys.L2StandardBridge) expect(await l2Token.l2Bridge()).to.equal(predeploys.L2StandardBridge)
......
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