Skip to content

Commit

Permalink
Fix rollup circuits wasm test
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Apr 27, 2023
1 parent 12a7feb commit 73407e8
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions yarn-project/circuits.js/src/rollup/rollup_wasm_wrapper.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { AggregationObject, CircuitError, VerificationKey } from '../index.js';
import { AggregationObject, CircuitError, MergeRollupInputs, RootRollupInputs, VerificationKey } from '../index.js';
import { makeBaseRollupInputs, makeMergeRollupInputs, makeRootRollupInputs } from '../tests/factories.js';
import { CircuitsWasm } from '../wasm/circuits_wasm.js';
import { RollupWasmWrapper } from './rollup_wasm_wrapper.js';

// TODO: All these tests are currently failing with segfaults.
// Note that base and root rollup sim are called ok from the circuit_powered_block_builder,
// so the problem must be with an invalid input we're providing.
describe('rollup/rollup_wasm_wrapper', () => {
let wasm: CircuitsWasm;
let rollupWasm: RollupWasmWrapper;
Expand All @@ -25,20 +22,25 @@ describe('rollup/rollup_wasm_wrapper', () => {
return input;
};

const makeMergeRollupInputsForCircuit = () => {
const input = makeMergeRollupInputs();
for (const previousData of input.previousRollupData) {
previousData.vk = VerificationKey.makeFake();
previousData.publicInputs.endAggregationObject = AggregationObject.makeFake();
}
// fix inputs to make it compatible with the merge circuit requirements
const fixPreviousRollupInputs = (input: MergeRollupInputs | RootRollupInputs) => {
input.previousRollupData[1].publicInputs.constants = input.previousRollupData[0].publicInputs.constants;
input.previousRollupData[1].publicInputs.startPrivateDataTreeSnapshot =
input.previousRollupData[0].publicInputs.endPrivateDataTreeSnapshot;
input.previousRollupData[1].publicInputs.startNullifierTreeSnapshot =
input.previousRollupData[0].publicInputs.endNullifierTreeSnapshot;
input.previousRollupData[1].publicInputs.startContractTreeSnapshot =
input.previousRollupData[0].publicInputs.endContractTreeSnapshot;
input.previousRollupData[1].publicInputs.startPublicDataTreeSnapshot =
input.previousRollupData[0].publicInputs.endPublicDataTreeSnapshot;
};

const makeMergeRollupInputsForCircuit = () => {
const input = makeMergeRollupInputs();
for (const previousData of input.previousRollupData) {
previousData.vk = VerificationKey.makeFake();
previousData.publicInputs.endAggregationObject = AggregationObject.makeFake();
}
fixPreviousRollupInputs(input);
return input;
};

Expand Down Expand Up @@ -85,18 +87,18 @@ describe('rollup/rollup_wasm_wrapper', () => {
}
});

it.skip('calls root_rollup__sim', async () => {
it('calls root_rollup__sim', async () => {
const input = makeRootRollupInputs();

for (const rd of input.previousRollupData) {
rd.vk = VerificationKey.makeFake();
rd.publicInputs.endAggregationObject = AggregationObject.makeFake();
rd.publicInputs = await rollupWasm.simulateBaseRollup(makeBaseRollupInputsForCircuit());
}
fixPreviousRollupInputs(input);

const output = await rollupWasm.simulateRootRollup(input);
expect(output.startNullifierTreeSnapshot).toEqual(
input.previousRollupData[0].publicInputs.startNullifierTreeSnapshot,
);
});
}, 15_000);
});

0 comments on commit 73407e8

Please sign in to comment.