From 1d54018d2e7ac08f5c78fbc1159bd2a160d07223 Mon Sep 17 00:00:00 2001 From: Joris Bontje Date: Tue, 8 Sep 2015 11:52:39 +0200 Subject: [PATCH] configurable deploy timeout per environment. fixes #63 --- demo/config/blockchain.yml | 1 + lib/config/blockchain.js | 1 + lib/deploy.js | 3 +-- test/config.blockchain.js | 3 +++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/demo/config/blockchain.yml b/demo/config/blockchain.yml index 5c17deba..f2d841fa 100644 --- a/demo/config/blockchain.yml +++ b/demo/config/blockchain.yml @@ -19,6 +19,7 @@ staging: rpc_whitelist: "*" datadir: default network_id: 0 + deploy_timeout: 45 console: true account: init: false diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index 15323a9a..d0dcdd50 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -41,6 +41,7 @@ BlockchainConfig.prototype.config = function(env) { genesisBlock: config.genesis_block, datadir: config.datadir, chains: config.chains, + deployTimeout: config.deploy_timeout || 20, networkId: networkId, maxPeers: 4, port: config.port || "30303", diff --git a/lib/deploy.js b/lib/deploy.js index e1c84709..d75f7e31 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -39,7 +39,7 @@ Deploy.prototype.deploy_contract = function(contractObject, contractParams) { while ((receipt = web3.eth.getTransactionReceipt(transactionHash)) === null || receipt.contractAddress === null) { sleep(1000); time += 1; - if (time >= 20) { + if (time >= this.blockchainConfig.deployTimeout) { return false; } } @@ -176,4 +176,3 @@ Deploy.prototype.generate_and_write_abi_file = function(destFile) { }; module.exports = Deploy; - diff --git a/test/config.blockchain.js b/test/config.blockchain.js index d9db6129..5f5cc9ff 100644 --- a/test/config.blockchain.js +++ b/test/config.blockchain.js @@ -44,6 +44,7 @@ describe('embark.config.blockchain', function() { genesis_block: 'config/genesis.json', datadir: '/tmp/embark', chains: 'chains_development.json', + deploy_timeout: 45, mine_when_needed: true, gas_limit: 123, gas_price: 100, @@ -69,6 +70,7 @@ describe('embark.config.blockchain', function() { genesisBlock: 'config/genesis.json', datadir: '/tmp/embark', chains: 'chains_development.json', + deployTimeout: 45, networkId: 0, maxPeers: 4, port: "30303", @@ -114,6 +116,7 @@ describe('embark.config.blockchain', function() { genesisBlock: undefined, datadir: '/tmp/embark', chains: undefined, + deployTimeout: 20, networkId: 0, maxPeers: 4, port: "30303",