Fix unexpected breaking change
This commit is contained in:
parent
9b880c9165
commit
fdb3cc8b75
|
@ -531,7 +531,13 @@ export class MerkleTree extends Base {
|
||||||
const proof = []
|
const proof = []
|
||||||
|
|
||||||
if (!Number.isInteger(index)) {
|
if (!Number.isInteger(index)) {
|
||||||
index = this._bufferIndexOf(this.leaves, leaf, this.sortLeaves)
|
index = -1
|
||||||
|
|
||||||
|
for (let i = 0; i < this.leaves.length; i++) {
|
||||||
|
if (Buffer.compare(leaf, this.leaves[i]) === 0) {
|
||||||
|
index = i
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index <= -1) {
|
if (index <= -1) {
|
||||||
|
|
|
@ -1291,3 +1291,13 @@ test('complete option with incompatible options', t => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('simple bad proof', t => {
|
||||||
|
t.plan(2)
|
||||||
|
|
||||||
|
const leaves = ['d', 'e', 'f']
|
||||||
|
const tree = new MerkleTree(leaves)
|
||||||
|
|
||||||
|
const proof = tree.getHexProof(leaves[0])
|
||||||
|
t.equal(proof.length, 1)
|
||||||
|
t.equal(proof[0], '0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue