-
Notifications
You must be signed in to change notification settings - Fork 389
fix: lack of cjs package version #2848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e2e1914
fix: lack of cjs package version
kobyhallx 35eca84
chore: adds `tsc-multi` to lock
kobyhallx 75e1b3c
Update tooling/noir_js/test/node/cjs.test.cjs
kobyhallx 85e8666
fix: appropriate test script
kobyhallx 566096c
Merge branch 'kh-expose-noirjs-cjs' of github.com:noir-lang/noir into…
kobyhallx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "extensions": ["cjs"], | ||
| "spec": [ | ||
| "test/node/**/*.test.cjs" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* eslint-disable no-undef */ | ||
| /* eslint-disable @typescript-eslint/no-var-requires */ | ||
| const chai = require('chai'); | ||
| const assert_lt_json = require('../noir_compiled_examples/assert_lt/target/assert_lt.json'); | ||
| const noirjs = require('@noir-lang/noir_js'); | ||
|
|
||
| it('001 generates witnesses successfully', async () => { | ||
|
kobyhallx marked this conversation as resolved.
Outdated
|
||
| const inputs = { | ||
| x: '2', | ||
| y: '3', | ||
| }; | ||
| const _solvedWitness = await noirjs.generateWitness(assert_lt_json, inputs); | ||
| }); | ||
|
|
||
| it('string input and number input are the same', async () => { | ||
| const inputsString = { | ||
| x: '2', | ||
| y: '3', | ||
| }; | ||
| const inputsNumber = { | ||
| x: 2, | ||
| y: 3, | ||
| }; | ||
| const solvedWitnessString = await noirjs.generateWitness(assert_lt_json, inputsString); | ||
| const solvedWitnessNumber = await noirjs.generateWitness(assert_lt_json, inputsNumber); | ||
| chai.expect(solvedWitnessString).to.deep.equal(solvedWitnessNumber); | ||
| }); | ||
|
|
||
| it('string input and number input are the same', async () => { | ||
| const inputsString = { | ||
| x: '2', | ||
| y: '3', | ||
| }; | ||
| const inputsNumber = { | ||
| x: 2, | ||
| y: 3, | ||
| }; | ||
|
|
||
| const solvedWitnessString = await noirjs.generateWitness(assert_lt_json, inputsString); | ||
| const solvedWitnessNumber = await noirjs.generateWitness(assert_lt_json, inputsNumber); | ||
| chai.expect(solvedWitnessString).to.deep.equal(solvedWitnessNumber); | ||
| }); | ||
|
|
||
| it('0x prefixed string input for inputs will throw', async () => { | ||
| const inputsHexPrefix = { | ||
| x: '0x2', | ||
| y: '0x3', | ||
| }; | ||
|
|
||
| try { | ||
| await noirjs.generateWitness(assert_lt_json, inputsHexPrefix); | ||
| chai.expect.fail( | ||
| 'Expected generatedWitness to throw, due to inputs being prefixed with 0x. Currently not supported', | ||
| ); | ||
| } catch (error) { | ||
| // Successfully errored due to 0x not being supported. Update this test once/if we choose | ||
| // to support 0x prefixed inputs. | ||
| } | ||
| }); | ||
|
|
||
| describe('input validation', () => { | ||
| it('x should be a uint64 not a string', async () => { | ||
| const inputs = { | ||
| x: 'foo', | ||
| y: '3', | ||
| }; | ||
|
|
||
| try { | ||
| await noirjs.generateWitness(assert_lt_json, inputs); | ||
| chai.expect.fail('Expected generatedWitness to throw, due to x not being convertible to a uint64'); | ||
| } catch (error) { | ||
| const knownError = error; | ||
| chai.expect(knownError.message).to.equal('Input for x is the wrong type, expected uint64, got "foo"'); | ||
| } | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "targets": [ | ||
| { "extname": ".cjs", "module": "commonjs" }, | ||
| { "extname": ".mjs", "module": "esnext" } | ||
| ], | ||
| "projects": ["packages/*/tsconfig.json"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.