From 4cd535ed13771e9d3a670aaf4dc9a3f1a8e14311 Mon Sep 17 00:00:00 2001 From: "Mark.B" Date: Fri, 5 Apr 2024 19:48:48 +0200 Subject: [PATCH] add types and also mocha config, fix errors: --- .github/workflows/ci.yml | 2 +- .mocharc.js | 16 ++++++++++++++++ hardhat.config.ts | 18 +++++++----------- package.json | 3 --- tsconfig.json | 6 ++++-- types/openzeppelin-test-helpers.d.ts | 2 ++ 6 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 .mocharc.js create mode 100644 types/openzeppelin-test-helpers.d.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d13912..d54ec1d 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: run: yarn compile - name: Test - run: yarn test + run: yarn hardhat test - name: Coverage run: yarn coverage diff --git a/.mocharc.js b/.mocharc.js new file mode 100644 index 0000000..382e128 --- /dev/null +++ b/.mocharc.js @@ -0,0 +1,16 @@ +'use strict'; +process.env.TS_NODE_FILES = true; +module.exports = { + 'allow-uncaught': true, + diff: true, + extension: ['ts'], + recursive: true, + reporter: 'spec', + require: ['ts-node/register', 'hardhat/register'], + slow: 300, + spec: 'test/**/*.test.ts', + timeout: 20000, + ui: 'bdd', + watch: false, + 'watch-files': ['src/**/*.sol', 'test/**/*.ts'], +}; diff --git a/hardhat.config.ts b/hardhat.config.ts index b78e719..e3bb661 100755 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -25,10 +25,10 @@ const accounts: string[] | { mnemonic: string } = const config: HardhatUserConfig = { namedAccounts: { deployer: 0, - admin: 1, - named_1: 2, - named_2: 3, - named_3: 4, + alice: 1, + bob: 2, + carol: 3, + other: 4, }, defaultNetwork: 'hardhat', solidity: { @@ -53,6 +53,9 @@ const config: HardhatUserConfig = { }, ], }, + mocha: { + timeout: Number.MAX_SAFE_INTEGER, + }, networks: { hardhat: { chainId: 12345, @@ -144,13 +147,6 @@ const config: HardhatUserConfig = { }, ], }, - namedAccounts: { - deployer: 0, - alice: 1, - bob: 2, - carol: 3, - other: 4, - }, paths: { sources: 'contracts', }, diff --git a/package.json b/package.json index b8715f3..75dd3c4 100755 --- a/package.json +++ b/package.json @@ -2,9 +2,6 @@ "name": "sw3", "version": "0.2.0", "description": "Contracts for Swap, Swear and Swindle.", - "directories": { - "test": "test" - }, "repository": { "type": "git", "url": "https://github.com/ethersphere/swap-swear-and-swindle.git" diff --git a/tsconfig.json b/tsconfig.json index d3ae2e3..b39cf57 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,8 +7,10 @@ "moduleResolution": "node", "forceConsistentCasingInFileNames": true, "outDir": "dist", - "resolveJsonModule": true + "resolveJsonModule": true, + "typeRoots": ["./types"], + "types": ["openzeppelin-test-helpers"] }, - "include": ["hardhat.config.ts", "./scripts", "./deploy", "./test", "./utils", "./tasks"], + "include": ["hardhat.config.ts", "./scripts", "./deploy", "./test", "./utils", "./tasks", "./types"], "exclude": ["node_modules", "**/*.spec.ts"] } diff --git a/types/openzeppelin-test-helpers.d.ts b/types/openzeppelin-test-helpers.d.ts new file mode 100644 index 0000000..8ea1fef --- /dev/null +++ b/types/openzeppelin-test-helpers.d.ts @@ -0,0 +1,2 @@ +// openzeppelin-test-helpers.d.ts +declare module '@openzeppelin/test-helpers';