Skip to content

Commit 76581d6

Browse files
authored
Merge pull request #6 from ianacaburian/develop
Cleaned up import statements. Exposed test seed to env. Updated Readm…
2 parents 5122d44 + 95ac279 commit 76581d6

23 files changed

+30
-22
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/node_modules
2+
.vscode
23

34
# Ignore test-related files
45
/coverage.data

.vscode/settings.json

-5
This file was deleted.

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,16 @@ npm run open:test/console # Open test/console project in Xcode.
106106
npm run install:test/console # Build and install the test/console bins.
107107
```
108108

109-
Optional: Set "FC_NUM_RUMS" (default=1) to specify how many times to run each
110-
(randomly generated) propery-based test -- see
111-
[fast-check](https://github.com/dubzzz/fast-check).
109+
- Optional: Set "FC_NUM_RUMS" (default=1) to specify how many times to run
110+
each (randomly generated) propery-based test -- see
111+
[fast-check](https://github.com/dubzzz/fast-check).
112112

113113
```
114114
FC_NUM_RUNS=1000 npm run test # Run each fc test 1000 times.
115115
```
116+
117+
- Optional: Set "FC_SEED" (default=1) to specify the seed for each fc test.
118+
119+
```
120+
FC_SEED=2 npm run test # Run each fc test with seed=2.
121+
```

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ianacaburian/generate-key-file",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Ports juce_KeyGeneration::generateKeyFile() to node.",
55
"type": "module",
66
"main": "./dist/index.js",

src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
export * from './juce/JuceKeyGeneration'
21
export {
32
type GenerateKeyFileParams,
43
type GenerateExpiringKeyFileParams
54
} from './types'
5+
6+
export { generateKeyFile } from './generateKeyFile'
7+
export { generateExpiringKeyFile } from './generateExpiringKeyFile'

src/juce/JuceKeyGeneration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { JuceKeyFileUtils } from 'src/juce/JuceKeyFileUtils'
21
import { GenerateExpiringKeyFileParams, GenerateKeyFileParams } from 'src/types'
32

43
import { JuceDateString } from './JuceDateString'
4+
import { JuceKeyFileUtils } from './JuceKeyFileUtils'
55
import { JuceRSAKey } from './JuceRSAKey'
66

77
export class JuceKeyGeneration {

src/juce/JuceRSAKey.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// import { BigInteger as JSBN } from 'jsbn'
2-
31
import { JuceBigInteger } from './JuceBigInteger'
42

53
export class JuceRSAKey {

src/test/JuceBigInteger.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import fc from 'fast-check'
22
import { JuceBigInteger } from 'src/juce/JuceBigInteger'
3-
import { execTestBin, hexArbitrary } from 'src/test/test-utils'
43
import { describe, expect, it } from 'vitest'
54

5+
import { execTestBin, hexArbitrary } from './test-utils'
6+
67
describe('JuceBigInteger', () => {
78
it('fromUTF8MemoryBlock', ctx => {
89
console.log(`Testing ${ctx.task.name}...`)

src/test/JuceKeyFileUtils.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import fc from 'fast-check'
22
import { JuceDateString } from 'src/juce/JuceDateString'
33
import { JuceKeyFileUtils } from 'src/juce/JuceKeyFileUtils'
44
import { JuceRSAKey } from 'src/juce/JuceRSAKey'
5-
import { execTestBin, hexArbitrary } from 'src/test/test-utils'
65
import {
76
CreateKeyFileCommentParams,
87
createKeyFileCommentParamsValidator,
@@ -12,6 +11,8 @@ import {
1211
import { describe, expect, it } from 'vitest'
1312
import { ZodFastCheck } from 'zod-fast-check'
1413

14+
import { execTestBin, hexArbitrary } from './test-utils'
15+
1516
describe('JuceKeyFileUtils', () => {
1617
it('createKeyFileContentLine', ctx => {
1718
console.log(`Testing ${ctx.task.name}...`)

src/test/JuceKeyGeneration.test.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import fc from 'fast-check'
22
import { JuceDateString } from 'src/juce/JuceDateString'
33
import { JuceKeyGeneration } from 'src/juce/JuceKeyGeneration'
4-
import { execTestBin } from 'src/test/test-utils'
54
import { describe, expect, it } from 'vitest'
65

6+
import { execTestBin } from './test-utils'
7+
78
describe('JuceKeyGeneration', () => {
89
type TestParams = {
910
userEmail: string
@@ -181,8 +182,8 @@ describe('JuceKeyGeneration', () => {
181182
fc.assert(
182183
fc.property(
183184
fc.record({
184-
userEmail: fc.string({ minLength: 1 }),
185-
userName: fc.string({ minLength: 1 })
185+
userEmail: fc.string({ minLength: 100 }),
186+
userName: fc.string({ minLength: 100 })
186187
}),
187188
input => {
188189
count += 1n

src/test/JuceRSAKey.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import fc from 'fast-check'
22
import { JuceBigInteger } from 'src/juce/JuceBigInteger'
33
import { JuceRSAKey } from 'src/juce/JuceRSAKey'
4-
import { execTestBin, hexArbitrary } from 'src/test/test-utils'
54
import { describe, expect, it } from 'vitest'
65

6+
import { execTestBin, hexArbitrary } from './test-utils'
7+
78
describe('JuceRSAKey', () => {
89
it('applyToValue', ctx => {
910
console.log(`Testing ${ctx.task.name}...`)

src/test/test-utils.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { execSync } from 'child_process'
2-
import crypto from 'crypto'
3-
import os from 'os'
42
import path from 'path'
53
import fc from 'fast-check'
64

test/bin/apply-key-file

0 Bytes
Binary file not shown.

test/bin/apply-to-value

0 Bytes
Binary file not shown.

test/bin/create-key-file

0 Bytes
Binary file not shown.

test/bin/create-key-file-comment

0 Bytes
Binary file not shown.

test/bin/create-key-file-content-line

0 Bytes
Binary file not shown.

test/bin/create-key-pair

0 Bytes
Binary file not shown.

test/bin/divide-by

0 Bytes
Binary file not shown.

test/bin/encrypt-xml-line

0 Bytes
Binary file not shown.

test/bin/exponent-modulo

0 Bytes
Binary file not shown.

test/bin/load-from-memory-block

0 Bytes
Binary file not shown.

vitest.setup.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
import fc from 'fast-check'
22

3-
fc.configureGlobal({ numRuns: process.env.FC_NUM_RUNS || 1, verbose: 1 })
3+
fc.configureGlobal({
4+
verbose: 1,
5+
numRuns: process.env.FC_NUM_RUNS || 1,
6+
seed: process.env.FC_SEED || 1
7+
})

0 commit comments

Comments
 (0)