-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
933a23f
commit a156362
Showing
3 changed files
with
66 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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,56 @@ | ||
import { wasm as wasm_tester } from "circom_tester"; | ||
import path from "path"; | ||
|
||
describe("RemoveSoftLineBreaks", () => { | ||
let circuit: any; | ||
|
||
beforeAll(async () => { | ||
circuit = await wasm_tester( | ||
path.join( | ||
__dirname, | ||
"./test-circuits/remove-soft-line-breaks-test.circom" | ||
), | ||
{ | ||
recompile: true, | ||
include: path.join(__dirname, "../../../node_modules"), | ||
output: path.join(__dirname, "./compiled-test-circuits"), | ||
} | ||
); | ||
}); | ||
|
||
it("should correctly remove soft line breaks", async () => { | ||
const input = { | ||
encoded: [ | ||
115, 101, 115, 58, 61, 13, 10, 45, 32, 83, 114, 101, 97, 107, | ||
61, 13, 10, | ||
], | ||
decoded: [115, 101, 115, 58, 45, 32, 83, 114, 101, 97, 107], | ||
r: 69, | ||
}; | ||
|
||
const witness = await circuit.calculateWitness(input); | ||
await circuit.checkConstraints(witness); | ||
|
||
await circuit.assertOut(witness, { | ||
is_valid: 1, | ||
}); | ||
}); | ||
|
||
it("should fail when decoded input is incorrect", async () => { | ||
const input = { | ||
encoded: [ | ||
115, 101, 115, 58, 61, 13, 10, 45, 32, 83, 114, 101, 97, 107, | ||
61, 13, 10, | ||
], | ||
decoded: [115, 101, 115, 58, 45, 32, 83, 114, 101, 97, 108], // Changed last character | ||
r: 69, | ||
}; | ||
|
||
const witness = await circuit.calculateWitness(input); | ||
await circuit.checkConstraints(witness); | ||
|
||
await circuit.assertOut(witness, { | ||
is_valid: 0, | ||
}); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/circuits/tests/test-circuits/remove-soft-line-breaks-test.circom
This file contains 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,5 @@ | ||
pragma circom 2.1.6; | ||
|
||
include "../../helpers/remove-soft-line-breaks.circom"; | ||
|
||
component main = RemoveSoftLineBreaks(17, 11); |