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 085982a commit b0b4a95
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 ed25519 from '../index.js';
import * as h from './ed25519.helpers.js';

const CURVES = { ed25519 }
const CURVES = { ed25519 };
const name = 'ed25519';
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/ed25519.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deepStrictEqual, strictEqual, throws } from 'assert';
import { readFileSync } from 'fs';
import { deepStrictEqual, strictEqual, throws } from 'node:assert';
import { readFileSync } from 'node:fs';
import { bytesToHex, concatBytes, hexToBytes, utf8ToBytes, randomBytes } from '@noble/hashes/utils';
import * as fc from 'fast-check';
import { describe, should } from 'micro-should';
Expand Down Expand Up @@ -452,7 +452,7 @@ describe('ed25519', () => {
});

// 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 b0b4a95

Please sign in to comment.