Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions yarn-project/prover-client/src/mocks/test_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import * as fs from 'fs/promises';
import { type MockProxy, mock } from 'jest-mock-extended';

import { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
import { CircuitProverAgent } from '../prover-pool/circuit-prover-agent.js';
import { ProverPool } from '../prover-pool/prover-pool.js';
import { type BBProverConfig } from '../prover/bb_prover.js';
import { type CircuitProver } from '../prover/interface.js';
import { TestCircuitProver } from '../prover/test_circuit_prover.js';
Expand All @@ -35,6 +37,7 @@ export class TestContext {
public globalVariables: GlobalVariables,
public actualDb: MerkleTreeOperations,
public prover: CircuitProver,
public proverPool: ProverPool,
public orchestrator: ProvingOrchestrator,
public blockNumber: number,
public directoriesToCleanup: string[],
Expand All @@ -43,6 +46,7 @@ export class TestContext {

static async new(
logger: DebugLogger,
proverCount = 4,
createProver: (bbConfig: BBProverConfig) => Promise<CircuitProver> = _ =>
Promise.resolve(new TestCircuitProver(new WASMSimulator())),
blockNumber = 3,
Expand Down Expand Up @@ -82,7 +86,10 @@ export class TestContext {
localProver = await createProver(bbConfig);
}

const orchestrator = await ProvingOrchestrator.new(actualDb, localProver);
const proverPool = new ProverPool(proverCount, i => new CircuitProverAgent(localProver, 10, `${i}`));
const orchestrator = new ProvingOrchestrator(actualDb, proverPool.queue);

await proverPool.start();

return new this(
publicExecutor,
Expand All @@ -93,6 +100,7 @@ export class TestContext {
globalVariables,
actualDb,
localProver,
proverPool,
orchestrator,
blockNumber,
[config?.directoryToCleanup ?? ''],
Expand All @@ -101,7 +109,7 @@ export class TestContext {
}

async cleanup() {
await this.orchestrator.stop();
await this.proverPool.stop();
for (const dir of this.directoriesToCleanup.filter(x => x !== '')) {
await fs.rm(dir, { recursive: true, force: true });
}
Expand Down
Loading