From c52bf9b2e1e462b5833b8e92542b37c32648f010 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Mon, 27 Mar 2017 08:12:59 +0200 Subject: [PATCH] [fix] #909 Implicit revocation was generating a wring MINDEX --- app/lib/dup/indexer.js | 3 +- .../identity-implicit-revocation.js | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 test/integration/identity-implicit-revocation.js diff --git a/app/lib/dup/indexer.js b/app/lib/dup/indexer.js index c5aead1e7..7fa873834 100644 --- a/app/lib/dup/indexer.js +++ b/app/lib/dup/indexer.js @@ -1442,7 +1442,8 @@ const indexer = module.exports = { if (REDUCED.revokes_on <= HEAD.medianTime && !REDUCED.revoked_on) { revocations.push({ op: 'UPDATE', - pub: MS.receiver, + pub: MS.pub, + created_on: REDUCED.created_on, written_on: [HEAD.number, HEAD.hash].join('-'), revoked_on: HEAD.medianTime }); diff --git a/test/integration/identity-implicit-revocation.js b/test/integration/identity-implicit-revocation.js new file mode 100644 index 000000000..72beb50da --- /dev/null +++ b/test/integration/identity-implicit-revocation.js @@ -0,0 +1,78 @@ +"use strict"; + +const _ = require('underscore'); +const co = require('co'); +const assert = require('assert'); +const should = require('should'); +const duniter = require('../../index'); +const bma = require('duniter-bma').duniter.methods.bma; +const user = require('./tools/user'); +const constants = require('../../app/lib/constants'); +const toolbox = require('./tools/toolbox'); + +const now = 1480000000; + +const s1 = toolbox.server({ + pair: { + pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', + sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP' + }, + sigValidity: 100, + msValidity: 10, + sigQty: 1, + medianTimeBlocks: 1 +}); + +const cat = user('cat', { pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'}, { server: s1 }); +const tac = user('tac', { pub: '2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc', sec: '2HuRLWgKgED1bVio1tdpeXrf7zuUszv1yPHDsDj7kcMC4rVSN9RC58ogjtKNfTbH1eFz7rn38U1PywNs3m6Q7UxE'}, { server: s1 }); +const tic = user('tic', { pub: 'DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV', sec: '468Q1XtTq7h84NorZdWBZFJrGkB18CbmbHr9tkp9snt5GiERP7ySs3wM8myLccbAAGejgMRC9rqnXuW3iAfZACm7'}, { server: s1 }); + +describe("Implicit revocation", function() { + + before(() => co(function *() { + yield s1.initWithDAL().then(bma).then((bmapi) => bmapi.openConnections()); + yield cat.createIdentity(); + yield tac.createIdentity(); + yield tic.createIdentity(); + yield cat.cert(tac); + yield tac.cert(tic); + yield tic.cert(cat); + yield cat.join(); + yield tac.join(); + yield tic.join(); + yield s1.commit({ time: now }); + yield s1.commit({ time: now + 8 }); + yield s1.commit({ time: now + 9 }); + yield cat.join(); + yield tac.join(); + yield s1.commit({ time: now + 10 }); + yield s1.commit({ time: now + 10 }); + yield s1.commit({ time: now + 11 }); + yield s1.commit({ time: now + 15 }); + yield s1.commit({ time: now + 15 }); + yield cat.join(); + yield tac.join(); + yield s1.commit({ time: now + 20 }); + yield s1.commit({ time: now + 20 }); + })); + + it('block#4 should have kicked tic', () => s1.expectThat('/blockchain/block/5', (res) => { + assert.deepEqual(res.excluded, [ + 'DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV' + ]); + })); + + it('should exist implicit revocation traces', () => co(function*() { + const ms = yield s1.dal.mindexDAL.getReducedMS('DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV') + ms.should.have.property('revoked_on').equal(1480000020) + })); + + it('should answer that tic is revoked on API', () => s1.expectThat('/wot/lookup/tic', (res) => { + res.should.have.property('results').length(1); + res.results[0].should.have.property('uids').length(1); + res.results[0].uids[0].should.have.property('uid').equal('tic'); + res.results[0].uids[0].should.have.property('revoked').equal(true); + res.results[0].uids[0].should.have.property('revoked_on').equal(1480000020); + res.results[0].uids[0].should.have.property('revocation_sig').equal(null); + })); +}); -- GitLab