Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
feat: use @jest/globals
Browse files Browse the repository at this point in the history
  • Loading branch information
sublimator committed Jun 29, 2023
1 parent bcc436b commit c97d3c1
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 19 deletions.
14 changes: 14 additions & 0 deletions addImports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/zsh

# enable globstar
setopt EXTENDED_GLOB
setopt NO_NOMATCH

importLine="import {jest, beforeEach, afterEach, afterAll, expect, test, describe, it, beforeAll} from '@jest/globals';"

for file in packages/niq-privacypass-noble/{src,test}/**/*.test.{mts,ts}; do
if [ -f "$file" ]; then
echo "Processing $file"
printf "%s\n%s" "$importLine" "$(cat $file)" > "$file"
fi
done
3 changes: 0 additions & 3 deletions packages/niq-privacypass-noble/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,5 @@
"dependencies": {
"@noble/curves": "^1.0.0",
"@noble/hashes": "^1.3.0"
},
"devDependencies": {
"@types/jest": "29.5.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { describe, expect, jest, test } from '@jest/globals'

import * as blindRSA from '../../../../src/crypto/blindrsa/blindrsa'

// Test vector
// https://www.ietf.org/archive/id/draft-irtf-cfrg-rsa-blind-signatures-03.html#appendix-A
import { modInv, mod } from '../../../../src/crypto/blindrsa/modular'
import { mod, modInv } from '../../../../src/crypto/blindrsa/modular'

import vectors from './testdata/rsablind_vectors.json'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it, jest } from '@jest/globals'

import { emsa_pss_encode } from '../../../../src/crypto/blindrsa/util'

// Test vector in file pss_test.go from: https://cs.opensource.google/go/go/+/refs/tags/go1.18.2:src/crypto/rsa/pss_test.go
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from '@jest/globals'

import { b64db, b64eb } from '../../../../src/crypto/voprf/b64'

describe('base64 functions', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { describe, expect, it } from '@jest/globals'
import { bytesToHex } from '@noble/hashes/utils'

import { computeComposites } from '../../../../src/crypto/voprf/computeComposites'
import { testConfig, testContext } from '../../testconfig'
import { testContext } from '../../testconfig'

const P = (hex: string) => testContext.decodePoint(hex)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from '@jest/globals'

import { DLEQ } from '../../../../src/crypto/voprf/dleq'
import { testContext } from '../../testconfig'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals'
import { hexToBytes } from '@noble/hashes/utils'

import { hashAndInc } from '../../../../src/crypto/voprf/hashAndInc'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { shake256, Keccak } from '@noble/hashes/sha3'
import { describe, expect, it } from '@jest/globals'
import { Keccak, shake256 } from '@noble/hashes/sha3'
import { p256 } from '@noble/curves/p256'
import { hexToBytes } from '@noble/hashes/utils'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals'
import { randomBytes } from '@noble/hashes/utils'
import { p256 } from '@noble/curves/p256'
import { bytesToNumberBE } from '@noble/curves/abstract/utils'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from '@jest/globals'

import { PrivacyPassRequestSer } from '../../../../src/protocol/types/ser'
import { b64dj, b64ds } from '../../../../src/crypto/voprf/b64'
import { testContext } from '../../testconfig'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from '@jest/globals'

import { IssueResponseInnerSer } from '../../../../src/protocol/types/ser'
import { b64dbn, b64ds } from '../../../../src/crypto/voprf/b64'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it, test } from '@jest/globals'

import { computeSecret, divPoint } from './utils'
import { createBlindToken } from './tokens'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from '@jest/globals'
import { p256 } from '@noble/curves/p256'

const REQUEST = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from '@jest/globals'

import { makeIssueRequest } from '../../../../../src/protocol/issue/client/makeIssueRequest'
import { testContext } from '../../../testconfig'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { describe, expect, it } from '@jest/globals'

import { makeIssueResponse } from '../../../../../src/protocol/issue/server/makeIssueResponse'
import { testContext } from '../../../testconfig'
import { verifyIssueResponse } from '../../../../../src/protocol/issue/client/verifyIssueResponse'
import { parseIssueResponse } from '../../../../../src/protocol/serdes'
import { commitment, issueResponseRaw, issueRequestDes } from '../../fixtures'
import { commitment, issueRequestDes, issueResponseRaw } from '../../fixtures'

describe('makeIssueResponse', () => {
it('should be defined', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from '@jest/globals'

import { makeIssueRequest } from '../../../../../src/protocol/issue/client/makeIssueRequest'
import { testContext } from '../../../testconfig'
import { makeIssueResponse } from '../../../../../src/protocol/issue/server/makeIssueResponse'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { describe, expect, it } from '@jest/globals'

import { makeRedeemRequest } from '../../../../../src/protocol/redeem/client/makeRedeemRequest'
import { SignedToken } from '../../../../../src/crypto/voprf/types'
import { testContext } from '../../../testconfig'
import { IssueResponseInnerSer } from '../../../../../src/protocol/types/ser'
import { b64dj } from '../../../../../src/crypto/voprf/b64'
import { wrapAndSerializeRequest } from '../../../../../src/protocol/serdes'
import { issueResponseRaw, issueRequestUntyped } from '../../fixtures'
import { issueRequestUntyped, issueResponseRaw } from '../../fixtures'

describe('makeRedeemRequest', () => {
it('should be possible to create a request to redeem a token', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from '@jest/globals'

import { testContext } from '../../../testconfig'
import { commitment, serverKey, wrappedRedeemRequest } from '../../fixtures'
import { verifyRedeemRequest } from '../../../../../src/protocol/redeem/server/verifyRedeemRequest'
Expand Down
11 changes: 0 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c97d3c1

Please sign in to comment.