Skip to content
Snippets Groups Projects
Commit c52bf9b2 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] #909 Implicit revocation was generating a wring MINDEX

parent 3020174a
No related branches found
No related tags found
No related merge requests found
...@@ -1442,7 +1442,8 @@ const indexer = module.exports = { ...@@ -1442,7 +1442,8 @@ const indexer = module.exports = {
if (REDUCED.revokes_on <= HEAD.medianTime && !REDUCED.revoked_on) { if (REDUCED.revokes_on <= HEAD.medianTime && !REDUCED.revoked_on) {
revocations.push({ revocations.push({
op: 'UPDATE', op: 'UPDATE',
pub: MS.receiver, pub: MS.pub,
created_on: REDUCED.created_on,
written_on: [HEAD.number, HEAD.hash].join('-'), written_on: [HEAD.number, HEAD.hash].join('-'),
revoked_on: HEAD.medianTime revoked_on: HEAD.medianTime
}); });
......
"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);
}));
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment