Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Allow using Web3Factory in-process Ganache with existing snapshot #1602

Merged
merged 2 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/dev-utils/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "2.1.0",
"changes": [
{
"note": "Allow using the Web3Factory in-process Ganache provider with existing DB snapshot",
"pr": 1602
}
]
},
{
"version": "2.0.2",
"changes": [
Expand Down
7 changes: 5 additions & 2 deletions packages/dev-utils/src/web3_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ 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
fs.mkdirSync(config.ganacheDatabasePath);
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({
Expand Down