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

Commit

Permalink
Added intransfer tests to run on jenkins, merged conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Usman Khan committed Oct 13, 2017
2 parents 100ccd8 + 92ea21f commit 1671cdd
Show file tree
Hide file tree
Showing 51 changed files with 2,548 additions and 677 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ module.exports = function (grunt) {
},

coverageUnit: {
command: 'node_modules/.bin/istanbul cover --dir test/.coverage-unit ./node_modules/.bin/_mocha test/unit/index.js',
command: 'node test/unit/index.js',
maxBuffer: maxBufferSize
},

Expand Down
17 changes: 13 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,20 @@ lock(resource: "Lisk-Core-Nodes", inversePrecedence: true) {
},
"Functional POST tx type 0" : {
node('node-01'){
sh '''
sh """
export TEST=test/functional/http/post/0.transfer.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "$(echo $WORKSPACE | cut -f 1 -d '@')"
npm run $JENKINS_PROFILE
'''
cd "\$(echo ${env.WORKSPACE} | cut -f 1 -d '@')"
npm run ${params.JENKINS_PROFILE}
"""
}
},
"Functional POST tx type 1" : {
node('node-01'){
sh """
export TEST=test/functional/http/post/1.second.secret.js TEST_TYPE='FUNC' NODE_ENV='TEST'
cd "\$(echo ${env.WORKSPACE} | cut -f 1 -d '@')"
npm run ${params.JENKINS_PROFILE}
"""
}
},
"Functional Peers" : {
Expand Down
1 change: 1 addition & 0 deletions Jenkinsfile.integration
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ node('node-06'){
sh '''#!/bin/bash
# Cycle postgres, install deps and prepare config
sudo service postgresql restart
rsync -axl -e "ssh -oUser=jenkins" master-01:/var/lib/jenkins/lisk/node_modules/ "$WORKSPACE/node_modules/"
npm install
cp test/config.json test/genesisBlock.json .
'''
Expand Down
2 changes: 1 addition & 1 deletion logic/dapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ DApp.prototype.objectNormalize = function (trs) {
var report = library.schema.validate(trs.asset.dapp, DApp.prototype.schema);

if (!report) {
throw 'Failed to validate dapp schema: ' + this.scope.schema.getLastErrors().map(function (err) {
throw 'Failed to validate dapp schema: ' + library.schema.getLastErrors().map(function (err) {
return err.message;
}).join(', ');
}
Expand Down
2 changes: 1 addition & 1 deletion logic/multisignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Multisignature.prototype.objectNormalize = function (trs) {
var report = library.schema.validate(trs.asset.multisignature, Multisignature.prototype.schema);

if (!report) {
throw 'Failed to validate multisignature schema: ' + this.scope.schema.getLastErrors().map(function (err) {
throw 'Failed to validate multisignature schema: ' + library.schema.getLastErrors().map(function (err) {
return err.message;
}).join(', ');
}
Expand Down
2 changes: 1 addition & 1 deletion logic/outTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ OutTransfer.prototype.objectNormalize = function (trs) {
var report = library.schema.validate(trs.asset.outTransfer, OutTransfer.prototype.schema);

if (!report) {
throw 'Failed to validate outTransfer schema: ' + this.scope.schema.getLastErrors().map(function (err) {
throw 'Failed to validate outTransfer schema: ' + library.schema.getLastErrors().map(function (err) {
return err.message;
}).join(', ');
}
Expand Down
6 changes: 3 additions & 3 deletions logic/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ Transaction.prototype.ready = function (trs, sender) {
* @return {setImmediateCallback} error | row.count
*/
Transaction.prototype.countById = function (trs, cb) {
this.scope.db.one(sql.countById, { id: trs.id }).then(function (row) {
self.scope.db.one(sql.countById, {id: trs.id}).then(function (row) {
return setImmediate(cb, null, row.count);
}).catch(function (err) {
this.scope.logger.error(err.stack);
self.scope.logger.error(err.stack);
return setImmediate(cb, 'Transaction#countById error');
});
};
Expand Down Expand Up @@ -1032,7 +1032,7 @@ Transaction.prototype.objectNormalize = function (trs) {
var report = this.scope.schema.validate(trs, Transaction.prototype.schema);

if (!report) {
throw 'Failed to validate transaction schema: ' + this.scope.schema.getLastErrors().map(function (err) {
throw 'Failed to validate transaction schema: ' + self.scope.schema.getLastErrors().map(function (err) {
return err.message;
}).join(', ');
}
Expand Down
4 changes: 2 additions & 2 deletions logic/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Vote (logger, schema) {
self = this;
library = {
logger: logger,
schema: schema,
schema: schema
};

}
Expand Down Expand Up @@ -329,7 +329,7 @@ Vote.prototype.objectNormalize = function (trs) {
var report = library.schema.validate(trs.asset, Vote.prototype.schema);

if (!report) {
throw 'Failed to validate vote schema: ' + this.scope.schema.getLastErrors().map(function (err) {
throw 'Failed to validate vote schema: ' + library.schema.getLastErrors().map(function (err) {
return err.message;
}).join(', ');
}
Expand Down
1 change: 0 additions & 1 deletion modules/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ Transactions.prototype.isLoaded = function () {
Transactions.prototype.onBind = function (scope) {
modules = {
accounts: scope.accounts,
transactions: scope.transactions,
transport: scope.transport
};

Expand Down
22 changes: 21 additions & 1 deletion test/common/apiHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ function getCount (cb) {
http.get('/api/transactions/count', httpCallbackHelper.bind(null, cb));
}

function getAccounts (params, cb) {
http.get('/api/accounts?' + params, httpCallbackHelper.bind(null, cb));
}

function getPublicKey (address, cb) {
http.get('/api/accounts/getPublicKey?address=' + address, httpCallbackHelper.bind(null, cb));
}
function getBalance (address, cb) {
http.get('/api/accounts/getBalance?address=' + address, httpCallbackHelper.bind(null, cb));
}

var getTransactionPromise = node.Promise.promisify(getTransaction);
var getTransactionsPromise = node.Promise.promisify(getTransactions);
var getQueuedTransactionPromise = node.Promise.promisify(getQueuedTransaction);
Expand All @@ -83,6 +94,9 @@ var getPendingMultisignaturePromise = node.Promise.promisify(getPendingMultisign
var creditAccountPromise = node.Promise.promisify(creditAccount);
var sendSignaturePromise = node.Promise.promisify(sendSignature);
var getCountPromise = node.Promise.promisify(getCount);
var getAccountsPromise = node.Promise.promisify(getAccounts);
var getPublicKeyPromise = node.Promise.promisify(getPublicKey);
var getBalancePromise = node.Promise.promisify(getBalance);

module.exports = {
getTransaction: getTransaction,
Expand Down Expand Up @@ -111,5 +125,11 @@ module.exports = {
creditAccount: creditAccount,
creditAccountPromise: creditAccountPromise,
getCount: getCount,
getCountPromise: getCountPromise
getCountPromise: getCountPromise,
getAccounts: getAccounts,
getAccountsPromise: getAccountsPromise,
getPublicKey: getPublicKey,
getBalancePromise: getBalancePromise,
getBalance: getBalance,
getPublicKeyPromise: getPublicKeyPromise
};
35 changes: 5 additions & 30 deletions test/common/initModule.js → test/common/modulesLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var modulesLoader = new function () {
*/
this.initLogic = function (Logic, scope, cb) {
jobsQueue.jobs = {};
scope = _.assign({}, this.scope, scope);
switch (Logic.name) {
case 'Account':
new Logic(scope.db, scope.schema, scope.logger, cb);
Expand Down Expand Up @@ -119,6 +120,7 @@ var modulesLoader = new function () {
*/
this.initModule = function (Module, scope, cb) {
jobsQueue.jobs = {};
scope = _.assign({}, this.scope, scope);
return new Module(cb, scope);
};

Expand All @@ -131,12 +133,9 @@ var modulesLoader = new function () {
* @param {function} cb
*/
this.initModules = function (modules, logic, scope, cb) {
scope = _.assign({}, this.scope, scope);
async.waterfall([
function (waterCb) {
this.getDbConnection(waterCb);
}.bind(this),
function (db, waterCb) {
scope = _.merge(this.scope, {db: db}, scope);
async.reduce(logic, {}, function (memo, logicObj, mapCb) {
var name = _.keys(logicObj)[0];
return this.initLogic(logicObj[name], scope, function (err, initializedLogic) {
Expand All @@ -146,7 +145,7 @@ var modulesLoader = new function () {
}.bind(this), waterCb);
}.bind(this),
function (logic, waterCb) {
scope = _.merge(this.scope, {logic: logic}, scope);
scope = _.assign({}, this.scope, scope, {logic: logic});
async.reduce(modules, {}, function (memo, moduleObj, mapCb) {
var name = _.keys(moduleObj)[0];
return this.initModule(moduleObj[name], scope, function (err, module) {
Expand Down Expand Up @@ -196,28 +195,6 @@ var modulesLoader = new function () {
], scope || {}, cb);
};

/**
* Initializes Module class with basic conf
*
* @param {function} Module
* @param {function} cb
* @param {Object=} scope
*/
this.initModuleWithDb = function (Module, cb, scope) {
this.initWithDb(Module, this.initModule, cb, scope);
};

/**
* Initializes Logic class with basic conf
*
* @param {function} Logic
* @param {function} cb
* @param {Object=} scope
*/
this.initLogicWithDb = function (Logic, cb, scope) {
this.initWithDb(Logic, this.initLogic, cb, scope);
};

/**
* Accepts Class to invoke (Logic or Module) and fills the scope with basic conf
*
Expand Down Expand Up @@ -272,6 +249,4 @@ var modulesLoader = new function () {
};
};

module.exports = {
modulesLoader: modulesLoader
};
module.exports = modulesLoader;
9 changes: 6 additions & 3 deletions test/common/wsServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ var wsServer = {
},

necessaryRPCEndpoints: {
status: sinon.stub().callsArgWith(1, sinon.stub().callsArgWith(1, {success: true, height: 1, broadhash: testConfig.nethash, nonce: testConfig.nethash})),
list: sinon.stub().callsArgWith(1, null),
status: sinon.stub().callsArgWith(1, {success: true, height: 1, broadhash: testConfig.nethash, nonce: testConfig.nethash}),
list: sinon.stub().callsArgWith(1, {peers: []}),
blocks: sinon.stub().callsArgWith(1, {blocks: []}),
getSignatures: sinon.stub().callsArgWith(1, {signatures: []}),
getTransactions: sinon.stub().callsArgWith(1, {transactions: []}),
updateMyself: sinon.stub().callsArgWith(1, null),
postTransactions: sinon.stub().callsArgWith(1, null),
postSignatures: sinon.stub().callsArgWith(1, null),
postBlock: sinon.stub().callsArgWith(1, null),
postBlock: sinon.stub().callsArgWith(1, sinon.stub().callsArg(1)),
blocksCommon: sinon.stub().callsArgWith(1, {success: true, common: null})
},

Expand Down
Loading

0 comments on commit 1671cdd

Please sign in to comment.