ethereum / sourcify

Decentralized Solidity contract source code verification service
https://sourcify.dev
MIT License
770 stars 378 forks source link

Enable TypeScript in Monitor tests #1439

Closed manuelwedler closed 2 months ago

manuelwedler commented 2 months ago

Closes #1432

marcocastignoli commented 2 months ago

When I run the test locally using npm run test I get:

  1) Monitor
       "before each" hook for "should use default config when no config is provided":
     Error: the buffer [
  110
  112
  109
] was thrown, throw an Error :)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)

  2) Monitor
       "after each" hook for "should use default config when no config is provided":
     TypeError: Cannot read properties of undefined (reading 'pid')
      at /sourcify/services/monitor/test/hardhat-network-helper.ts:33:33
      at new Promise (<anonymous>)
      at stopHardhatNetwork (test/hardhat-network-helper.ts:32:10)
      at Context.<anonymous> (test/Monitor.spec.ts:54:29)
      at processImmediate (node:internal/timers:466:21)

When I run the tests using debugger I get:


 Exception during run: TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///sourcify/services/monitor/test/sources/Storage/1_Storage.json" needs an import assertion of type "json"
    at new NodeError (node:internal/errors:387:5)
    at validateAssertions (node:internal/modules/esm/assert:82:15)
    at defaultLoad (node:internal/modules/esm/load:84:3)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
    at async formattedImport (/sourcify/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
    at async Object.exports.requireOrImport (/sourcify/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
    at async Object.exports.loadFilesAsync (/sourcify/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/sourcify/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/sourcify/node_modules/mocha/lib/cli/run.js:370:5) {
  code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}
manuelwedler commented 2 months ago

Yeah would definitely make sense to mock it. But I also think we should not make more effort on the monitor at the moment, so merging this.