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

Commit

Permalink
Merge pull request #2181 from LiskHQ/2156-cleanup-test-suit
Browse files Browse the repository at this point in the history
Cleanup tests to use "devnet" configuration files to run all tests - Closes #2156
  • Loading branch information
MaciejBaj authored Jul 3, 2018
2 parents b085749 + 9193094 commit 7d98b89
Show file tree
Hide file tree
Showing 34 changed files with 66 additions and 2,744 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def buildDependencies() {
def startLisk() {
try {
sh '''
NODE_ENV=test JENKINS_NODE_COOKIE=dontKillMe nohup node app.js -c test/data/config.json &> .app.log &
NODE_ENV=test JENKINS_NODE_COOKIE=dontKillMe nohup node app.js &> .app.log &
sleep 15
'''
} catch (err) {
Expand Down
1 change: 0 additions & 1 deletion Jenkinsfile.integration
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ node('lisk-integration') {
sudo service postgresql restart
rsync -axl -e "ssh -oUser=jenkins" master-01:/var/lib/jenkins/lisk/node_modules/ "$WORKSPACE/node_modules/" || true
npm install
cp test/data/config.json test/data/genesis_block.json .
'''
} catch (err) {
statusFail()
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ To test Lisk is built and configured correctly, issue the following command:
node app.js
```
Once the process is verified as running correctly, `CTRL+C` and start the process with `pm2`. This will fork the process into the background and automatically recover the process if it fails.
This will start the lisk instance with `devnet` configuration. Once the process is verified as running correctly, `CTRL+C` and start the process with `pm2`. This will fork the process into the background and automatically recover the process if it fails.
```
pm2 start --name lisk app.js
Expand All @@ -218,7 +218,7 @@ pm2 stop lisk
pm2 start --name lisk app.js -- -p [port] -a [address] -c [config-path] -n [network]
```
You can pass any of `devnet`, `testnet`, `betanet` or `mainnet` for the network option.
You can pass any of `devnet`, `alphanet`, `betanet`, `testnet` or `mainnet` for the network option.
## Tests
Expand All @@ -231,13 +231,7 @@ dropdb lisk_test
createdb lisk_test
```
2. Ensure Lisk is configured to run on the same local network used by the tests. Replace the files **config.json** and **genesis_block.json** with those located under the **test/data** directory:
```
cp test/data/config.json test/data/genesis_block.json .
```
3. Launch Lisk (runs on port 4000):
2. Launch Lisk (runs on port 4000):
```
NODE_ENV=test node app.js
Expand Down
2 changes: 1 addition & 1 deletion config/alphanet/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"httpPort": 4000,
"address": "0.0.0.0",
"version": "1.1.0-alpha.0",
"minVersion": ">=1.0.0-beta.9.2",
"minVersion": "1.0.0-beta.9.2",
"fileLogLevel": "debug",
"logFileName": "logs/lisk.log",
"consoleLogLevel": "info",
Expand Down
2 changes: 1 addition & 1 deletion config/betanet/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"httpPort": 5000,
"address": "0.0.0.0",
"version": "1.1.0-alpha.0",
"minVersion": ">=1.0.0-beta.9",
"minVersion": "1.0.0-beta.9",
"fileLogLevel": "debug",
"logFileName": "logs/lisk.log",
"consoleLogLevel": "error",
Expand Down
2 changes: 1 addition & 1 deletion config/devnet/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"httpPort": 4000,
"address": "0.0.0.0",
"version": "1.1.0-alpha.0",
"minVersion": ">=1.0.0-beta.9.2",
"minVersion": "1.0.0-beta.9.2",
"fileLogLevel": "debug",
"logFileName": "logs/lisk.log",
"consoleLogLevel": "info",
Expand Down
2 changes: 1 addition & 1 deletion config/mainnet/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"httpPort": 8000,
"address": "0.0.0.0",
"version": "1.1.0-alpha.0",
"minVersion": ">=0.9.5",
"minVersion": "0.9.5",
"fileLogLevel": "info",
"logFileName": "logs/lisk.log",
"consoleLogLevel": "none",
Expand Down
2 changes: 1 addition & 1 deletion config/testnet/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"httpPort": 7000,
"address": "0.0.0.0",
"version": "1.0.0-rc.0.1",
"minVersion": ">=1.0.0-rc.0.1",
"minVersion": "1.0.0-rc.0.1",
"fileLogLevel": "info",
"logFileName": "logs/lisk.log",
"consoleLogLevel": "none",
Expand Down
2 changes: 1 addition & 1 deletion modules/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ System.prototype.networkCompatible = function(nethash) {
* @todo Add description for the params and the return value
*/
System.prototype.versionCompatible = function(version) {
return semver.satisfies(version, __private.minVersion);
return semver.gte(version, __private.minVersion);
};

/**
Expand Down
3 changes: 1 addition & 2 deletions test/common/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ function __init(initScope, done) {
cb(null, __testContext.config);
},
genesisBlock(cb) {
var genesisBlock = require('../data/genesis_block.json');
cb(null, { block: genesisBlock });
cb(null, { block: __testContext.config.genesisBlock });
},

schema(cb) {
Expand Down
11 changes: 4 additions & 7 deletions test/common/modules_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
var express = require('express');
var randomstring = require('randomstring');
var async = require('async');
var config = require('../../test/data/config.json');
var Sequence = require('../../helpers/sequence.js');
var database = require('../../db');
var genesisBlock = require('../../test/data/genesis_block.json');
var Logger = require('../../logger.js');
var z_schema = require('../../helpers/z_schema.js');
var cacheHelper = require('../../helpers/cache.js');
Expand All @@ -34,13 +32,12 @@ var modulesLoader = new function() {
this.db = null;
this.logger = new Logger({
echo: null,
errorLevel: config.fileLogLevel,
filename: config.logFileName,
errorLevel: __testContext.config.fileLogLevel,
filename: __testContext.config.logFileName,
});
config.nonce = randomstring.generate(16);
this.scope = {
config,
genesisBlock: { block: genesisBlock },
config: __testContext.config,
genesisBlock: { block: __testContext.config.genesisBlock },
logger: this.logger,
network: {
app: express(),
Expand Down
6 changes: 3 additions & 3 deletions test/common/ws/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

'use strict';

const testConfig = require('../../data/config.json');
const System = require('../../../modules/system');
const connect = require('../../../api/ws/rpc/connect');
const WSServerMaster = require('./server_master');
Expand All @@ -23,6 +22,7 @@ const WSServerMaster = require('./server_master');
* WSClient
* Create a web socket client to be connected to server
*
*
* @param {object} headers - headers object to be passed a query param to client
* @constructor
*/
Expand All @@ -37,8 +37,8 @@ WSClient.prototype.start = function() {
System.setHeaders(this.headers);
this.client = connect(
{
ip: testConfig.address,
wsPort: testConfig.wsPort,
ip: __testContext.config.address,
wsPort: __testContext.config.wsPort,
},
{
trace() {},
Expand Down
5 changes: 2 additions & 3 deletions test/common/ws/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ require('../../setup'); // Ensure availability of global variables
var randomstring = require('randomstring');
var WAMPServer = require('wamp-socket-cluster/WAMPServer');
var SocketCluster = require('socketcluster');
var testConfig = require('../../data/config.json');

var wsServer = {
validNonce: randomstring.generate(16),
Expand Down Expand Up @@ -58,8 +57,8 @@ var wsServer = {
status: sinonSandbox.stub().callsArgWith(1, {
success: true,
height: 1,
broadhash: testConfig.nethash,
nonce: testConfig.nethash,
broadhash: __testContext.config.nethash,
nonce: __testContext.config.nethash,
}),
list: sinonSandbox.stub().callsArgWith(1, { peers: [] }),
blocks: sinonSandbox.stub().callsArgWith(1, { blocks: [] }),
Expand Down
6 changes: 5 additions & 1 deletion test/common/ws/server_master.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@

'use strict';

// Initialize global variables
require('../../setup');

var ChildProcess = require('child_process');
var path = require('path');
var Promise = require('bluebird');
var randomstring = require('randomstring');
var testConfig = require('../../data/config.json');
var random = require('../../common/utils/random');

var testConfig = __testContext.config;

/**
* WSServerMaster
* Create a socket server master instance with the support to spawn multiple processes
Expand Down
Loading

0 comments on commit 7d98b89

Please sign in to comment.