Commit 680118f7 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #2727 from ethereum-optimism/fix/broken-contracts-tests

contracts: fix broken contracts tests
parents 6fe58eb2 34f9be41
/* External Imports */ /* External Imports */
import { ethers } from 'hardhat' import { ethers } from 'hardhat'
import { Contract, BigNumber } from 'ethers' import { Contract } from 'ethers'
import { expect } from '../../setup' import { expect } from '../../setup'
const bigNumberify = (arr: any[]) => { const bigNumberify = (arr: any[]) => {
return arr.map((el: any) => { return arr.map((el: any) => {
if (typeof el === 'number') { if (typeof el === 'number') {
return BigNumber.from(el) return ethers.BigNumber.from(el)
} else if (typeof el === 'string' && /^\d+n$/gm.test(el)) { } else if (typeof el === 'string' && /^\d+n$/gm.test(el)) {
return BigNumber.from(el.slice(0, el.length - 1)) return ethers.BigNumber.from(el.slice(0, el.length - 1))
} else if (typeof el === 'string' && el.length > 2 && el.startsWith('0x')) { } else if (typeof el === 'string' && el.length > 2 && el.startsWith('0x')) {
return BigNumber.from(el.toLowerCase()) return ethers.BigNumber.from(el.toLowerCase())
} else if (Array.isArray(el)) { } else if (Array.isArray(el)) {
return bigNumberify(el) return bigNumberify(el)
} else { } else {
...@@ -34,9 +34,10 @@ export const runJsonTest = (contractName: string, json: any): void => { ...@@ -34,9 +34,10 @@ export const runJsonTest = (contractName: string, json: any): void => {
await expect(contract.functions[functionName](...test.in)).to.be await expect(contract.functions[functionName](...test.in)).to.be
.reverted .reverted
} else { } else {
expect( const result = await contract.functions[functionName](...test.in)
bigNumberify(await contract.functions[functionName](...test.in)) expect(JSON.stringify(bigNumberify(result))).to.deep.equal(
).to.deep.equal(bigNumberify(test.out)) JSON.stringify(bigNumberify(test.out))
)
} }
}) })
} }
......
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