- Run Ganache
- Migrate the Arc Contracts
- Terminate Ganache
- Zip the Ganache Database
- Restore Ganache Snapshot
- Start Clean
It can be very handy to run Arc.js tests or your application against a Ganache database that is a snapshot of the chain at any given point. Here's how, assuming you are running the script from your application (which is why you see "npm explore @daostack/arc.js --
" prepended to each script command).
Note that some of these instructions are very similar to what you see when not running Ganache against a database.
First you want to run Ganache with the appropriate flags that will create a database.
npm explore @daostack/arc.js -- npm start test.ganacheDb.run
Then migrate the Arc contracts review the full documentation on migrating contracts:
npm explore @daostack/arc.js -- npm start migrateContracts
To let this be your snapshot, manually in your own OS, terminate the Ganache process you spawned above. You will see it running as a "node" process.
Now zip the database for later reuse to start from this point in the chain.
npm explore @daostack/arc.js -- npm start test.ganacheDb.zip
At this point you can restart Ganache as above and it will commence from the point represented in the database.
After running against the snapshot you may want to restart it, commencing at the point at which you zipped it.
First make sure you have terminated Ganache, then unzip the database:
npm explore @daostack/arc.js -- npm start test.ganacheDb.restoreFromZip
Now when you restart ganacheDb it will be running against the previously-zipped database.
To start again fully from scratch, an empty database, you can clean out the pre-existing database. Note this can take a long time as there may be thousands of files to delete:
npm explore @daostack/arc.js -- npm start test.ganacheDb.clean