Skip to content

Commit

Permalink
add regression unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Apr 10, 2024
1 parent cbf4975 commit fe30b9a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/provable/test/merkle-tree.unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Bool, Field } from '../wrapped.js';
import { maybeSwap } from '../merkle-tree.js';
import { Random, test } from '../../testing/property.js';
import { expect } from 'expect';
import { MerkleMap } from '../merkle-map.js';

test(Random.bool, Random.field, Random.field, (b, x, y) => {
let [x0, y0] = maybeSwap(Bool(!!b), Field(x), Field(y));
Expand All @@ -15,3 +16,10 @@ test(Random.bool, Random.field, Random.field, (b, x, y) => {
expect(y0.toBigInt()).toEqual(x);
}
});

test(Random.field, (key) => {
let map = new MerkleMap();
let witness = map.getWitness(Field(key));
let [, calculatedKey] = witness.computeRootAndKey(Field(0));
expect(calculatedKey.toBigInt()).toEqual(key);
});

0 comments on commit fe30b9a

Please sign in to comment.