diff --git a/src/server/controllers/verification/session-state/input-files.session-state.paths.yaml b/src/server/controllers/verification/session-state/input-files.session-state.paths.yaml index 61cf2167..6049cc92 100644 --- a/src/server/controllers/verification/session-state/input-files.session-state.paths.yaml +++ b/src/server/controllers/verification/session-state/input-files.session-state.paths.yaml @@ -1,5 +1,4 @@ openapi: "3.0.0" - paths: /session/input-files: post: @@ -39,6 +38,13 @@ paths: format: uri description: Remote file URL required: false + - name: dryrun + in: query + schema: + type: boolean + default: false + description: Dry-run flag. When present and 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. diff --git a/src/server/controllers/verification/session-state/session-state.handlers.ts b/src/server/controllers/verification/session-state/session-state.handlers.ts index da503112..3d546b3a 100644 --- a/src/server/controllers/verification/session-state/session-state.handlers.ts +++ b/src/server/controllers/verification/session-state/session-state.handlers.ts @@ -40,6 +40,8 @@ export async function addInputFilesEndpoint(req: Request, res: Response) { return { path: pb.path, content: pb.buffer.toString(FILE_ENCODING) }; }); + // when undefined, the dryrun parameter interpreted as false + const dryRun = Boolean(req.query.dryrun) const session = req.session; const newFilesCount = saveFiles(pathContents, session); if (newFilesCount) { @@ -48,7 +50,8 @@ export async function addInputFilesEndpoint(req: Request, res: Response) { session.contractWrappers, session, services.verification, - services.repository + services.repository, + dryRun ); } res.send(getSessionJSON(session)); @@ -102,6 +105,8 @@ export async function addInputContractEndpoint(req: Request, res: Response) { content: retrievedMetadataBase64, }); + // when undefined, the dryrun parameter interpreted as false + const dryRun = Boolean(req.query.dryrun) const session = req.session; const newFilesCount = saveFiles(pathContents, session); @@ -112,7 +117,8 @@ export async function addInputContractEndpoint(req: Request, res: Response) { session.contractWrappers, session, services.verification, - services.repository + services.repository, + dryRun ); } res.send(getSessionJSON(session)); diff --git a/src/server/controllers/verification/verification.common.ts b/src/server/controllers/verification/verification.common.ts index a35c8953..2878803b 100644 --- a/src/server/controllers/verification/verification.common.ts +++ b/src/server/controllers/verification/verification.common.ts @@ -294,7 +294,8 @@ export const verifyContractsInSession = async ( contractWrappers: ContractWrapperMap, session: Session, verificationService: IVerificationService, - repositoryService: IRepositoryService + repositoryService: IRepositoryService, + dryRun: boolean = false ): Promise => { for (const id in contractWrappers) { const contractWrapper = contractWrappers[id]; @@ -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); } } diff --git a/src/server/controllers/verification/verify/session/verify.session.handlers.ts b/src/server/controllers/verification/verify/session/verify.session.handlers.ts index 71442dad..005e461f 100644 --- a/src/server/controllers/verification/verify/session/verify.session.handlers.ts +++ b/src/server/controllers/verification/verify/session/verify.session.handlers.ts @@ -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 = {}; @@ -40,7 +41,8 @@ export async function verifyContractsInSessionEndpoint( verifiable, session, services.verification, - services.repository + services.repository, + dryRun ); res.send(getSessionJSON(session)); } diff --git a/src/server/controllers/verification/verify/session/verify.session.paths.yaml b/src/server/controllers/verification/verify/session/verify.session.paths.yaml index e8773c9f..e223d2ac 100644 --- a/src/server/controllers/verification/verify/session/verify.session.paths.yaml +++ b/src/server/controllers/verification/verify/session/verify.session.paths.yaml @@ -31,6 +31,14 @@ paths: verificationId: type: string example: "0x3f67e9f57515bb1e7195c7c5af1eff630091567c0bb65ba3dece57a56da766fe" + parameters: + - name: dryrun + in: query + schema: + type: boolean + default: false + description: Dry-run flag. When present and set to true, a successful verification result will not be stored in the repository. + required: false responses: "200": description: OK