From f2b9b1f371c11e56d32cd3e3cbca25811f105168 Mon Sep 17 00:00:00 2001 From: Nikita Chebykin Date: Sat, 11 Jul 2020 14:58:40 +0200 Subject: [PATCH] Add a port number as an optional config value --- src/config.ts | 1 + src/ganache-server.ts | 2 +- src/setup-ganache.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index ef152e2..b814b41 100644 --- a/src/config.ts +++ b/src/config.ts @@ -24,6 +24,7 @@ export type Config = { allowUnlimitedContractSize?: boolean; // {url:port@blocknumber} for example http://localhost:8545@1599200 fork?: string; + port?: number; unlocked_accounts?: string[]; }; }; diff --git a/src/ganache-server.ts b/src/ganache-server.ts index b9fd6cc..2d74f78 100644 --- a/src/ganache-server.ts +++ b/src/ganache-server.ts @@ -29,7 +29,7 @@ process.once('message', (options: NodeOptions) => { // processes of test-environment may be run in parallel. // It also means however that the port (and therefore host URL) is not // available until the server finishes initialization. - server.listen(undefined, function (err: unknown) { + server.listen(options.port, function (err: unknown) { if (err) { send({ type: 'error' }); } else { diff --git a/src/setup-ganache.ts b/src/setup-ganache.ts index 26458b0..3e46a76 100644 --- a/src/setup-ganache.ts +++ b/src/setup-ganache.ts @@ -27,6 +27,7 @@ export type NodeOptions = { gasLimit?: number; allowUnlimitedContractSize?: boolean; fork?: string; + port?: number; unlocked_accounts?: string[]; };