Skip to content

Commit

Permalink
Wrap tests covering dryrun query parameter into their own describe() …
Browse files Browse the repository at this point in the history
…clause.

Signed-off-by: Simon Viénot <[email protected]>
  • Loading branch information
svienot committed Dec 19, 2023
1 parent 43a22a1 commit 2c3606b
Showing 1 changed file with 82 additions and 80 deletions.
162 changes: 82 additions & 80 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1271,91 +1271,93 @@ describe("Server", function () {
});
});

it("should not store the successful verification result when the query parameter dryrun=true is provided", (done) => {
const agent = chai.request.agent(server.app);
agent
.post("/session/input-files?dryrun=true")
.attach("files", sourceBuffer)
.attach("files", metadataBuffer)
.then((res) => {
const contracts = assertSingleContractStatus(res, "error");
contracts[0].address = defaultContractAddress;

agent
.post("/session/verify-checked?dryrun=true")
.send({ contracts })
.then((res) => {
assertSingleContractStatus(res, "error");
contracts[0].chainId = defaultContractChain;

agent
.post("/session/verify-checked?dryrun=true")
.send({ contracts })
.then((res) => {
assertSingleContractStatus(res, "perfect");
assertContractNotSaved(defaultContractAddress, defaultContractChain);
done();
});
});
});
});

it("should store the successful verification result when the query parameter dryrun=false is provided", (done) => {
const agent = chai.request.agent(server.app);
agent
.post("/session/input-files?dryrun=false")
.attach("files", sourceBuffer)
.attach("files", metadataBuffer)
.then((res) => {
const contracts = assertSingleContractStatus(res, "error");
contracts[0].address = defaultContractAddress;
describe("dryrun query parameter", function () {
it("should not store the successful verification result when the query parameter dryrun=true is provided", (done) => {
const agent = chai.request.agent(server.app);
agent
.post("/session/input-files?dryrun=true")
.attach("files", sourceBuffer)
.attach("files", metadataBuffer)
.then((res) => {
const contracts = assertSingleContractStatus(res, "error");
contracts[0].address = defaultContractAddress;

agent
.post("/session/verify-checked?dryrun=false")
.send({ contracts })
.then((res) => {
assertSingleContractStatus(res, "error");
contracts[0].chainId = defaultContractChain;
agent
.post("/session/verify-checked?dryrun=true")
.send({contracts})
.then((res) => {
assertSingleContractStatus(res, "error");
contracts[0].chainId = defaultContractChain;

agent
.post("/session/verify-checked?dryrun=true")
.send({contracts})
.then((res) => {
assertSingleContractStatus(res, "perfect");
assertContractNotSaved(defaultContractAddress, defaultContractChain);
done();
});
});
});
});

agent
.post("/session/verify-checked?dryrun=false")
.send({ contracts })
.then((res) => {
assertSingleContractStatus(res, "perfect");
assertContractSaved(defaultContractAddress, defaultContractChain, "perfect");
done();
});
});
});
});
it("should store the successful verification result when the query parameter dryrun=false is provided", (done) => {
const agent = chai.request.agent(server.app);
agent
.post("/session/input-files?dryrun=false")
.attach("files", sourceBuffer)
.attach("files", metadataBuffer)
.then((res) => {
const contracts = assertSingleContractStatus(res, "error");
contracts[0].address = defaultContractAddress;

it("should store the successful verification result when the query parameter dryrun is not provided", (done) => {
const agent = chai.request.agent(server.app);
agent
.post("/session/input-files")
.attach("files", sourceBuffer)
.attach("files", metadataBuffer)
.then((res) => {
const contracts = assertSingleContractStatus(res, "error");
contracts[0].address = defaultContractAddress;
agent
.post("/session/verify-checked?dryrun=false")
.send({contracts})
.then((res) => {
assertSingleContractStatus(res, "error");
contracts[0].chainId = defaultContractChain;

agent
.post("/session/verify-checked?dryrun=false")
.send({contracts})
.then((res) => {
assertSingleContractStatus(res, "perfect");
assertContractSaved(defaultContractAddress, defaultContractChain, "perfect");
done();
});
});
});
});

agent
.post("/session/verify-checked")
.send({ contracts })
.then((res) => {
assertSingleContractStatus(res, "error");
contracts[0].chainId = defaultContractChain;
it("should store the successful verification result when the query parameter dryrun is not provided", (done) => {
const agent = chai.request.agent(server.app);
agent
.post("/session/input-files")
.attach("files", sourceBuffer)
.attach("files", metadataBuffer)
.then((res) => {
const contracts = assertSingleContractStatus(res, "error");
contracts[0].address = defaultContractAddress;

agent
.post("/session/verify-checked")
.send({ contracts })
.then((res) => {
assertSingleContractStatus(res, "perfect");
assertContractSaved(defaultContractAddress, defaultContractChain, "perfect");
done();
});
});
});
agent
.post("/session/verify-checked")
.send({contracts})
.then((res) => {
assertSingleContractStatus(res, "error");
contracts[0].chainId = defaultContractChain;

agent
.post("/session/verify-checked")
.send({contracts})
.then((res) => {
assertSingleContractStatus(res, "perfect");
assertContractSaved(defaultContractAddress, defaultContractChain, "perfect");
done();
});
});
});
});
});

it("should fail for a source that is missing and unfetchable", (done) => {
Expand Down

0 comments on commit 2c3606b

Please sign in to comment.