Regtest for reorg.
This commit is contained in:
parent
11c9aa022f
commit
5b833dca89
30
test/regtest/comms.txt
Normal file
30
test/regtest/comms.txt
Normal file
@ -0,0 +1,30 @@
|
||||
[2017-08-16T13:44:43.245Z] info: Connecting to p2p network.
|
||||
client sending: magic:: 0b110907 command:: 76657273696f6e0000000000 length:: 65000000 checksum:: 735475bc message:: 7111010001000000000000004b4c945900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006e2b8235df4c158a0f2f626974636f72653a312e312e322f0000000001
|
||||
server sending: magic:: 0b110907 command:: 76657273696f6e0000000000 length:: 67000000 checksum:: 46b5c9ae
|
||||
client sending: magic:: 0b110907 command:: 76657261636b000000000000 length:: 00000000 checksum:: 5df6e0e2 message::
|
||||
server sending: magic:: 0b110907 command:: 76657261636b000000000000 length:: 00000000 checksum:: 5df6e0e2
|
||||
[2017-08-16T13:44:43.261Z] info: Connected to peer: 192.168.3.5, network: regtest, version: 70015, subversion: /Satoshi:0.14.99/, status: ready, port: 18333, best height: 1178711
|
||||
[2017-08-16T13:44:43.262Z] info: Header Service: Gathering: 2001 header(s) from the peer-to-peer network.
|
||||
[2017-08-16T13:44:43.262Z] info: Header Service: download progress: 1176710/1178711 (99.83%)
|
||||
client sending: magic:: 0b110907 command:: 676574686561646572730000 length:: 45000000 checksum:: 857caf8b message:: 7111010001145ed5b8587723d506f208c0aaf9c4d628bcba4bacd1d30f90270000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
server sending: magic:: command:: length:: checksum::
|
||||
server sending: magic:: 0b110907 command:: 616c65727400000000000000 length:: a8000000 checksum:: 1bf9aaea
|
||||
server sending: magic:: 0b110907 command:: 70696e670000000000000000 length:: 08000000 checksum:: 7c640b03
|
||||
client sending: magic:: 0b110907 command:: 706f6e670000000000000000 length:: 08000000 checksum:: 7c640b03 message:: e79ac440be90a476
|
||||
server sending: magic:: 0b110907 command:: 676574686561646572730000 length:: 25040000 checksum:: 552dc886
|
||||
server sending: magic:: command:: length:: checksum::
|
||||
server sending: magic:: 0b110907 command:: 686561646572730000000000 length:: d3780200 checksum:: 29213586
|
||||
server sending: magic:: 0b110907 command:: 686561646572730000000000 length:: d3780200 checksum:: 29213586
|
||||
server sending: magic:: 0b110907 command:: 686561646572730000000000 length:: d3780200 checksum:: 29213586
|
||||
server sending: magic:: 0b110907 command:: 686561646572730000000000 length:: d3780200 checksum:: 29213586
|
||||
server sending: magic:: command:: length:: checksum::
|
||||
[2017-08-16T13:44:43.411Z] info: Header Service: download progress: 1178710/1178711 (100.00%)
|
||||
client sending: magic:: 0b110907 command:: 676574686561646572730000 length:: 45000000 checksum:: cd33b9da message:: 71110100019f1309c60de611c5cdec7e0b24fb00da0d16fb706f1ae21a500f0000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
server sending: magic:: 0b110907 command:: 686561646572730000000000 length:: 52000000 checksum:: a4022af1
|
||||
server sending: magic:: 0b110907 command:: 686561646572730000000000 length:: 52000000 checksum:: a4022af1
|
||||
server sending: magic:: command:: length:: checksum::
|
||||
[2017-08-16T13:44:43.419Z] info: localhost-header subscribe: p2p/block total: 1
|
||||
[2017-08-16T13:44:43.419Z] info: Header Service: emitting headers to block service.
|
||||
[2017-08-16T13:44:43.419Z] info: Block Service: Gathering: 0 block(s) from the peer-to-peer network.
|
||||
[2017-08-16T13:44:43.419Z] info: Block Service: The best block hash is: 00000000000004842ea914123b8010541a41174a11ba62b244d0aec19840467c at height: 1178711
|
||||
|
||||
92
test/regtest/reorg.js
Normal file
92
test/regtest/reorg.js
Normal file
@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
|
||||
var expect = require('chai').expect;
|
||||
var sinon = require('sinon');
|
||||
var net = require('net');
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
var server;
|
||||
var headers = [];
|
||||
var blocks = [];
|
||||
var magic = new Buffer('00', 'hex'); // TODO find out what this is
|
||||
var messages = {
|
||||
verack: new Buffer('76657273696f6e0000000000', 'hex'),
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
comms path:
|
||||
|
||||
client = bitcore-node
|
||||
server = my fake server
|
||||
|
||||
client -> version
|
||||
|
||||
server -> version
|
||||
|
||||
client -> verack
|
||||
|
||||
server -> verack
|
||||
|
||||
client -> getHeaders
|
||||
|
||||
server -> headers
|
||||
|
||||
client -> ?
|
||||
|
||||
server -> ?
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
var startFakeNode = function(callback) {
|
||||
|
||||
server = net.createServer(function(socket) {
|
||||
socket.write('hi\r\n');
|
||||
socket.pipe(socket);
|
||||
});
|
||||
|
||||
server.listen(1337, '127.0.0.1');
|
||||
callback();
|
||||
};
|
||||
|
||||
|
||||
var shutdownFakeNode = function(done) {
|
||||
server.close();
|
||||
done();
|
||||
};
|
||||
|
||||
|
||||
|
||||
describe('Reorg', function() {
|
||||
// 1. spin up bitcore-node and have it connect to our custom tcp socket
|
||||
// 2. feed it a few headers
|
||||
// 3. feed it a few blocks
|
||||
// 4. feed it a block that reorgs
|
||||
|
||||
before(function(done) {
|
||||
startFakeNode(done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
shutdownFakeNode(done);
|
||||
});
|
||||
|
||||
it('should reorg correctly', function(done) {
|
||||
var client = new net.Socket();
|
||||
client.connect(1337, '127.0.0.1');
|
||||
client.on('data', function(data) {
|
||||
console.log(data.toString());
|
||||
client.destroy();
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user