Skip to content
Snippets Groups Projects
Commit 94073df8 authored by inso's avatar inso
Browse files

[fix]#1029 blockstamp in raw documents incoherence

parent 9dee9797
No related branches found
No related tags found
1 merge request!1049[fix]#1029 blockstamp in raw documents incoherence
...@@ -130,6 +130,7 @@ export class PeeringService { ...@@ -130,6 +130,7 @@ export class PeeringService {
peerEntityOld.endpoints = thePeer.endpoints peerEntityOld.endpoints = thePeer.endpoints
peerEntityOld.status = thePeer.status peerEntityOld.status = thePeer.status
peerEntityOld.signature = thePeer.signature peerEntityOld.signature = thePeer.signature
peerEntityOld.blockstamp = thePeer.block
} }
// Set the peer as UP again // Set the peer as UP again
const peerEntity = peerEntityOld.toDBPeer() const peerEntity = peerEntityOld.toDBPeer()
......
"use strict";
const co = require('co');
const _ = require('underscore');
const rp = require('request-promise');
const httpTest = require('./tools/http');
const node = require('./tools/node');
const user = require('./tools/user');
const commit = require('./tools/commit');
const sync = require('./tools/sync');
const until = require('./tools/until');
const toolbox = require('./tools/toolbox');
const BlockDTO = require("../../app/lib/dto/BlockDTO");
const expectHttpCode = httpTest.expectHttpCode;
const expectAnswer = httpTest.expectAnswer;
const MEMORY_MODE = true;
const commonConf = {
ipv4: '127.0.0.1',
remoteipv4: '127.0.0.1',
currency: 'bb',
httpLogs: true,
forksize: 3,
sigQty: 1
};
const catKeyPair = {
pair: {
pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd',
sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'
}
};
const tocKeyPair = {
pair: {
pub: 'DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo',
sec: '64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F'
}
};
const s1 = toolbox.server(_.clone(catKeyPair));
const s2 = toolbox.server(_.clone(tocKeyPair));
const cat = user('cat', { pub: 'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd', sec: '51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP'}, { server: s1 });
const toc = user('toc', { pub: 'DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo', sec: '64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F'}, { server: s1 });
describe("Network updating", function() {
before(function() {
return co(function *() {
const commitS1 = commit(s1);
const commitS2 = commit(s2);
yield [s1, s2].reduce((p, server) => co(function*() {
yield p;
yield server.initDalBmaConnections()
require('../../app/modules/router').duniter.methods.routeToNetwork(server);
}), Promise.resolve());
// Server 1
yield cat.createIdentity();
yield toc.createIdentity();
yield toc.cert(cat);
yield cat.cert(toc);
yield cat.join();
yield toc.join();
for (const i in _.range(32)) {
yield commitS1(); // block#0
}
// // s2 syncs from s1
yield sync(0, 31, s1, s2);
const b2 = yield s1.makeNext({});
yield s1.postBlock(b2);
yield s2.postBlock(b2);
yield s1.recomputeSelfPeer(); // peer#1
yield s1.sharePeeringWith(s2);
const b3 = yield s1.makeNext({});
yield s1.postBlock(b3);
yield s2.postBlock(b3);
yield s1.recomputeSelfPeer(); // peer#1
yield s1.sharePeeringWith(s2);
});
});
describe("Server 1 /network/peering", function() {
it('/peers?leaf=LEAFDATA', () => co(function*() {
const data = yield s1.get('/network/peering/peers?leaves=true');
const leaf = data.leaves[0];
const res = yield s1.get('/network/peering/peers?leaf=' + leaf);
res.leaf.value.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.leaf.value.should.have.property("block").match(new RegExp('^3-'));
res.leaf.value.should.have.property("raw").match(new RegExp('.*Block: 3-.*'));
}));
});
describe("Server 2 /network/peering", function() {
it('/peers?leaf=LEAFDATA', () => co(function*() {
const data = yield s2.get('/network/peering/peers?leaves=true');
const leaf = data.leaves[0];
const res = yield s2.get('/network/peering/peers?leaf=' + leaf);
res.leaf.value.should.have.property("pubkey").equal('DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo');
res.leaf.value.should.have.property("block").match(new RegExp('^0-'));
res.leaf.value.should.have.property("raw").match(new RegExp('.*Block: 0-.*'));
}));
});
});
...@@ -100,6 +100,24 @@ describe("Peer document", function() { ...@@ -100,6 +100,24 @@ describe("Peer document", function() {
leavesCount: 1 leavesCount: 1
})); }));
it('leaf data', () => co(function*() {
const data = yield s1.get('/network/peering/peers?leaves=true');
const leaf = data.leaves[0];
const res = yield s1.get('/network/peering/peers?leaf=' + leaf);
res.leaf.value.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.leaf.value.should.have.property("block").match(new RegExp('^3-'));
res.leaf.value.should.have.property("raw").match(new RegExp('.*Block: 3-.*'));
res.leaf.value.should.have.property("endpoints").length(3);
}));
it('peers', () => s1.expectThat('/network/peering', (res) => {
res.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.should.have.property("block").match(new RegExp('^3-'));
res.should.have.property("endpoints").length(3);
}));
it('peering should have been updated by node 1', () => s1.expectThat('/network/peering', (res) => { it('peering should have been updated by node 1', () => s1.expectThat('/network/peering', (res) => {
res.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); res.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.should.have.property("block").match(new RegExp('^3-')); res.should.have.property("block").match(new RegExp('^3-'));
...@@ -118,6 +136,18 @@ describe("Peer document", function() { ...@@ -118,6 +136,18 @@ describe("Peer document", function() {
leavesCount: 1 leavesCount: 1
})); }));
it('leaf data', () => co(function*() {
const data = yield s2.get('/network/peering/peers?leaves=true');
const leaf = data.leaves[0];
const res = yield s2.get('/network/peering/peers?leaf=' + leaf);
res.leaf.value.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.leaf.value.should.have.property("block").match(new RegExp('^3-'));
res.leaf.value.should.have.property("raw").match(new RegExp('.*Block: 3-.*'));
res.leaf.value.should.have.property("endpoints").length(3);
}));
it('peering should have been updated by node 1', () => s2.expectThat('/network/peering', (res) => { it('peering should have been updated by node 1', () => s2.expectThat('/network/peering', (res) => {
res.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); res.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.should.have.property("block").match(new RegExp('^3-')); res.should.have.property("block").match(new RegExp('^3-'));
...@@ -136,6 +166,16 @@ describe("Peer document", function() { ...@@ -136,6 +166,16 @@ describe("Peer document", function() {
leavesCount: 1 leavesCount: 1
})); }));
it('leaf data', () => co(function*() {
const data = yield s3.get('/network/peering/peers?leaves=true');
const leaf = data.leaves[0];
const res = yield s3.get('/network/peering/peers?leaf=' + leaf);
res.leaf.value.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.leaf.value.should.have.property("block").match(new RegExp('^3-'));
res.leaf.value.should.have.property("raw").match(new RegExp('.*Block: 3-.*'));
res.leaf.value.should.have.property("endpoints").length(3);
}));
it('peering should have been updated by node 1', () => s3.expectThat('/network/peering', (res) => { it('peering should have been updated by node 1', () => s3.expectThat('/network/peering', (res) => {
res.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd'); res.should.have.property("pubkey").equal('HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd');
res.should.have.property("block").match(new RegExp('^3-')); res.should.have.property("block").match(new RegExp('^3-'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment