The use-case is when you have a tremendously large test-suite (i.e., a ton of tests) which takes hours on end to complete.
In such scenario, you’d want your tests to run as fast as possible.
The db: memdown() option disables all disk read/write operations in ganache, turning your tests ballistically faster.
The downside (from my observation) is that you need to run your node process (NodeJS, not the Ganache node) configured with a higher amount of memory.
For example, prior to switching to OZ test environment (when we were using Truffle directly), we had in our package.json file:
So supporting memdown on your side would need to be accompanied with --max-old-space-size=4096 in some way (or perhaps you can add that as yet another option in your test environment configuration file).
Thank you very much for your quick response, by the way.
Do I need to add all of this to the issue that you’ve opened on GitHub?
Hi @barakman, it’s not possible to customize Test Environment in this way probably because the options that you specify under node in test-environment.config.js are serialized before sending them to the Ganache subprocess.
We would have to change the way we load the config file so it is loaded in the Ganache subprocess.
We won’t have time to work on this feature for now but I’m happy to guide you through it if you’re interested in contributing it.
Hi, thank you very much.
Yes, I am interested (provided that it’s not going to be an extremely long task).
Here is my progress so far, up until I read your message (yes, I have realized that you’re serializing this object).
I can easily workaround this problem by editing file deferred-leveldown.js and adding the following line at the beginning of function DeferredLevelDOWN:
db.db = require('memdown')();
Of course, you can also declare const memdown = require('memdown'); at the beginning of the file and then add db.db = memdown(); at the beginning of the function, but that’s really just semantics.
I could add an npm-postinstall script on my end, to edit that file and “patch” it with the fix above, but this workaround is of course not guaranteed to be backward-compatible and work correctly on the next version of the OZ Test Environment.
So I’d be happy if you could guide me through on that one.
I suppose that your actual source code is in TypeScript (as I recall from previously contributing to one of your other packages - solidity-docgen), but that’s not an issue as far as I’m concerned.
Instead of sending the entire config to the subprocess as in:
We should only send accountsConfig. The rest of the values in config.node should be obtained directly in setupServer by running await import('./config'), and merged with the accounts that were received:
Side note: I had to leave coverage: config.coverage as part of the options object in order for it to compile, but I doubt that it makes any difference; I ensured that by removing this field in the corresponding compilation output (JS) file.
I also tried keeping the gasPrice field (in other words, I tried removing only the ...config.node field), but got the same results.