@dashevo/dash-spv
Advanced tools
Comparing version 1.0.0-pr.1545.8 to 1.0.0-pr.1621.0
@@ -1,1 +0,1 @@ | ||
{"files":{".eslintignore":"5772aab4a649e8c99c5b74bd685792cd6a69f9ac",".eslintrc.json":"41aa1d3c1477f203b588dcb5c0015454edd94481",".gitignore":"095d365a56f423d4fab2345c95c137e7c6ea45c0",".mocharc.yml":"4b2c6eac5413c431a990afeec68f34c8398891ad","LICENSE":"95bf3c7cb642fb61c1bbbb319fd3c83e47a5af96","README.md":"3659fd1bfb44b5e6916679ae586ccbff18683e59","config/config.js":"267c3536b5fe54c88080a56241c34d7393a54ac2","index.js":"4413accedb71ffb73ea7ce4ad45a2035c2ce92ca","lib/blockstore.js":"1ed82a8c1cfb4bc3aa96f0669a27c94d2e76b164","lib/consensus.js":"73201c7fec9c62f5f87dba7b2d0d54c08fa4fa6f","lib/errors/SPVError.js":"08b7af972c146bcdf29ffaa06eb90ca2c5660914","lib/merkleproofs.js":"dca09952c352109795af64f9490209a96e483e2f","lib/spvchain.js":"167c1fecd83df5ae597c7af87471ec972c6b782e","lib/test/.eslintrc":"4c2b11fe8177c0c2fd0667acb599fc44c4c9741a","lib/test/bootstrap.js":"53142f9ec29cd1e75714de8a0be0080cf3bbda04","lib/utils.js":"c2119b88a67698053e783f09c038a04ae208f232","lib/x11.js":"d85e555bad579a8b3e2e92447331933ce9b0c4b1","package.json":"8ef99737c8857fc9858d013b767be0ba0e2f8fac","test/data/headers.js":"eb9cae85ee11027338fbf1f69e373d22388286d6","test/data/merkleproofs.js":"49ea4c29fb1f0cf6378ed7ee46b0a1db3bb555c1","test/data/rawHeaders.js":"03fed6ca2f8c2d1b63cfa13743431a2d551c7ad9","test/index.js":"4b67c838fadf0baac0207b13ddd99b0bc8d228c0","test/spvchain.js":"58a7716c91830e0a23bd27ab857cbba70b8bee93"},"deps":{}} | ||
{"files":{".eslintignore":"5772aab4a649e8c99c5b74bd685792cd6a69f9ac",".eslintrc.json":"41aa1d3c1477f203b588dcb5c0015454edd94481",".gitignore":"095d365a56f423d4fab2345c95c137e7c6ea45c0",".mocharc.yml":"f6d924f143da5bc22530e55dcec6922aff69d8e1","LICENSE":"95bf3c7cb642fb61c1bbbb319fd3c83e47a5af96","README.md":"3659fd1bfb44b5e6916679ae586ccbff18683e59","config/config.js":"267c3536b5fe54c88080a56241c34d7393a54ac2","index.js":"4413accedb71ffb73ea7ce4ad45a2035c2ce92ca","lib/blockstore.js":"1ed82a8c1cfb4bc3aa96f0669a27c94d2e76b164","lib/consensus.js":"73201c7fec9c62f5f87dba7b2d0d54c08fa4fa6f","lib/errors/SPVError.js":"08b7af972c146bcdf29ffaa06eb90ca2c5660914","lib/merkleproofs.js":"dca09952c352109795af64f9490209a96e483e2f","lib/spvchain.js":"4ada79dda7b544debbfc023c1ce5ad058bb0c034","lib/test/.eslintrc":"4c2b11fe8177c0c2fd0667acb599fc44c4c9741a","lib/test/bootstrap.js":"e2b2b2b17a9bf0ebff7721d8cb1e5cb75efb0f0f","lib/utils.js":"c2119b88a67698053e783f09c038a04ae208f232","lib/x11.js":"d85e555bad579a8b3e2e92447331933ce9b0c4b1","package.json":"92f5ef353e1e1417db8ee1c76e644b79764a026e","test/data/headers.js":"eb9cae85ee11027338fbf1f69e373d22388286d6","test/data/merkleproofs.js":"49ea4c29fb1f0cf6378ed7ee46b0a1db3bb555c1","test/data/rawHeaders.js":"03fed6ca2f8c2d1b63cfa13743431a2d551c7ad9","test/index.js":"4b67c838fadf0baac0207b13ddd99b0bc8d228c0","test/spvchain.js":"58a7716c91830e0a23bd27ab857cbba70b8bee93"},"deps":{}} |
@@ -345,27 +345,25 @@ const X11 = require('./x11'); | ||
const allValid = normalizedHeaders.reduce( | ||
(acc, header, index, array) => { | ||
const previousHeaders = normalizedHeaders.slice(0, index); | ||
if (index !== 0) { | ||
if (!SpvChain.isParentChild(header, array[index - 1])) { | ||
throw new SPVError(`SPV: Header ${header.hash} is not a child of ${array[index - 1].hash}`); | ||
} | ||
const allValid = normalizedHeaders.reduce((acc, header, index, array) => { | ||
const previousHeaders = normalizedHeaders.slice(0, index); | ||
if (index !== 0) { | ||
if (!SpvChain.isParentChild(header, array[index - 1])) { | ||
throw new SPVError(`SPV: Header ${header.hash} is not a child of ${array[index - 1].hash}`); | ||
} | ||
if (!this.isValid(header, previousHeaders)) { | ||
throw new SPVError(`SPV: Header ${header.hash} is invalid`); | ||
} | ||
return acc && true; | ||
if (!this.isValid(header, previousHeaders)) { | ||
throw new SPVError(`SPV: Header ${header.hash} is invalid`); | ||
} | ||
if (isOrphan) { | ||
if (!this.isValid(header, previousHeaders)) { | ||
throw new SPVError('Some headers are invalid'); | ||
} | ||
return acc && true; | ||
} | ||
if (!this.isValid(header, this.getLongestChain())) { | ||
return acc && true; | ||
} | ||
if (isOrphan) { | ||
if (!this.isValid(header, previousHeaders)) { | ||
throw new SPVError('Some headers are invalid'); | ||
} | ||
return acc && true; | ||
}, true, | ||
); | ||
} | ||
if (!this.isValid(header, this.getLongestChain())) { | ||
throw new SPVError('Some headers are invalid'); | ||
} | ||
return acc && true; | ||
}, true); | ||
if (!allValid) { | ||
@@ -372,0 +370,0 @@ throw new SPVError('Some headers are invalid'); |
const sinon = require('sinon'); | ||
beforeEach(function beforeEach() { | ||
if (!this.sinon) { | ||
this.sinon = sinon.createSandbox(); | ||
} else { | ||
exports.mochaHooks = { | ||
beforeEach() { | ||
if (!this.sinon) { | ||
this.sinon = sinon.createSandbox(); | ||
} else { | ||
this.sinon.restore(); | ||
} | ||
}, | ||
afterEach() { | ||
this.sinon.restore(); | ||
} | ||
}); | ||
before(function before() { | ||
if (!this.sinon) { | ||
this.sinon = sinon.createSandbox(); | ||
} | ||
}); | ||
afterEach(function afterEach() { | ||
this.sinon.restore(); | ||
}); | ||
}, | ||
}; |
{ | ||
"name": "@dashevo/dash-spv", | ||
"version": "1.0.0-pr.1545.8", | ||
"version": "1.0.0-pr.1621.0", | ||
"description": "Repository containing SPV functions used by @dashevo", | ||
@@ -23,10 +23,10 @@ "main": "index.js", | ||
"devDependencies": { | ||
"chai": "^4.3.9", | ||
"eslint": "^7.32.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.24.2", | ||
"mocha": "^9.1.2", | ||
"chai": "^4.3.10", | ||
"eslint": "^8.53.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.29.0", | ||
"mocha": "^10.2.0", | ||
"should": "^13.2.3", | ||
"sinon": "^11.1.2" | ||
"sinon": "^17.0.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
970261
6873