Allow using Web3Factory in-process Ganache with existing snapshot

This commit is contained in:
Fabio Berger 2019-02-08 13:19:47 +00:00
parent ffd8349889
commit d01837f42c

View File

@ -47,9 +47,12 @@ export const web3Factory = {
_.isUndefined(config.shouldThrowErrorsOnGanacheRPCResponse) ||
config.shouldThrowErrorsOnGanacheRPCResponse;
if (!_.isUndefined(config.ganacheDatabasePath)) {
// Saving the snapshot to a local db. Ganache requires this directory to exist
const doesDatabaseAlreadyExist = fs.existsSync(config.ganacheDatabasePath);
if (!doesDatabaseAlreadyExist) {
// Working with local DB snapshot. Ganache requires this directory to exist
fs.mkdirSync(config.ganacheDatabasePath);
}
}
provider.addProvider(
new GanacheSubprovider({
vmErrorsOnRPCResponse: shouldThrowErrorsOnGanacheRPCResponse,