Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
restore chunking secrets between nodes in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejBaj committed Jul 25, 2017
1 parent 8c9d054 commit 60e15f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
19 changes: 17 additions & 2 deletions test/integration/peers.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -66,15 +68,22 @@ 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,
database: 'lisk_local_' + index,
peers: {
list: generateNodePeers(numOfPeers, syncMode)
},
forging: forgingNodesIndices.indexOf(index) !== -1
forging: isForging,
secrets: isForging ? secretsChunks[index] : []
};
});
}
Expand Down Expand Up @@ -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);
}
Expand Down
20 changes: 10 additions & 10 deletions test/integration/pm2.integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand All @@ -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"
},
Expand Down

0 comments on commit 60e15f5

Please sign in to comment.