diff --git a/test/integration/peers.integration.js b/test/integration/peers.integration.js index 3f924f32380..8f57988f817 100644 --- a/test/integration/peers.integration.js +++ b/test/integration/peers.integration.js @@ -12,6 +12,8 @@ var WAMPClient = require('wamp-socket-cluster/WAMPClient'); var child_process = require('child_process'); var waitUntilBlockchainReady = require('../common/globalBefore').waitUntilBlockchainReady; +var baseConfig = require('../../test/config.json'); + var SYNC_MODE = { RANDOM: 0, ALL_TO_FIRST: 1, @@ -66,7 +68,13 @@ function generateNodePeers (numOfPeers, syncMode, syncModeArgs) { } function generateNodesConfig (numOfPeers, syncMode, forgingNodesIndices) { + var secretsInChunk = Math.ceil(baseConfig.forging.secret.length / forgingNodesIndices.length); + var secretsChunks = Array.apply(null, new Array(forgingNodesIndices.length)).map(function (val, index) { + return baseConfig.forging.secret.slice(index * secretsInChunk, (index + 1) * secretsInChunk); + }); + return Array.apply(null, new Array(numOfPeers)).map(function (val, index) { + var isForging = forgingNodesIndices.indexOf(index) !== -1; return { ip: '127.0.0.1', port: 5000 + index, @@ -74,7 +82,8 @@ function generateNodesConfig (numOfPeers, syncMode, forgingNodesIndices) { peers: { list: generateNodePeers(numOfPeers, syncMode) }, - forging: forgingNodesIndices.indexOf(index) !== -1 + forging: isForging, + secrets: isForging ? secretsChunks[index] : [] }; }); } @@ -110,7 +119,13 @@ function generatePM2NodesConfig (testNodeConfigs) { }; if (!nodeConfig.forging) { - nodePM2Config.args += ' -c ./test/integration/config.non-forge.json'; + nodePM2Config.args += ' -c ./test/integration/configs/config.non-forge.json'; + } else { + var currentNodeConfig = _.clone(baseConfig); + currentNodeConfig.forging.force = false; + currentNodeConfig.forging.secret = nodeConfig.secrets; + fs.writeFileSync(__dirname + '/configs/config.node-' + index + '.json', JSON.stringify(currentNodeConfig, null, 4)); + nodePM2Config.args += ' -c ./test/integration/configs/config.node-' + index + '.json'; } pm2Config.apps.push(nodePM2Config); } diff --git a/test/integration/pm2.integration.json b/test/integration/pm2.integration.json index aed4c96d2a5..d1a220ae405 100644 --- a/test/integration/pm2.integration.json +++ b/test/integration/pm2.integration.json @@ -4,7 +4,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_0", - "args": " -p 5000 -h 4000 -x 127.0.0.1:5001 -d lisk_local_0", + "args": " -p 5000 -h 4000 -x 127.0.0.1:5001 -d lisk_local_0 -c ./test/integration/configs/config.node-0.json", "env": { "NODE_ENV": "test" }, @@ -15,7 +15,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_1", - "args": " -p 5001 -h 4001 -x 127.0.0.1:5001 -d lisk_local_1", + "args": " -p 5001 -h 4001 -x 127.0.0.1:5001 -d lisk_local_1 -c ./test/integration/configs/config.node-1.json", "env": { "NODE_ENV": "test" }, @@ -26,7 +26,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_2", - "args": " -p 5002 -h 4002 -x 127.0.0.1:5001 -d lisk_local_2", + "args": " -p 5002 -h 4002 -x 127.0.0.1:5001 -d lisk_local_2 -c ./test/integration/configs/config.node-2.json", "env": { "NODE_ENV": "test" }, @@ -37,7 +37,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_3", - "args": " -p 5003 -h 4003 -x 127.0.0.1:5001 -d lisk_local_3", + "args": " -p 5003 -h 4003 -x 127.0.0.1:5001 -d lisk_local_3 -c ./test/integration/configs/config.node-3.json", "env": { "NODE_ENV": "test" }, @@ -48,7 +48,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_4", - "args": " -p 5004 -h 4004 -x 127.0.0.1:5001 -d lisk_local_4", + "args": " -p 5004 -h 4004 -x 127.0.0.1:5001 -d lisk_local_4 -c ./test/integration/configs/config.node-4.json", "env": { "NODE_ENV": "test" }, @@ -59,7 +59,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_5", - "args": " -p 5005 -h 4005 -x 127.0.0.1:5001 -d lisk_local_5", + "args": " -p 5005 -h 4005 -x 127.0.0.1:5001 -d lisk_local_5 -c ./test/integration/configs/config.node-5.json", "env": { "NODE_ENV": "test" }, @@ -70,7 +70,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_6", - "args": " -p 5006 -h 4006 -x 127.0.0.1:5001 -d lisk_local_6", + "args": " -p 5006 -h 4006 -x 127.0.0.1:5001 -d lisk_local_6 -c ./test/integration/configs/config.node-6.json", "env": { "NODE_ENV": "test" }, @@ -81,7 +81,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_7", - "args": " -p 5007 -h 4007 -x 127.0.0.1:5001 -d lisk_local_7", + "args": " -p 5007 -h 4007 -x 127.0.0.1:5001 -d lisk_local_7 -c ./test/integration/configs/config.node-7.json", "env": { "NODE_ENV": "test" }, @@ -92,7 +92,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_8", - "args": " -p 5008 -h 4008 -x 127.0.0.1:5001 -d lisk_local_8", + "args": " -p 5008 -h 4008 -x 127.0.0.1:5001 -d lisk_local_8 -c ./test/integration/configs/config.node-8.json", "env": { "NODE_ENV": "test" }, @@ -103,7 +103,7 @@ "exec_mode": "fork", "script": "app.js", "name": "node_9", - "args": " -p 5009 -h 4009 -x 127.0.0.1:5001 -d lisk_local_9", + "args": " -p 5009 -h 4009 -x 127.0.0.1:5001 -d lisk_local_9 -c ./test/integration/configs/config.node-9.json", "env": { "NODE_ENV": "test" },