mirror of
https://github.com/erhant/circomkit.git
synced 2026-01-13 22:47:54 -05:00
* migrate tests under their own folder * more refactors + `pkgroll` added * todo commander * migrate CLI to `commander` * fixed proof tester types * added `list` command * use jest, use pnpm, more refactors & renames & typings * remove redundant hardhats, better jest * up version
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import {Circomkit, WitnessTester} from '../src';
|
|
|
|
describe('errors', () => {
|
|
let circuit: WitnessTester<['in', 'inin'], ['out']>;
|
|
|
|
beforeAll(async () => {
|
|
const circomkit = new Circomkit({
|
|
verbose: false,
|
|
logLevel: 'silent',
|
|
circuits: './tests/circuits.json',
|
|
dirPtau: './tests/ptau',
|
|
dirCircuits: './tests/circuits',
|
|
dirInputs: './tests/inputs',
|
|
dirBuild: './tests/build',
|
|
});
|
|
circuit = await circomkit.WitnessTester('error_rt', {file: 'errors', template: 'Errors'});
|
|
});
|
|
|
|
it('should fail for fewer inputs than expected', async () => {
|
|
await circuit.expectFail({in: 0, inin: [1]});
|
|
// Not enough values for input signal inin
|
|
});
|
|
|
|
it('should fail for more inputs than expected', async () => {
|
|
await circuit.expectFail({in: 0, inin: [1, 2, 3]});
|
|
// Too many values for input signal inin
|
|
});
|
|
|
|
it('should fail due to false-assert', async () => {
|
|
await circuit.expectFail({in: 1, inin: [1, 2]});
|
|
// Error: Assert Failed.
|
|
});
|
|
|
|
it('should fail due to missing signal', async () => {
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-expect-error
|
|
await circuit.expectFail({inin: [1, 2]});
|
|
// Not all inputs have been set. Only 2 out of 3.
|
|
});
|
|
|
|
it('should fail due to extra signal', async () => {
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-expect-error
|
|
await circuit.expectFail({inin: [1, 2, 3], idontexist: 1});
|
|
// Too many values for input signal inin
|
|
});
|
|
});
|