Commit 9d108959 authored by Wyatt Barnes's avatar Wyatt Barnes

Replace use of typeof/toBe with toBeTypeOf

parent c0be176b
...@@ -11,8 +11,15 @@ import { ...@@ -11,8 +11,15 @@ import {
import { OptimismFeeEstimationPlugin } from './plugin' import { OptimismFeeEstimationPlugin } from './plugin'
const defaultProvider = 'https://mainnet.optimism.io' const defaultProvider = 'https://mainnet.optimism.io'
const provider = z.string().url().default(defaultProvider).parse(process.env['VITE_L2_RPC_URL']) const provider = z
if (provider === defaultProvider) console.warn('Warning: Using default public provider, this could cause tests to fail due to rate limits. Set the VITE_L2_RPC_URL env to override default provider') .string()
.url()
.default(defaultProvider)
.parse(process.env['VITE_L2_RPC_URL'])
if (provider === defaultProvider)
console.warn(
'Warning: Using default public provider, this could cause tests to fail due to rate limits. Set the VITE_L2_RPC_URL env to override default provider'
)
describe('OptimismFeeEstimationPlugin', () => { describe('OptimismFeeEstimationPlugin', () => {
let web3: Web3 let web3: Web3
...@@ -125,16 +132,16 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -125,16 +132,16 @@ describe('OptimismFeeEstimationPlugin', () => {
describe('should return a bigint by default', () => { describe('should return a bigint by default', () => {
test('getBaseFee', async () => test('getBaseFee', async () =>
expect(typeof (await web3.op.getBaseFee())).toBe('bigint')) expect(await web3.op.getBaseFee()).toBeTypeOf('bigint'))
test('getDecimals should return 6n', async () => test('getDecimals should return 6n', async () =>
expect(await web3.op.getDecimals()).toBe(BigInt(6))) expect(await web3.op.getDecimals()).toBe(BigInt(6)))
test('getGasPrice', async () => test('getGasPrice', async () =>
expect(typeof (await web3.op.getGasPrice())).toBe('bigint')) expect(await web3.op.getGasPrice()).toBeTypeOf('bigint'))
test('getL1BaseFee', async () => test('getL1BaseFee', async () =>
expect(typeof (await web3.op.getL1BaseFee())).toBe('bigint')) expect(await web3.op.getL1BaseFee()).toBeTypeOf('bigint'))
test('getOverhead should return 188n', async () => test('getOverhead should return 188n', async () =>
expect(await web3.op.getOverhead()).toBe(BigInt(188))) expect(await web3.op.getOverhead()).toBe(BigInt(188)))
...@@ -147,16 +154,16 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -147,16 +154,16 @@ describe('OptimismFeeEstimationPlugin', () => {
const numberFormat = { number: FMT_NUMBER.NUMBER, bytes: FMT_BYTES.HEX } const numberFormat = { number: FMT_NUMBER.NUMBER, bytes: FMT_BYTES.HEX }
test('getBaseFee', async () => test('getBaseFee', async () =>
expect(typeof (await web3.op.getBaseFee(numberFormat))).toBe('number')) expect(await web3.op.getBaseFee(numberFormat)).toBeTypeOf('number'))
test('getDecimals should return 6', async () => test('getDecimals should return 6', async () =>
expect(await web3.op.getDecimals(numberFormat)).toBe(6)) expect(await web3.op.getDecimals(numberFormat)).toBe(6))
test('getGasPrice', async () => test('getGasPrice', async () =>
expect(typeof (await web3.op.getGasPrice(numberFormat))).toBe('number')) expect(await web3.op.getGasPrice(numberFormat)).toBeTypeOf('number'))
test('getL1BaseFee', async () => test('getL1BaseFee', async () =>
expect(typeof (await web3.op.getL1BaseFee(numberFormat))).toBe('number')) expect(await web3.op.getL1BaseFee(numberFormat)).toBeTypeOf('number'))
test('getOverhead should return 188', async () => test('getOverhead should return 188', async () =>
expect(await web3.op.getOverhead(numberFormat)).toBe(188)) expect(await web3.op.getOverhead(numberFormat)).toBe(188))
...@@ -182,11 +189,11 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -182,11 +189,11 @@ describe('OptimismFeeEstimationPlugin', () => {
describe('should return a bigint by default', () => { describe('should return a bigint by default', () => {
test('getL1Fee', async () => { test('getL1Fee', async () => {
expect( expect(
typeof (await web3.op.getL1Fee({ await web3.op.getL1Fee({
chainId: '0xa', chainId: '0xa',
data: encodedBurnMethod, data: encodedBurnMethod,
type: '0x2', type: '0x2',
})) })
).toBe('bigint') ).toBe('bigint')
}) })
...@@ -201,30 +208,30 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -201,30 +208,30 @@ describe('OptimismFeeEstimationPlugin', () => {
test('estimateFees', async () => test('estimateFees', async () =>
expect( expect(
typeof (await web3.op.estimateFees({ await web3.op.estimateFees({
chainId: 10, chainId: 10,
data: encodedBurnMethod, data: encodedBurnMethod,
type: 2, type: 2,
to: optimistAddress[10], to: optimistAddress[10],
from: '0x77194aa25a06f932c10c0f25090f3046af2c85a6', from: '0x77194aa25a06f932c10c0f25090f3046af2c85a6',
})) })
).toBe('bigint')) ).toBeTypeOf('bigint'))
test('getL2Fee', async () => { test('getL2Fee', async () => {
expect( expect(
typeof (await web3.op.getL2Fee({ await web3.op.getL2Fee({
chainId: '0xa', chainId: '0xa',
data: encodedBurnMethod, data: encodedBurnMethod,
type: '0x2', type: '0x2',
to: optimistAddress[10], to: optimistAddress[10],
from: '0x77194aa25a06f932c10c0f25090f3046af2c85a6', from: '0x77194aa25a06f932c10c0f25090f3046af2c85a6',
})) })
).toBe('bigint') ).toBeTypeOf('bigint')
}) })
test('estimateFees', async () => test('estimateFees', async () =>
expect( expect(
typeof (await web3.op.estimateFees( await web3.op.estimateFees(
{ {
chainId: 10, chainId: 10,
data: encodedBurnMethod, data: encodedBurnMethod,
...@@ -233,8 +240,8 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -233,8 +240,8 @@ describe('OptimismFeeEstimationPlugin', () => {
from: '0x77194aa25a06f932c10c0f25090f3046af2c85a6', from: '0x77194aa25a06f932c10c0f25090f3046af2c85a6',
}, },
{ blockNumber: 107028270 } { blockNumber: 107028270 }
)) )
).toBe('bigint')) ).toBeTypeOf('bigint'))
}) })
describe('should return a hexString', () => { describe('should return a hexString', () => {
...@@ -242,15 +249,15 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -242,15 +249,15 @@ describe('OptimismFeeEstimationPlugin', () => {
test('getL1Fee', async () => { test('getL1Fee', async () => {
expect( expect(
typeof (await web3.op.getL1Fee( await web3.op.getL1Fee(
{ {
chainId: '0xa', chainId: '0xa',
data: encodedBurnMethod, data: encodedBurnMethod,
type: '0x2', type: '0x2',
}, },
hexStringFormat hexStringFormat
)) )
).toBe('string') ).toBeTypeOf('string')
}) })
test('getL1GasUsed should return 0x75c', async () => test('getL1GasUsed should return 0x75c', async () =>
...@@ -267,7 +274,7 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -267,7 +274,7 @@ describe('OptimismFeeEstimationPlugin', () => {
test('estimateFees', async () => test('estimateFees', async () =>
expect( expect(
typeof (await web3.op.estimateFees( await web3.op.estimateFees(
{ {
chainId: 10, chainId: 10,
data: encodedBurnMethod, data: encodedBurnMethod,
...@@ -276,8 +283,8 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -276,8 +283,8 @@ describe('OptimismFeeEstimationPlugin', () => {
from: '0x77194aa25a06f932c10c0f25090f3046af2c85a6', from: '0x77194aa25a06f932c10c0f25090f3046af2c85a6',
}, },
{ returnFormat: hexStringFormat } { returnFormat: hexStringFormat }
)) )
).toBe('string')) ).toBeTypeOf('string'))
}) })
}) })
...@@ -307,12 +314,12 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -307,12 +314,12 @@ describe('OptimismFeeEstimationPlugin', () => {
describe('should return a bigint by default', () => { describe('should return a bigint by default', () => {
test('getL1Fee', async () => { test('getL1Fee', async () => {
expect( expect(
typeof (await web3.op.getL1Fee({ await web3.op.getL1Fee({
chainId: '0xa', chainId: '0xa',
data: encodedWithdrawMethod, data: encodedWithdrawMethod,
type: '0x2', type: '0x2',
})) })
).toBe('bigint') ).toBeTypeOf('bigint')
}) })
test('getL1GasUsed should return 2592n', async () => test('getL1GasUsed should return 2592n', async () =>
...@@ -326,7 +333,7 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -326,7 +333,7 @@ describe('OptimismFeeEstimationPlugin', () => {
test('estimateFees', async () => test('estimateFees', async () =>
expect( expect(
typeof (await web3.op.estimateFees({ await web3.op.estimateFees({
chainId: 10, chainId: 10,
data: encodedWithdrawMethod, data: encodedWithdrawMethod,
value: Web3.utils.toWei('0.00000001', 'ether'), value: Web3.utils.toWei('0.00000001', 'ether'),
...@@ -335,8 +342,8 @@ describe('OptimismFeeEstimationPlugin', () => { ...@@ -335,8 +342,8 @@ describe('OptimismFeeEstimationPlugin', () => {
from: '0x6387a88a199120aD52Dd9742C7430847d3cB2CD4', from: '0x6387a88a199120aD52Dd9742C7430847d3cB2CD4',
maxFeePerGas: Web3.utils.toWei('0.2', 'gwei'), maxFeePerGas: Web3.utils.toWei('0.2', 'gwei'),
maxPriorityFeePerGas: Web3.utils.toWei('0.1', 'gwei'), maxPriorityFeePerGas: Web3.utils.toWei('0.1', 'gwei'),
})) })
).toBe('bigint')) ).toBeTypeOf('bigint'))
}) })
}) })
}) })
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