Fixed some tests.
This commit is contained in:
parent
07a4b706c7
commit
5ff8e7c6c1
@ -259,7 +259,11 @@ HeaderService.prototype._onHeaders = function(headers) {
|
|||||||
HeaderService.prototype._detectReorg = function() {
|
HeaderService.prototype._detectReorg = function() {
|
||||||
// is our original tip's height and hash the same after we rewound by the checkpoint amount of blocks
|
// is our original tip's height and hash the same after we rewound by the checkpoint amount of blocks
|
||||||
// and re-imported? If so, then we've reorg'ed since we've been shut down.
|
// and re-imported? If so, then we've reorg'ed since we've been shut down.
|
||||||
if (this._originalTip.hash !== this._headers.getIndex(this._originalTip.height).hash) {
|
|
||||||
|
var headerHash = this._headers.getIndex(this._originalTip.height).hash;
|
||||||
|
assert(headerHash, 'Expected a header to exist at height ' + this._originalTip.height);
|
||||||
|
|
||||||
|
if (this._originalTip.hash !== headerHash) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -285,7 +289,7 @@ HeaderService.prototype._onBestHeight = function(height) {
|
|||||||
|
|
||||||
HeaderService.prototype._startSync = function() {
|
HeaderService.prototype._startSync = function() {
|
||||||
|
|
||||||
this._numNeeded = this._bestHeight - this._tip.height;
|
this._numNeeded = Math.max(this._bestHeight - this._tip.height, this._checkpoint);
|
||||||
|
|
||||||
log.info('Header Service: Gathering: ' + this._numNeeded + ' ' + 'header(s) from the peer-to-peer network.');
|
log.info('Header Service: Gathering: ' + this._numNeeded + ' ' + 'header(s) from the peer-to-peer network.');
|
||||||
|
|
||||||
|
|||||||
@ -109,6 +109,11 @@ describe('Header Service', function() {
|
|||||||
headerService._tip = { height: 0 };
|
headerService._tip = { height: 0 };
|
||||||
headerService._originalTip = { height: 0, hash: header.hash };
|
headerService._originalTip = { height: 0, hash: header.hash };
|
||||||
headerService._bestHeight = { height: 1 };
|
headerService._bestHeight = { height: 1 };
|
||||||
|
headerService._headers = {
|
||||||
|
getIndex: function() { return { hash: header.hash }; },
|
||||||
|
getLastIndex: sinon.stub(),
|
||||||
|
set: sinon.stub()
|
||||||
|
};
|
||||||
var getChainwork = sandbox.stub(headerService, '_getChainwork').returns(new BN(1));
|
var getChainwork = sandbox.stub(headerService, '_getChainwork').returns(new BN(1));
|
||||||
var headers = [ header ];
|
var headers = [ header ];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user