Skip to content

Commit

Permalink
Add dryrun query parameter to /session/input-files and /session/verif…
Browse files Browse the repository at this point in the history
…y-checked end-points.

Signed-off-by: Simon Viénot <[email protected]>
  • Loading branch information
svienot committed Dec 7, 2023
1 parent 8f37472 commit 607346a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
openapi: "3.0.0"

paths:
/session/input-files:
post:
Expand Down Expand Up @@ -39,6 +38,12 @@ paths:
format: uri
description: Remote file URL
required: false
- name: dryrun
in: query
schema:
type: boolean
description: Dry-run flag. When set to true, a successful verification result will not be stored in the repository.
required: false
responses:
"200":
description: Response is sent when the upload is successful under different conditions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function addInputFilesEndpoint(req: Request, res: Response) {
return { path: pb.path, content: pb.buffer.toString(FILE_ENCODING) };
});

const dryRun = Boolean(req.body.dryRun)
const session = req.session;
const newFilesCount = saveFiles(pathContents, session);
if (newFilesCount) {
Expand All @@ -48,7 +49,8 @@ export async function addInputFilesEndpoint(req: Request, res: Response) {
session.contractWrappers,
session,
services.verification,
services.repository
services.repository,
dryRun
);
}
res.send(getSessionJSON(session));
Expand Down Expand Up @@ -102,6 +104,7 @@ export async function addInputContractEndpoint(req: Request, res: Response) {
content: retrievedMetadataBase64,
});

const dryRun = Boolean(req.query.dryrun)
const session = req.session;

const newFilesCount = saveFiles(pathContents, session);
Expand All @@ -112,7 +115,8 @@ export async function addInputContractEndpoint(req: Request, res: Response) {
session.contractWrappers,
session,
services.verification,
services.repository
services.repository,
dryRun
);
}
res.send(getSessionJSON(session));
Expand Down
5 changes: 3 additions & 2 deletions src/server/controllers/verification/verification.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ export const verifyContractsInSession = async (
contractWrappers: ContractWrapperMap,
session: Session,
verificationService: IVerificationService,
repositoryService: IRepositoryService
repositoryService: IRepositoryService,
dryRun: boolean = false
): Promise<void> => {
for (const id in contractWrappers) {
const contractWrapper = contractWrappers[id];
Expand Down Expand Up @@ -379,7 +380,7 @@ export const verifyContractsInSession = async (
contractWrapper.status = match.status || "error";
contractWrapper.statusMessage = match.message;
contractWrapper.storageTimestamp = match.storageTimestamp;
if (match.status) {
if (match.status && !dryRun) {
await repositoryService.storeMatch(checkedContract, match);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export async function verifyContractsInSessionEndpoint(
throw new BadRequestError("There are currently no pending contracts.");
}

const dryRun = Boolean(req.query.dryRun)
const receivedContracts: SendableContract[] = req.body.contracts;

const verifiable: ContractWrapperMap = {};
Expand All @@ -40,7 +41,8 @@ export async function verifyContractsInSessionEndpoint(
verifiable,
session,
services.verification,
services.repository
services.repository,
dryRun
);
res.send(getSessionJSON(session));
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ paths:
verificationId:
type: string
example: "0x3f67e9f57515bb1e7195c7c5af1eff630091567c0bb65ba3dece57a56da766fe"
parameters:
- name: dryrun
in: query
schema:
type: boolean
description: Dry-run flag. When set to true, a successful verification result will not be stored in the repository.
required: false
responses:
"200":
description: OK
Expand Down

0 comments on commit 607346a

Please sign in to comment.