aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio B <kandinsky454@protonmail.ch>2019-02-09 01:49:33 +0800
committerGitHub <noreply@github.com>2019-02-09 01:49:33 +0800
commitffdaec9f9fa68c500ceabf6565640ba6549a9fba (patch)
treea0501ca97c1e186cd6086ae385c03edff61b66fa
parentffd8349889cb27613364a423f1b0f5b87bb26099 (diff)
parentc794153221af10446e3a9316037451fa1c6dbfdb (diff)
downloaddexon-0x-contracts-ffdaec9f9fa68c500ceabf6565640ba6549a9fba.tar.gz
dexon-0x-contracts-ffdaec9f9fa68c500ceabf6565640ba6549a9fba.tar.zst
dexon-0x-contracts-ffdaec9f9fa68c500ceabf6565640ba6549a9fba.zip
Merge pull request #1602 from 0xProject/feat/allow_using_existing_ganache_snapshot
Allow using Web3Factory in-process Ganache with existing snapshot
-rw-r--r--packages/dev-utils/CHANGELOG.json9
-rw-r--r--packages/dev-utils/src/web3_factory.ts7
2 files changed, 14 insertions, 2 deletions
diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json
index ce6cfede5..cbeb2e74f 100644
--- a/packages/dev-utils/CHANGELOG.json
+++ b/packages/dev-utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "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": [
{
diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts
index 5f8981a46..3fa3c19f7 100644
--- a/packages/dev-utils/src/web3_factory.ts
+++ b/packages/dev-utils/src/web3_factory.ts
@@ -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({