Skip to content

Commit

Permalink
Merge pull request #131 from ChALkeR/chalker/test/webcrypto/0
Browse files Browse the repository at this point in the history
test: clean up test:webcrypto logic
  • Loading branch information
paulmillr authored Nov 12, 2024
2 parents c03833e + 54bfca0 commit 5ec4dc3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build:mingz": "npm run --silent build:min | gzip -c8",
"build:release": "npm run --silent build:min > test/build/noble-secp256k1.min.js; npm run --silent build:mingz > test/build/noble-secp256k1.min.js.gz",
"test": "node test/index.js",
"test:webcrypto": "node test/secp256k1.webcrypto.test.js",
"test:webcrypto": "node test/index.webcrypto.js",
"bench": "node test/benchmark.js",
"loc": "echo \"`npm run --silent build:min | wc -c` symbols `wc -l < index.ts` LOC, `npm run --silent build:mingz | wc -c`B gzipped\""
},
Expand Down
10 changes: 7 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { should } from 'micro-should';
import * as t1 from './basic.test.js';
import * as t2 from './secp256k1.test.js';
import './basic.test.js';
import './secp256k1.test.js';

should.run();
if (!globalThis.crypto) {
console.error('global crypto not found (old Node.js?), perhaps you meant to run test:webcrypto');
}

should.run();
10 changes: 5 additions & 5 deletions test/secp256k1.webcrypto.test.js → test/index.webcrypto.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { should } from 'micro-should';
import './basic.test.js';
import './secp256k1.test.js';

// A copy of index.js with polyfilled globalThis.crypto to run on Node.js 18
import { webcrypto } from 'node:crypto';
// @ts-ignore
if (!globalThis.crypto) globalThis.crypto = webcrypto;

import './secp256k1.test.js';

// Force ESM import to execute
import { should } from 'micro-should';
should.run();

0 comments on commit 5ec4dc3

Please sign in to comment.