diff --git a/app/lib/dup/indexer.js b/app/lib/dup/indexer.js index c5aead1e75c3da87a75e11f19ae3271612d3e159..7fa8738348f1d725b702afcdf13c767c7c9dcb4a 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 0000000000000000000000000000000000000000..72beb50da9d14992558093ccb317b57338603a90 --- /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); + })); +});