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) || _.isUndefined(config.shouldThrowErrorsOnGanacheRPCResponse) ||
config.shouldThrowErrorsOnGanacheRPCResponse; config.shouldThrowErrorsOnGanacheRPCResponse;
if (!_.isUndefined(config.ganacheDatabasePath)) { 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); fs.mkdirSync(config.ganacheDatabasePath);
} }
}
provider.addProvider( provider.addProvider(
new GanacheSubprovider({ new GanacheSubprovider({
vmErrorsOnRPCResponse: shouldThrowErrorsOnGanacheRPCResponse, vmErrorsOnRPCResponse: shouldThrowErrorsOnGanacheRPCResponse,