Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* External Imports */
import { ethers } from 'hardhat'
import { Contract, BigNumber } from 'ethers'
import { Contract } from 'ethers'

import { expect } from '../../setup'

const bigNumberify = (arr: any[]) => {
return arr.map((el: any) => {
if (typeof el === 'number') {
return BigNumber.from(el)
return ethers.BigNumber.from(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')) {
return BigNumber.from(el.toLowerCase())
return ethers.BigNumber.from(el.toLowerCase())
} else if (Array.isArray(el)) {
return bigNumberify(el)
} else {
Expand All @@ -34,9 +34,10 @@ export const runJsonTest = (contractName: string, json: any): void => {
await expect(contract.functions[functionName](...test.in)).to.be
.reverted
} else {
expect(
bigNumberify(await contract.functions[functionName](...test.in))
).to.deep.equal(bigNumberify(test.out))
const result = await contract.functions[functionName](...test.in)
expect(JSON.stringify(bigNumberify(result))).to.deep.equal(
JSON.stringify(bigNumberify(test.out))
)
}
})
}
Expand Down