Commit adfa5f56 authored by Kelvin Fichter's avatar Kelvin Fichter

maint(core): clean up test folder structure

Small PR to clean up the folder structure for the tests for core-utils
so that the folders follow the source folders and file names. Planning
to make some improvements to these tests, this is a first simple PR that
will help me do that.
parent f77b7a9b
......@@ -15,8 +15,8 @@
"lint:check": "eslint . --max-warnings=0",
"lint:fix": "yarn lint:check --fix",
"pre-commit": "lint-staged",
"test": "ts-mocha test/*.spec.ts",
"test:coverage": "nyc ts-mocha test/*.spec.ts && nyc merge .nyc_output coverage.json"
"test": "ts-mocha test/**/*.spec.ts",
"test:coverage": "nyc ts-mocha test/**/*.spec.ts && nyc merge .nyc_output coverage.json"
},
"keywords": [
"optimism",
......
import { BigNumber } from '@ethersproject/bignumber'
/* Imports: Internal */
import { expect } from './setup'
import { expect } from '../setup'
import {
toRpcHexString,
remove0x,
......@@ -12,7 +12,7 @@ import {
encodeHex,
hexStringEquals,
bytes32ify,
} from '../src'
} from '../../src'
describe('remove0x', () => {
it('should return undefined', () => {
......@@ -62,6 +62,7 @@ describe('toHexString', () => {
'The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received null'
)
})
it('should return with a hex string', () => {
const cases = [
{ input: 0, output: '0x00' },
......@@ -104,6 +105,7 @@ describe('padHexString', () => {
expect(padHexString('abcd', 1)).to.deep.equal('abcd')
expect(padHexString('abcdefgh', 3).length).to.deep.equal(8)
})
it('should return a string padded with 0x and zeros', () => {
expect(padHexString('0xabcd', 3)).to.deep.equal('0x00abcd')
})
......
/* Imports: Internal */
import { expect } from './setup'
import { sleep, clone, reqenv, getenv } from '../src'
import { expect } from '../setup'
import { sleep, clone, reqenv, getenv } from '../../src'
describe('sleep', async () => {
it('should return wait input amount of ms', async () => {
......@@ -21,7 +21,7 @@ describe('clone', async () => {
})
describe('reqenv', async () => {
let cachedEnvironment
let cachedEnvironment: NodeJS.ProcessEnv
const temporaryEnvironmentKey = 'testVariable'
const temporaryEnvironment = {
[temporaryEnvironmentKey]: 'This is an environment variable',
......@@ -51,7 +51,7 @@ describe('reqenv', async () => {
})
describe('getenv', async () => {
let cachedEnvironment
let cachedEnvironment: NodeJS.ProcessEnv
const temporaryEnvironmentKey = 'testVariable'
const temporaryEnvironment = {
[temporaryEnvironmentKey]: 'This is an environment variable',
......
import { assert } from 'chai'
/* Imports: Internal */
import { expect } from './setup'
import { expectApprox, awaitCondition } from '../src'
import { expect } from '../setup'
import { expectApprox, awaitCondition } from '../../src'
describe('awaitCondition', () => {
it('should try the condition fn until it returns true', async () => {
......@@ -42,6 +42,7 @@ describe('expectApprox', () => {
absoluteLowerDeviation: 20,
})
})
it('should pass when the actual number is lower, but within the expected range of the target', async () => {
expectApprox(81, 100, {
percentUpperDeviation: 20,
......@@ -50,6 +51,7 @@ describe('expectApprox', () => {
absoluteLowerDeviation: 20,
})
})
it('should throw an error when no deviation values are given', async () => {
try {
expectApprox(101, 100, {})
......@@ -75,6 +77,7 @@ describe('expectApprox', () => {
)
}
})
it('... and absoluteUpperDeviation sets the upper bound', async () => {
try {
expectApprox(121, 100, {
......@@ -88,6 +91,7 @@ describe('expectApprox', () => {
}
})
})
describe('... when both values are defined', () => {
it('... and percentUpperDeviation sets the upper bound', async () => {
try {
......@@ -102,6 +106,7 @@ describe('expectApprox', () => {
)
}
})
it('... and absoluteUpperDeviation sets the upper bound', async () => {
try {
expectApprox(121, 100, {
......
import { expect } from './setup'
import { applyL1ToL2Alias, undoL1ToL2Alias } from '../src'
import { expect } from '../setup'
import { applyL1ToL2Alias, undoL1ToL2Alias } from '../../src'
describe('address aliasing utils', () => {
describe('applyL1ToL2Alias', () => {
......
import './setup'
import '../setup'
/* Internal Imports */
import { expect } from 'chai'
......@@ -9,13 +9,13 @@ import {
sequencerBatch,
BatchType,
SequencerBatch,
} from '../src'
} from '../../src'
describe('BatchEncoder', function () {
this.timeout(10_000)
// eslint-disable-next-line @typescript-eslint/no-var-requires
const data = require('./fixtures/calldata.json')
const data = require('../fixtures/calldata.json')
describe('appendSequencerBatch', () => {
it('legacy: should work with the simple case', () => {
......@@ -112,6 +112,7 @@ describe('BatchEncoder', function () {
],
transactions: ['0x454234000000112', '0x45423400000012'],
}
expect(() => encodeAppendSequencerBatch(batch)).to.throw(
'Unexpected uneven hex string value!'
)
......
import './setup'
import '../setup'
import { BigNumber } from '@ethersproject/bignumber'
import { zeroesAndOnes, calldataCost } from '../src'
import { zeroesAndOnes, calldataCost } from '../../src'
describe('Fees', () => {
it('should count zeros and ones', () => {
......
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