trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 676 forks source link

Invalid `hardfork` throws unrelated error #4181

Open jeffsmale90 opened 1 year ago

jeffsmale90 commented 1 year ago

If an invalid value is provided as chain.hardfork (in programmatic usage), an unhelpful error is raised:

const server = ganache.server({ chain: { hardfork: "not-a-hardfork" } };

Will result in:

events.js:377
      throw er; // Unhandled 'error' event
      ^
Error [OpenError]: Parent database is not open
    at /Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:180046
    at /Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:1369681
    at onopen (/Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:1378217)
    at /Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:1369681
    at /Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:1369681
    at onopen (/Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:1367599)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
Emitted 'error' event on LevelUP instance at:
    at /Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:179094
    at /Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:180044
    at /Users/jeffsmale/repro/node_modules/ganache/dist/node/0.js:2:1369681
    [... lines matching original stack trace ...]
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
cliffoo commented 1 year ago

Yes the cli error is much clearer.

$ ganache -k not-valid
Invalid values:
  Argument: chain.hardfork, Given: "not-valid", Choices: "constantinople", "byzantium", "petersburg", "istanbul", "muirGlacier", "berlin", "london", "arrowGlacier", "grayGlacier"