From 393123a61fcb5e421dcbd91e8a11b991ffb4165c Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 26 Mar 2024 14:37:26 +0100 Subject: [PATCH] tests into tests --- src/lib/provable/gadgets/foreign-field.ts | 2 +- src/lib/provable/packed.ts | 2 +- .../provable/{gadgets => test}/arithmetic.unit-test.ts | 4 ++-- src/lib/provable/{gadgets => test}/bitwise.unit-test.ts | 2 +- src/lib/provable/{gadgets => test}/ecdsa.unit-test.ts | 8 ++++---- .../{gadgets => test}/elliptic-curve.unit-test.ts | 8 ++++++-- .../foreign-field-gadgets.unit-test.ts} | 6 +++--- src/lib/provable/test/keccak.unit-test.ts | 2 +- .../provable/{gadgets => test}/range-check.unit-test.ts | 6 +++--- src/lib/provable/{gadgets => test}/sha256.unit-test.ts | 2 +- src/lib/provable/{gadgets => test}/test-utils.ts | 4 ++-- src/lib/provable/{ => types}/fields.ts | 4 ++-- 12 files changed, 27 insertions(+), 23 deletions(-) rename src/lib/provable/{gadgets => test}/arithmetic.unit-test.ts (93%) rename src/lib/provable/{gadgets => test}/bitwise.unit-test.ts (99%) rename src/lib/provable/{gadgets => test}/ecdsa.unit-test.ts (97%) rename src/lib/provable/{gadgets => test}/elliptic-curve.unit-test.ts (94%) rename src/lib/provable/{gadgets/foreign-field.unit-test.ts => test/foreign-field-gadgets.unit-test.ts} (98%) rename src/lib/provable/{gadgets => test}/range-check.unit-test.ts (96%) rename src/lib/provable/{gadgets => test}/sha256.unit-test.ts (97%) rename src/lib/provable/{gadgets => test}/test-utils.ts (94%) rename src/lib/provable/{ => types}/fields.ts (91%) diff --git a/src/lib/provable/gadgets/foreign-field.ts b/src/lib/provable/gadgets/foreign-field.ts index b955521024..71744eb4b3 100644 --- a/src/lib/provable/gadgets/foreign-field.ts +++ b/src/lib/provable/gadgets/foreign-field.ts @@ -11,7 +11,7 @@ import { Unconstrained } from '../types/unconstrained.js'; import { Field } from '../field.js'; import { Gates, foreignFieldAdd } from '../gates.js'; import { exists } from '../core/exists.js'; -import { modifiedField } from '../fields.js'; +import { modifiedField } from '../types/fields.js'; import { Tuple, TupleN } from '../../util/types.js'; import { assertOneOf } from './basic.js'; import { assert, bitSlice, toVar, toVars } from './common.js'; diff --git a/src/lib/provable/packed.ts b/src/lib/provable/packed.ts index 966e8baf70..6bf7d86908 100644 --- a/src/lib/provable/packed.ts +++ b/src/lib/provable/packed.ts @@ -5,7 +5,7 @@ import { Field } from './field.js'; import { assert } from './gadgets/common.js'; import { Poseidon, ProvableHashable, packToFields } from './crypto/poseidon.js'; import { Provable } from './provable.js'; -import { fields, modifiedField } from './fields.js'; +import { fields, modifiedField } from './types/fields.js'; export { Packed, Hashed }; diff --git a/src/lib/provable/gadgets/arithmetic.unit-test.ts b/src/lib/provable/test/arithmetic.unit-test.ts similarity index 93% rename from src/lib/provable/gadgets/arithmetic.unit-test.ts rename to src/lib/provable/test/arithmetic.unit-test.ts index 13009759cd..579dce8236 100644 --- a/src/lib/provable/gadgets/arithmetic.unit-test.ts +++ b/src/lib/provable/test/arithmetic.unit-test.ts @@ -6,9 +6,9 @@ import { record, } from '../../testing/equivalent.js'; import { Field } from '../wrapped.js'; -import { Gadgets } from './gadgets.js'; +import { Gadgets } from '../gadgets/gadgets.js'; import { provable } from '../types/struct.js'; -import { assert } from './common.js'; +import { assert } from '../gadgets/common.js'; let Arithmetic = ZkProgram({ name: 'arithmetic', diff --git a/src/lib/provable/gadgets/bitwise.unit-test.ts b/src/lib/provable/test/bitwise.unit-test.ts similarity index 99% rename from src/lib/provable/gadgets/bitwise.unit-test.ts rename to src/lib/provable/test/bitwise.unit-test.ts index a938b84ab8..1c3bbc8240 100644 --- a/src/lib/provable/gadgets/bitwise.unit-test.ts +++ b/src/lib/provable/test/bitwise.unit-test.ts @@ -7,7 +7,7 @@ import { } from '../../testing/equivalent.js'; import { Fp, mod } from '../../../bindings/crypto/finite-field.js'; import { Field } from '../wrapped.js'; -import { Gadgets } from './gadgets.js'; +import { Gadgets } from '../gadgets/gadgets.js'; import { Random } from '../../testing/property.js'; import { constraintSystem, diff --git a/src/lib/provable/gadgets/ecdsa.unit-test.ts b/src/lib/provable/test/ecdsa.unit-test.ts similarity index 97% rename from src/lib/provable/gadgets/ecdsa.unit-test.ts rename to src/lib/provable/test/ecdsa.unit-test.ts index 0cfab362e3..97e9b93f30 100644 --- a/src/lib/provable/gadgets/ecdsa.unit-test.ts +++ b/src/lib/provable/test/ecdsa.unit-test.ts @@ -5,12 +5,12 @@ import { Point, initialAggregator, verifyEcdsaConstant, -} from './elliptic-curve.js'; -import { Field3 } from './foreign-field.js'; +} from '../gadgets/elliptic-curve.js'; +import { Field3 } from '../gadgets/foreign-field.js'; import { CurveParams } from '../../../bindings/crypto/elliptic-curve-examples.js'; import { Provable } from '../provable.js'; import { ZkProgram } from '../../proof-system/zkprogram.js'; -import { assert } from './common.js'; +import { assert } from '../gadgets/common.js'; import { foreignField, uniformForeignField } from './test-utils.js'; import { First, @@ -22,7 +22,7 @@ import { oneOf, record, } from '../../testing/equivalent.js'; -import { Bool } from '../../provable/bool.js'; +import { Bool } from '../bool.js'; import { Random } from '../../testing/random.js'; // quick tests diff --git a/src/lib/provable/gadgets/elliptic-curve.unit-test.ts b/src/lib/provable/test/elliptic-curve.unit-test.ts similarity index 94% rename from src/lib/provable/gadgets/elliptic-curve.unit-test.ts rename to src/lib/provable/test/elliptic-curve.unit-test.ts index 2dfa76d0fb..2db23ecd9d 100644 --- a/src/lib/provable/gadgets/elliptic-curve.unit-test.ts +++ b/src/lib/provable/test/elliptic-curve.unit-test.ts @@ -9,8 +9,12 @@ import { unit, } from '../../testing/equivalent.js'; import { Random } from '../../testing/random.js'; -import { assert } from './common.js'; -import { EllipticCurve, Point, simpleMapToCurve } from './elliptic-curve.js'; +import { assert } from '../gadgets/common.js'; +import { + EllipticCurve, + Point, + simpleMapToCurve, +} from '../gadgets/elliptic-curve.js'; import { foreignField, throwError } from './test-utils.js'; // provable equivalence tests diff --git a/src/lib/provable/gadgets/foreign-field.unit-test.ts b/src/lib/provable/test/foreign-field-gadgets.unit-test.ts similarity index 98% rename from src/lib/provable/gadgets/foreign-field.unit-test.ts rename to src/lib/provable/test/foreign-field-gadgets.unit-test.ts index e5213da894..3f0fdaaca5 100644 --- a/src/lib/provable/gadgets/foreign-field.unit-test.ts +++ b/src/lib/provable/test/foreign-field-gadgets.unit-test.ts @@ -10,10 +10,10 @@ import { unit, } from '../../testing/equivalent.js'; import { Random } from '../../testing/random.js'; -import { Field3, Gadgets } from './gadgets.js'; +import { Field3, Gadgets } from '../gadgets/gadgets.js'; import { ZkProgram } from '../../proof-system/zkprogram.js'; import { Provable } from '../provable.js'; -import { assert } from './common.js'; +import { assert } from '../gadgets/common.js'; import { allConstant, and, @@ -33,7 +33,7 @@ import { throwError, unreducedForeignField, } from './test-utils.js'; -import { l2 } from './range-check.js'; +import { l2 } from '../gadgets/range-check.js'; const { ForeignField } = Gadgets; diff --git a/src/lib/provable/test/keccak.unit-test.ts b/src/lib/provable/test/keccak.unit-test.ts index b70f704748..1678b0a231 100644 --- a/src/lib/provable/test/keccak.unit-test.ts +++ b/src/lib/provable/test/keccak.unit-test.ts @@ -16,7 +16,7 @@ import { sha3_512, } from '@noble/hashes/sha3'; import { Bytes } from '../wrapped-classes.js'; -import { bytes } from '../gadgets/test-utils.js'; +import { bytes } from './test-utils.js'; import { UInt8 } from '../int.js'; import { test, Random, sample } from '../../testing/property.js'; import { expect } from 'expect'; diff --git a/src/lib/provable/gadgets/range-check.unit-test.ts b/src/lib/provable/test/range-check.unit-test.ts similarity index 96% rename from src/lib/provable/gadgets/range-check.unit-test.ts rename to src/lib/provable/test/range-check.unit-test.ts index ba2ab8b087..fbb65befb7 100644 --- a/src/lib/provable/gadgets/range-check.unit-test.ts +++ b/src/lib/provable/test/range-check.unit-test.ts @@ -8,9 +8,9 @@ import { fieldWithRng, } from '../../testing/equivalent.js'; import { Random } from '../../testing/property.js'; -import { assert } from './common.js'; -import { Gadgets } from './gadgets.js'; -import { l } from './range-check.js'; +import { assert } from '../gadgets/common.js'; +import { Gadgets } from '../gadgets/gadgets.js'; +import { l } from '../gadgets/range-check.js'; import { constraintSystem, contains, diff --git a/src/lib/provable/gadgets/sha256.unit-test.ts b/src/lib/provable/test/sha256.unit-test.ts similarity index 97% rename from src/lib/provable/gadgets/sha256.unit-test.ts rename to src/lib/provable/test/sha256.unit-test.ts index bf8f5cb27c..c18d661752 100644 --- a/src/lib/provable/gadgets/sha256.unit-test.ts +++ b/src/lib/provable/test/sha256.unit-test.ts @@ -1,6 +1,6 @@ import { ZkProgram } from '../../proof-system/zkprogram.js'; import { Bytes } from '../wrapped-classes.js'; -import { Gadgets } from './gadgets.js'; +import { Gadgets } from '../gadgets/gadgets.js'; import { sha256 as nobleSha256 } from '@noble/hashes/sha256'; import { bytes } from './test-utils.js'; import { diff --git a/src/lib/provable/gadgets/test-utils.ts b/src/lib/provable/test/test-utils.ts similarity index 94% rename from src/lib/provable/gadgets/test-utils.ts rename to src/lib/provable/test/test-utils.ts index 4b420aa632..0406cc0d2a 100644 --- a/src/lib/provable/gadgets/test-utils.ts +++ b/src/lib/provable/test/test-utils.ts @@ -1,8 +1,8 @@ import type { FiniteField } from '../../../bindings/crypto/finite-field.js'; import { ProvableSpec, spec } from '../../testing/equivalent.js'; import { Random } from '../../testing/random.js'; -import { Field3 } from './gadgets.js'; -import { assert } from './common.js'; +import { Field3 } from '../gadgets/gadgets.js'; +import { assert } from '../gadgets/common.js'; import { Bytes } from '../wrapped-classes.js'; export { diff --git a/src/lib/provable/fields.ts b/src/lib/provable/types/fields.ts similarity index 91% rename from src/lib/provable/fields.ts rename to src/lib/provable/types/fields.ts index 419ba9d203..e92cd0d51e 100644 --- a/src/lib/provable/fields.ts +++ b/src/lib/provable/types/fields.ts @@ -1,5 +1,5 @@ -import { ProvablePureExtended } from './types/struct.js'; -import { Field } from './field.js'; +import { ProvablePureExtended } from './struct.js'; +import { Field } from '../field.js'; export { modifiedField, fields };