Skip to content

Commit

Permalink
Remove chai-as-promised
Browse files Browse the repository at this point in the history
We can use fs.existsSync to check if a directory exists
  • Loading branch information
fvictorio committed Sep 12, 2024
1 parent caa756a commit 020af16
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
2 changes: 0 additions & 2 deletions js/integration-tests/solidity-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
"@nomicfoundation/edr-helpers": "workspace:*",
"@tsconfig/node20": "^20.1.4",
"@types/chai": "^4.2.0",
"@types/chai-as-promised": "^7.1.8",
"@types/mocha": ">=9.1.0",
"@types/node": "^20.0.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"hardhat": "2.22.10",
"prettier": "^3.2.5",
"ts-node": "^10.8.0",
Expand Down
14 changes: 6 additions & 8 deletions js/integration-tests/solidity-tests/test/fuzz.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import chai, { assert, expect } from "chai";
import chaiAsPromised from "chai-as-promised";
import { TestContext } from "./testContext";
import fs from "node:fs/promises";
import { existsSync } from "node:fs";
import { FuzzConfigArgs } from "@nomicfoundation/edr";

chai.use(chaiAsPromised);

describe("Fuzz and invariant testing", function () {
let testContext: TestContext;

Expand All @@ -27,7 +25,7 @@ describe("Fuzz and invariant testing", function () {
assert.equal(result1.totalTests, 1);

// The fuzz failure directory should not be created if we don't set the directory
await assert.isRejected(fs.stat(failureDir));
assert.isFalse(existsSync(failureDir));

const result2 = await testContext.runTestsWithStats("OverflowTest", {
fuzz: {
Expand All @@ -38,7 +36,7 @@ describe("Fuzz and invariant testing", function () {
assert.equal(result2.totalTests, 1);

// The fuzz failure directory should now be created
await assert.isFulfilled(fs.stat(failureDir));
assert.isTrue(existsSync(failureDir));
});

// One test as steps should be sequential
Expand Down Expand Up @@ -66,7 +64,7 @@ describe("Fuzz and invariant testing", function () {
assert.equal(result1.totalTests, 1);

// The invariant failure directory should not be created if we don't set the directory
await assert.isRejected(fs.stat(failureDir));
assert.isFalse(existsSync(failureDir));

const firstStart = performance.now();
const result2 = await testContext.runTestsWithStats(
Expand All @@ -83,7 +81,7 @@ describe("Fuzz and invariant testing", function () {
assert.equal(result2.totalTests, 1);

// The invariant failure directory should now be created
await assert.isFulfilled(fs.stat(failureDir));
assert.isTrue(existsSync(failureDir));

const secondStart = performance.now();
const result3 = await testContext.runTestsWithStats(
Expand All @@ -100,7 +98,7 @@ describe("Fuzz and invariant testing", function () {
const secondDuration = performance.now() - secondStart;

// The invariant failure directory should still be there
await assert.isFulfilled(fs.stat(failureDir));
assert.isTrue(existsSync(failureDir));
// The second run should be faster than the first because it should use the persisted failure.
assert.isBelow(secondDuration, firstDuration * 0.25);
});
Expand Down
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 020af16

Please sign in to comment.