Open CT-Smyth opened 4 years ago
ganache-core
has the db_path
option, and ganache-cli
has the --db
flag. You can specify a path to save the chain database.
For Ganache UI, Quickstart creates a cleanroom, whereas saved Workspaces persist.
Do these features fulfill your request?
Expected Behavior
Should have a command switch to suppress "cleanroom" behavior which erases blockchain state between tests.
Current Behavior
Currently, blockchain state is reset between tests. This is desirable behavior for the majority of testing conditions, but testing requirements for complex systems can result in tens of thousands of lines of code in a single testing file, as state evolution on-chain must be tracked. If separate tests could be scripted while maintaining chain state, more complex scenarios could be modeled with smaller, factored testing files.
Possible Solution
Add a command switch in the testing script language to suppress the reinitialization of the ganache (or other) blockchain when running tests.
Context
Our project uses a network of 40+ closely linked contracts with segregated silos for the required on-chain state and status storage of tokenized information. Although we can (and do) create modular unit tests for each function that each includes the 180+ steps required for full fresh contract deployment and test initialization, Gaming out real-world scenarios require much more complex interactions to create the state conditions we must test for. Our system creates a state history and that state history influences the permissible behavior in a complex system of interacting historical and present parameters.
This issue is causing our team to have to manage ridiculously large testing files, incrementally increasing the possibility of mistakes while exponentially increasing the complexity of finding and fixing them.
Currently, we have a suite of 380 unit test files for 479 functions within 47 contracts. Our scenario testing files are currently 70k + LOC each, and we'd really like to be able to factor them out into smaller incremental modules, each building on state created from previous passing tests.
Thanks for taking the time to review this feature request, hopefully, it will be simple to implement.