merkle-tools
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -80,3 +80,2 @@ /*jslint node: true */ | ||
if (leafCount > 0) { // skip this whole process if there are no leaves added to the tree | ||
var levelCount = Math.ceil(Math.log2(leafCount)) + 1; | ||
tree.levels.unshift(tree.leaves); | ||
@@ -83,0 +82,0 @@ while (tree.levels[0].length > 1) { |
{ | ||
"name": "merkle-tools", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Tools for creating merkle trees, generating merkle proofs, and verification of merkle proofs.", | ||
@@ -5,0 +5,0 @@ "main": "merkletools.js", |
@@ -84,2 +84,42 @@ var should = require('should'); | ||
describe("make tree with addLeaves hex", function () { | ||
var hashes = []; | ||
hashes.push('a292780cc748697cb499fdcc8cb89d835609f11e502281dfe3f6690b1cc23dcb'); | ||
hashes.push('cb4990b9a8936bbc137ddeb6dcab4620897b099a450ecdc5f3e86ef4b3a7135c'); | ||
var merkleTools = new merkletools(); | ||
merkleTools.addLeaves(hashes); | ||
merkleTools.makeTree(); | ||
var targetProof0 = merkleTools.getProof(0); | ||
var targetProof1 = merkleTools.getProof(1); | ||
it("merkle root value should be correct", function () { | ||
assert.equal(merkleTools.getMerkleRoot().toString('hex'), mRoot.toString('hex')); | ||
assert.equal(targetProof0.length, 1); | ||
assert.equal(targetProof1.length, 1); | ||
}); | ||
}); | ||
describe("make tree with addLeaves hex", function () { | ||
var hashes = []; | ||
hashes.push('2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'); | ||
hashes.push('2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'); | ||
var merkleTools = new merkletools(); | ||
merkleTools.addLeaves(hashes); | ||
merkleTools.makeTree(); | ||
var targetProof0 = merkleTools.getProof(0); | ||
var targetProof1 = merkleTools.getProof(1); | ||
it("merkle root value should be correct", function () { | ||
//assert.equal(merkleTools.getMerkleRoot().toString('hex'), 'e9fca0aee4dbbb93914ef2ef6e6da0df938fb0f29afe6ec5b875e1cee997a5c1'); | ||
assert.equal(targetProof0.length, 1); | ||
assert.equal(targetProof1.length, 1); | ||
}); | ||
}); | ||
describe("make tree with addLeaf buffers", function () { | ||
@@ -86,0 +126,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27324
400