Skip to content

Commit

Permalink
test: prefix imports of built-in modules
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed May 18, 2024
1 parent 6db9d7c commit 5249db1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
15 changes: 4 additions & 11 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fc from 'fast-check';
import * as secp256k1 from '../index.js';
import * as h from './secp256k1.helpers.js';

const CURVES = { secp256k1 }
const CURVES = { secp256k1 };
const name = 'secp256k1';
const C = CURVES[name];
const CURVE_ORDER = C.CURVE.n;
Expand Down Expand Up @@ -136,10 +136,7 @@ for (const pointName in POINTS) {
throws(() => G[1][op]('1'), "'1'");
throws(() => G[1][op]({ x: 1n, y: 1n }), '{ x: 1n, y: 1n }');
throws(() => G[1][op]({ x: 1n, y: 1n, z: 1n }), '{ x: 1n, y: 1n, z: 1n }');
throws(
() => G[1][op]({ x: 1n, y: 1n, z: 1n, t: 1n }),
'{ x: 1n, y: 1n, z: 1n, t: 1n }'
);
throws(() => G[1][op]({ x: 1n, y: 1n, z: 1n, t: 1n }), '{ x: 1n, y: 1n, z: 1n, t: 1n }');
throws(() => G[1][op](new Uint8Array([])), 'ui8a([])');
throws(() => G[1][op](new Uint8Array([0])), 'ui8a([0])');
throws(() => G[1][op](new Uint8Array([1])), 'ui8a([1])');
Expand Down Expand Up @@ -264,11 +261,7 @@ describe(name, () => {
const pub = C.getPublicKey(priv);
const sig = C.sign(msg, priv);
const err = `priv=${toHex(priv)},pub=${toHex(pub)},msg=${msg}`;
deepStrictEqual(
C.verify(sig, msg, pub),
true,
err
);
deepStrictEqual(C.verify(sig, msg, pub), true, err);
}),
{ numRuns: NUM_RUNS }
)
Expand Down Expand Up @@ -399,7 +392,7 @@ describe(name, () => {
});

// ESM is broken.
import url from 'url';
import url from 'node:url';
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
should.run();
}
6 changes: 3 additions & 3 deletions test/secp256k1.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { hexToBytes, bytesToHex as hex } from '@noble/hashes/utils';
import { deepStrictEqual, throws } from 'assert';
import { deepStrictEqual, throws } from 'node:assert';
import * as fc from 'fast-check';
import { readFileSync } from 'fs';
import { readFileSync } from 'node:fs';
import { should, describe } from 'micro-should';
// prettier-ignore
import {
Expand Down Expand Up @@ -543,7 +543,7 @@ describe('secp256k1', () => {
});

// ESM is broken.
import url from 'url';
import url from 'node:url';
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
should.run();
}

0 comments on commit 5249db1

Please sign in to comment.