Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Feb 10, 2025
1 parent df0842e commit e0d90e7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ describe.each([
);

await Promise.all(promises);
expect(database.addProvingJob).toHaveBeenCalledTimes(3);
expect(database.addProvingJob).toHaveBeenNthCalledWith(1, expect.objectContaining({ epochNumber: 0 }));
expect(database.addProvingJob).toHaveBeenNthCalledWith(2, expect.objectContaining({ epochNumber: 1 }));
expect(database.addProvingJob).toHaveBeenNthCalledWith(
expect(database.addProvingJobs).toHaveBeenCalledTimes(3);
expect(database.addProvingJobs).toHaveBeenNthCalledWith(1, expect.objectContaining({ epochNumber: 0 }));
expect(database.addProvingJobs).toHaveBeenNthCalledWith(2, expect.objectContaining({ epochNumber: 1 }));
expect(database.addProvingJobs).toHaveBeenNthCalledWith(
3,
expect.objectContaining({ epochNumber: 0 }),
expect.objectContaining({ epochNumber: 0 }),
Expand Down Expand Up @@ -327,13 +327,13 @@ describe.each([
);

await Promise.all(promises);
expect(database.addProvingJob).toHaveBeenCalledTimes(2);
expect(database.addProvingJob).toHaveBeenNthCalledWith(
expect(database.addProvingJobs).toHaveBeenCalledTimes(2);
expect(database.addProvingJobs).toHaveBeenNthCalledWith(
1,
expect.objectContaining({ epochNumber: 0 }),
expect.objectContaining({ epochNumber: 0 }),
);
expect(database.addProvingJob).toHaveBeenNthCalledWith(2, expect.objectContaining({ epochNumber: 0 }));
expect(database.addProvingJobs).toHaveBeenNthCalledWith(2, expect.objectContaining({ epochNumber: 0 }));
});

it('correctly reports errors', async () => {
Expand Down Expand Up @@ -1093,15 +1093,15 @@ describe.each([
it('re-enqueues proof requests on start', async () => {
const id1 = makeRandomProvingJobId();

await database.addProvingJob({
await database.addProvingJobs({
id: id1,
type: ProvingRequestType.BASE_PARITY,
epochNumber: 1,
inputsUri: makeInputsUri(),
});

const id2 = makeRandomProvingJobId();
await database.addProvingJob({
await database.addProvingJobs({
id: id2,
type: ProvingRequestType.PRIVATE_BASE_ROLLUP,
epochNumber: 2,
Expand Down Expand Up @@ -1144,15 +1144,15 @@ describe.each([
it('restores proof results on start', async () => {
const id1 = makeRandomProvingJobId(1);

await database.addProvingJob({
await database.addProvingJobs({
id: id1,
type: ProvingRequestType.BASE_PARITY,
epochNumber: 1,
inputsUri: makeInputsUri(),
});

const id2 = makeRandomProvingJobId(2);
await database.addProvingJob({
await database.addProvingJobs({
id: id2,
type: ProvingRequestType.PRIVATE_BASE_ROLLUP,
epochNumber: 2,
Expand All @@ -1178,7 +1178,7 @@ describe.each([
it('only re-enqueues unfinished jobs', async () => {
const id1 = makeRandomProvingJobId();

await database.addProvingJob({
await database.addProvingJobs({
id: id1,
type: ProvingRequestType.BASE_PARITY,
epochNumber: 1,
Expand All @@ -1187,7 +1187,7 @@ describe.each([
await database.setProvingJobResult(id1, makeOutputsUri());

const id2 = makeRandomProvingJobId();
await database.addProvingJob({
await database.addProvingJobs({
id: id2,
type: ProvingRequestType.PRIVATE_BASE_ROLLUP,
epochNumber: 2,
Expand All @@ -1213,7 +1213,7 @@ describe.each([
jest.spyOn(database, 'addProvingJob');
await broker.enqueueProvingJob(job);

expect(database.addProvingJob).toHaveBeenCalledWith(job);
expect(database.addProvingJobs).toHaveBeenCalledWith(job);
});

it('does not retain job if database fails to save', async () => {
Expand Down Expand Up @@ -1307,7 +1307,7 @@ describe.each([
await broker.reportProvingJobSuccess(id, makeOutputsUri());

expect(database.setProvingJobResult).not.toHaveBeenCalled();
expect(database.addProvingJob).not.toHaveBeenCalled();
expect(database.addProvingJobs).not.toHaveBeenCalled();
});

it('does not save job error if job is unknown', async () => {
Expand All @@ -1320,7 +1320,7 @@ describe.each([
await broker.reportProvingJobError(id, 'test error');

expect(database.setProvingJobError).not.toHaveBeenCalled();
expect(database.addProvingJob).not.toHaveBeenCalled();
expect(database.addProvingJobs).not.toHaveBeenCalled();
});

it('cleans up old jobs periodically', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
this.logger.verbose(`Writing jobs to disk batchSize=${currentBatch.jobs.length}`);

try {
await this.database.addProvingJob(...currentBatch.jobs);
await this.database.addProvingJobs(...currentBatch.jobs);
for (const job of currentBatch.jobs) {
this.enqueueJobInternal(job);
}
Expand Down Expand Up @@ -285,7 +285,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
return Promise.resolve(this.#reportProvingJobProgress(id, startedAt, filter));
}

async #enqueueProvingJob(job: ProvingJob): Promise<ProvingJobStatus> {
#enqueueProvingJob(job: ProvingJob): Promise<ProvingJobStatus> {
// We return the job status at the start of this call
const jobStatus = this.#getProvingJobStatus(job.id);
if (this.jobsCache.has(job.id)) {
Expand All @@ -294,7 +294,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
this.logger.debug(`Duplicate proving job id=${job.id} epochNumber=${job.epochNumber}. Ignoring`, {
provingJobId: job.id,
});
return jobStatus;
return Promise.resolve(jobStatus);
}

if (this.isJobStale(job)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ProvingBrokerDatabase {
* Saves a proof request so it can be retrieved later
* @param requests - The proof request to save
*/
addProvingJob(...requests: ProvingJob[]): Promise<void>;
addProvingJobs(...requests: ProvingJob[]): Promise<void>;

/**
* Deletes all proving jobs belonging to epochs older than the given epoch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
it('can add a proving job', async () => {
const id = makeRandomProvingJobId(42);
await expect(
db.addProvingJob({
db.addProvingJobs({
id,
epochNumber: 42,
type: ProvingRequestType.BASE_PARITY,
Expand All @@ -49,7 +49,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
for (let i = 0; i < numJobs; i++) {
const id = makeRandomProvingJobId(42);
await expect(
db.addProvingJob({
db.addProvingJobs({
id,
epochNumber: 42,
type: ProvingRequestType.BASE_PARITY,
Expand All @@ -62,7 +62,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
it('can add multiple proving jobs as a batch', async () => {
const numJobs = 5;
await expect(
db.addProvingJob(
db.addProvingJobs(
...times(numJobs, () => ({
id: makeRandomProvingJobId(42),
epochNumber: 42,
Expand All @@ -76,7 +76,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
it('rejects batches containing jobs from different epochs', async () => {
const numJobs = 5;
await expect(
db.addProvingJob(
db.addProvingJobs(
...times(numJobs, () => ({
id: makeRandomProvingJobId(42),
epochNumber: 42,
Expand All @@ -96,7 +96,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
it('can add a proving success', async () => {
// need to add the epoch via a new job
const id = makeRandomProvingJobId(42);
await db.addProvingJob({
await db.addProvingJobs({
id,
epochNumber: 42,
type: ProvingRequestType.BASE_PARITY,
Expand All @@ -108,7 +108,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
it('can add multiple proving successes', async () => {
// need to add the epoch via a new job
const id = makeRandomProvingJobId(42);
await db.addProvingJob({
await db.addProvingJobs({
id,
epochNumber: 42,
type: ProvingRequestType.BASE_PARITY,
Expand All @@ -125,7 +125,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
it('can add a proving error', async () => {
// need to add the epoch via a new job
const id = makeRandomProvingJobId(42);
await db.addProvingJob({
await db.addProvingJobs({
id,
epochNumber: 42,
type: ProvingRequestType.BASE_PARITY,
Expand All @@ -138,7 +138,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
it('can add multiple proving errors', async () => {
// need to add the epoch via a new job
const id = makeRandomProvingJobId(42);
await db.addProvingJob({
await db.addProvingJobs({
id,
epochNumber: 42,
type: ProvingRequestType.BASE_PARITY,
Expand All @@ -158,7 +158,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
for (let i = 0; i < numJobs; i++) {
const id = makeRandomProvingJobId(startEpoch + i);
await expect(
db.addProvingJob({
db.addProvingJobs({
id,
epochNumber: startEpoch + i,
type: ProvingRequestType.BASE_PARITY,
Expand All @@ -182,7 +182,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
type: ProvingRequestType.BASE_PARITY,
inputsUri: makeInputsUri(),
};
await db.addProvingJob(job);
await db.addProvingJobs(job);
if (i == startEpoch + 2) {
expectedJobs.push([job, undefined]);
} else if (i % 2) {
Expand All @@ -206,7 +206,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
const epochs = [];
for (let i = 0; i < numJobs; i++) {
const id = makeRandomProvingJobId(startEpoch + i);
await db.addProvingJob({
await db.addProvingJobs({
id,
epochNumber: startEpoch + i,
type: ProvingRequestType.BASE_PARITY,
Expand All @@ -229,7 +229,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
type: ProvingRequestType.BASE_PARITY,
inputsUri: makeInputsUri(),
};
await db.addProvingJob(job);
await db.addProvingJobs(job);
if (i == startEpoch + 2) {
expectedJobs.push([job, undefined]);
} else if (i % 2) {
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('ProvingBrokerPersistedDatabase', () => {
type: ProvingRequestType.BASE_PARITY,
inputsUri: makeInputsUri(),
};
await db.addProvingJob(job);
await db.addProvingJobs(job);
if (i == startEpoch + 2) {
expectedJobs.push([job, undefined]);
} else if (i % 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class InMemoryBrokerDatabase implements ProvingBrokerDatabase {
return this.results.get(id);
}

addProvingJob(...requests: ProvingJob[]): Promise<void> {
addProvingJobs(...requests: ProvingJob[]): Promise<void> {
for (const req of requests) {
this.jobs.set(req.id, req);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
}
}

async addProvingJob(...jobs: ProvingJob[]): Promise<void> {
async addProvingJobs(...jobs: ProvingJob[]): Promise<void> {
if (jobs.length === 0) {
return;
}
Expand Down

0 comments on commit e0d90e7

Please sign in to comment.