Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dry run parameter to /session/input-files and /session/verify-checked end-points #92

Merged
merged 4 commits into from
Dec 7, 2023
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
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,13 @@ paths:
format: uri
description: Remote file URL
required: false
- name: dryrun
in: query
schema:
type: boolean
svienot marked this conversation as resolved.
Show resolved Hide resolved
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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));
Expand Down Expand Up @@ -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)
Nana-EC marked this conversation as resolved.
Show resolved Hide resolved
const session = req.session;

const newFilesCount = saveFiles(pathContents, session);
Expand All @@ -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));
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,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
Expand Down
Loading