From 020af16683b62bcff98e3ff9c7436b6f6ef50141 Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Thu, 12 Sep 2024 09:54:04 +0200 Subject: [PATCH] Remove chai-as-promised We can use fs.existsSync to check if a directory exists --- js/integration-tests/solidity-tests/package.json | 2 -- js/integration-tests/solidity-tests/test/fuzz.ts | 14 ++++++-------- pnpm-lock.yaml | 6 ------ 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/js/integration-tests/solidity-tests/package.json b/js/integration-tests/solidity-tests/package.json index e25fce221a..18a439d794 100644 --- a/js/integration-tests/solidity-tests/package.json +++ b/js/integration-tests/solidity-tests/package.json @@ -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", diff --git a/js/integration-tests/solidity-tests/test/fuzz.ts b/js/integration-tests/solidity-tests/test/fuzz.ts index 33921b2986..dcdf68a1d5 100644 --- a/js/integration-tests/solidity-tests/test/fuzz.ts +++ b/js/integration-tests/solidity-tests/test/fuzz.ts @@ -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; @@ -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: { @@ -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 @@ -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( @@ -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( @@ -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); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8e44c6f611..36f4c6bec9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -424,9 +424,6 @@ importers: '@types/chai': specifier: ^4.2.0 version: 4.3.12 - '@types/chai-as-promised': - specifier: ^7.1.8 - version: 7.1.8 '@types/mocha': specifier: '>=9.1.0' version: 10.0.6 @@ -436,9 +433,6 @@ importers: chai: specifier: ^4.3.6 version: 4.4.1 - chai-as-promised: - specifier: ^7.1.1 - version: 7.1.1(chai@4.4.1) hardhat: specifier: 2.22.10 version: 2.22.10(ts-node@10.9.2(@types/node@20.16.1)(typescript@5.5.4))(typescript@5.5.4)