Skip to content

Commit

Permalink
Merge pull request #16 from Adamant-im/api-test-fix
Browse files Browse the repository at this point in the history
Api test fix
  • Loading branch information
zyuhel authored Dec 14, 2018
2 parents bcc8c23 + 198bddf commit 10f12f1
Show file tree
Hide file tree
Showing 22 changed files with 3,101 additions and 2,842 deletions.
3 changes: 1 addition & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ module.exports = function (grunt) {
},

coverage: {
// command: 'export NODE_ENV=TEST && node_modules/.bin/istanbul cover --dir test/.coverage-unit ./node_modules/.bin/_mocha',
command: './node_modules/.bin/mocha test/unit/**',
command: 'export NODE_ENV=TEST && node_modules/.bin/istanbul cover --dir test/.coverage-unit ./node_modules/.bin/_mocha',
maxBuffer: maxBufferSize
},

Expand Down
4 changes: 2 additions & 2 deletions helpers/jobsQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var jobsQueue = {

register: function (name, job, time) {
if (this.jobs[name]) {
return this.jobs[name];
// throw new Error('Synchronous job ' + name + ' already registered');
// return this.jobs[name];
throw new Error('Synchronous job ' + name + ' already registered');
}

var nextJob = function () {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant",
"version": "0.4.0",
"version": "0.4.2",
"private": true,
"scripts": {
"start": "node app.js",
Expand All @@ -10,7 +10,7 @@
"fetchCoverage": "./node_modules/.bin/grunt exec:fetchCoverage --verbose",
"jsdoc": "jsdoc -c docs/conf.json --verbose --pedantic",
"server-docs": "npm run jsdoc && http-server docs/jsdoc/",
"fasttest": "./node_modules/.bin/mocha --exclude test/unit/logic/blockReward.js --exclude test/unit/sql/blockRewards.js test/unit/*"
"fasttest": "./node_modules/.bin/mocha --exclude test/unit/logic/blockReward.js --exclude test/unit/sql/blockRewards.js --exclude test/api/delegates.js --exclude test/api/peer.transactions.stress.js --exclude test/api/peer.transactions.votes.js test/unit/**/* test/api/**/*"
},
"author": "ADAMANT Tech Labs <[email protected]>, Lisk Foundation <[email protected]>, lightcurve GmbH <[email protected]>",
"license": "GPL-3.0",
Expand Down Expand Up @@ -49,7 +49,7 @@
"rimraf": "=2.5.4",
"semver": "=5.3.0",
"socket.io": "=1.7.2",
"sodium": "^2.0.3",
"sodium": "^3.0.2",
"sodium-browserify-tweetnacl": "*",
"strftime": "=0.10.0",
"valid-url": "=1.0.9",
Expand Down
4 changes: 2 additions & 2 deletions sql/delegates.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ var DelegatesSql = {
var sql = [
'WITH',
'supply AS (SELECT calcSupply((SELECT height FROM blocks ORDER BY height DESC LIMIT 1))::numeric),',
'delegates AS (SELECT row_number() OVER (ORDER BY votesWeight DESC, m."publicKey" ASC)::int AS rank,',
'delegates AS (SELECT row_number() OVER (ORDER BY m."votesWeight" DESC, m."publicKey" ASC)::int AS rank,',
'm.username,',
'm.address,',
'ENCODE(m."publicKey", \'hex\') AS "publicKey",',
'm.vote,',
'm.votesWeight,',
'm."votesWeight",',
'm.producedblocks,',
'm.missedblocks,',
'ROUND(vote / (SELECT * FROM supply) * 100, 2)::float AS approval,',
Expand Down
8 changes: 4 additions & 4 deletions test/api/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('POST /api/accounts/open', function () {
node.expect(res.body.account).to.have.property('address').to.equal(account.address);
node.expect(res.body.account).to.have.property('unconfirmedBalance').that.is.a('string');
node.expect(res.body.account).to.have.property('balance').that.is.a('string');
node.expect(res.body.account).to.have.property('publicKey').to.equal(account.publicKey);
node.expect(res.body.account).to.have.property('publicKey').to.equal(account.publicKey.toString('hex'));
node.expect(res.body.account).to.have.property('unconfirmedSignature').to.equal(0);
node.expect(res.body.account).to.have.property('secondSignature').to.equal(0);
node.expect(res.body.account).to.have.property('secondPublicKey').to.equal(null);
Expand Down Expand Up @@ -197,7 +197,7 @@ describe('POST /api/accounts/generatePublicKey', function () {
secret: account.password
}, function (err, res) {
node.expect(res.body).to.have.property('success').to.be.ok;
node.expect(res.body).to.have.property('publicKey').to.equal(account.publicKey);
node.expect(res.body).to.have.property('publicKey').to.equal(account.publicKey.toString('hex'));
done();
});
});
Expand Down Expand Up @@ -341,7 +341,7 @@ describe('GET /accounts', function () {
});

it('using unknown publicKey should fail', function (done) {
getAccounts('publicKey=' + account.publicKey, function (err, res) {
getAccounts('publicKey=' + account.publicKey.toString('hex'), function (err, res) {
node.expect(res.body).to.have.property('success').to.be.not.ok;
node.expect(res.body).to.have.property('error').to.eql('Account not found');
done();
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('GET /accounts', function () {
});

it('using known address and not matching publicKey should fail', function (done) {
getAccounts('address=' + node.gAccount.address + '&publicKey=' + account.publicKey, function (err, res) {
getAccounts('address=' + node.gAccount.address + '&publicKey=' + account.publicKey.toString('hex'), function (err, res) {
node.expect(res.body).to.have.property('success').to.be.not.ok;
node.expect(res.body).to.have.property('error');
node.expect(res.body.error).to.contain('Account publicKey does not match address');
Expand Down
Loading

0 comments on commit 10f12f1

Please sign in to comment.