From da92171818f297f42b5a4633b186a7114c2d8447 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 31 May 2016 22:10:46 -0400 Subject: [PATCH] fix testnet support --- boilerplate/config/blockchain.yml | 29 +++++++++-------------------- demo/config/blockchain.yml | 1 + lib/blockchain.js | 4 ++++ lib/config/blockchain.js | 1 + test/deploy.js | 2 +- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 1599e2d3..4a94a057 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -1,49 +1,38 @@ development: rpc_host: localhost rpc_port: 8101 - mine: false - rpc_whitelist: localhost + rpc_whitelist: "*" minerthreads: 1 genesis_block: config/genesis/dev_genesis.json datadir: /tmp/embark chains: config/chains/development.json mine_when_needed: true - max_peers: 0 gas_limit: 500000 gas_price: 10000000000000 + console: false account: init: true password: config/password - num: 1 staging: + testnet: true rpc_host: localhost rpc_port: 8101 - rpc_whitelist: localhost + rpc_whitelist: "*" datadir: default - mine: false network_id: 0 - max_peers: 4 - bootnodes: - boot: false - enodes: [] #insert enode urls here. - nat: any #NAT port mapping mechanism (any|none|upnp|pmp|extip:) - port: 30303 + deploy_timeout: 45 + console: true account: init: false address: production: rpc_host: localhost rpc_port: 8101 - rpc_whitelist: localhost + rpc_whitelist: "*" datadir: default network_id: 1 - mine: false - max_peers: 4 - bootnodes: - boot: false - enodes: [] - nat: any #NAT port mapping mechanism (any|none|upnp|pmp|extip:) - port: 30303 + console: true account: init: false address: + diff --git a/demo/config/blockchain.yml b/demo/config/blockchain.yml index f2d841fa..924dc35a 100644 --- a/demo/config/blockchain.yml +++ b/demo/config/blockchain.yml @@ -14,6 +14,7 @@ development: init: true password: config/password staging: + testnet: true rpc_host: localhost rpc_port: 8101 rpc_whitelist: "*" diff --git a/lib/blockchain.js b/lib/blockchain.js index 52e54442..f2c55ae3 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -47,6 +47,10 @@ Blockchain.prototype.generate_basic_command = function() { cmd += "--datadir=\"" + config.datadir + "\" "; } + if (config.testnet) { + cmd += "--testnet "; + } + if (config.account.password !== void 0) { cmd += "--password " + config.account.password + " "; } diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index bec3d87f..6f032ee1 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -33,6 +33,7 @@ BlockchainConfig.prototype.config = function(env) { config = { + testnet: false, rpcHost: config.rpc_host, rpcPort: config.rpc_port, gasLimit: config.gas_limit || 500000, diff --git a/test/deploy.js b/test/deploy.js index ebe6ae3f..9f33ea9f 100644 --- a/test/deploy.js +++ b/test/deploy.js @@ -96,7 +96,7 @@ describe('embark.deploy', function() { result += deploy.generate_provider_file(); result += deploy.generate_abi_file(); - assert.strictEqual(result, "var web3 = new Web3();web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101'));web3.eth.defaultAccount = web3.eth.accounts[0];blockchain = {\"rpcHost\":\"localhost\",\"rpcPort\":8101,\"gasLimit\":1000000,\"gasPrice\":10000000000000,\"rpcWhitelist\":\"*\",\"nat\":[],\"minerthreads\":1,\"genesisBlock\":\"config/genesis.json\",\"datadir\":\"/tmp/embark\",\"bootNodes\":[],\"deployTimeout\":20,\"networkId\":"+deploy.blockchainConfig.networkId+",\"maxPeers\":4,\"mine\":false,\"port\":\"30303\",\"console_toggle\":false,\"mine_when_needed\":true,\"whisper\":false,\"account\":{\"init\":true,\"password\":\"config/password\"},\"geth_extra_opts\":[],\"testnet\":false,\"deploy_synchronously\":false};SimpleStorageAbi = 123;SimpleStorageContract = web3.eth.contract(SimpleStorageAbi);SimpleStorage = SimpleStorageContract.at('0x123');AnotherStorageAbi = 234;AnotherStorageContract = web3.eth.contract(AnotherStorageAbi);AnotherStorage = AnotherStorageContract.at('0x234');contractDB = {\"SimpleStorage\":{\"compiled\":{\"info\":{\"abiDefinition\":123}}},\"AnotherStorage\":{\"compiled\":{\"info\":{\"abiDefinition\":234}}}};"); + assert.strictEqual(result, "var web3 = new Web3();web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101'));web3.eth.defaultAccount = web3.eth.accounts[0];blockchain = {\"testnet\":false,\"rpcHost\":\"localhost\",\"rpcPort\":8101,\"gasLimit\":1000000,\"gasPrice\":10000000000000,\"rpcWhitelist\":\"*\",\"nat\":[],\"minerthreads\":1,\"genesisBlock\":\"config/genesis.json\",\"datadir\":\"/tmp/embark\",\"bootNodes\":[],\"deployTimeout\":20,\"networkId\":"+deploy.blockchainConfig.networkId+",\"maxPeers\":4,\"mine\":false,\"port\":\"30303\",\"console_toggle\":false,\"mine_when_needed\":true,\"whisper\":false,\"account\":{\"init\":true,\"password\":\"config/password\"},\"geth_extra_opts\":[],\"deploy_synchronously\":false};SimpleStorageAbi = 123;SimpleStorageContract = web3.eth.contract(SimpleStorageAbi);SimpleStorage = SimpleStorageContract.at('0x123');AnotherStorageAbi = 234;AnotherStorageContract = web3.eth.contract(AnotherStorageAbi);AnotherStorage = AnotherStorageContract.at('0x234');contractDB = {\"SimpleStorage\":{\"compiled\":{\"info\":{\"abiDefinition\":123}}},\"AnotherStorage\":{\"compiled\":{\"info\":{\"abiDefinition\":234}}}};"); }); }); });