fix merkle tree tool to latest web3
This commit is contained in:
parent
725b68a69e
commit
d8a60a8201
|
@ -23,12 +23,10 @@ contract('MerkleProof', function () {
|
||||||
const proof = merkleTree.getHexProof(elements[0]);
|
const proof = merkleTree.getHexProof(elements[0]);
|
||||||
|
|
||||||
const leaf = bufferToHex(sha3(elements[0]));
|
const leaf = bufferToHex(sha3(elements[0]));
|
||||||
console.log(root);
|
|
||||||
console.log(proof);
|
const result = await MerkleProofWrapper.methods.verifyProof(proof, root, leaf).call();
|
||||||
console.log(leaf);
|
|
||||||
var result = await MerkleProofWrapper.methods.verifyProof(proof, root, leaf).call();
|
assert(result);
|
||||||
console.log(result);
|
|
||||||
//assert(result, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for an invalid Merkle proof', async function () {
|
it('should return false for an invalid Merkle proof', async function () {
|
||||||
|
@ -44,9 +42,9 @@ contract('MerkleProof', function () {
|
||||||
|
|
||||||
const badProof = badMerkleTree.getHexProof(badElements[0]);
|
const badProof = badMerkleTree.getHexProof(badElements[0]);
|
||||||
|
|
||||||
var result = await MerkleProofWrapper.methods.verifyProof(badProof, correctRoot, correctLeaf).call();
|
const result = await MerkleProofWrapper.methods.verifyProof(badProof, correctRoot, correctLeaf).call();
|
||||||
console.log(result);
|
|
||||||
//assert(result, false);
|
assert(!result);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for a Merkle proof of invalid length', async function () {
|
it('should return false for a Merkle proof of invalid length', async function () {
|
||||||
|
@ -60,9 +58,9 @@ contract('MerkleProof', function () {
|
||||||
|
|
||||||
const leaf = bufferToHex(sha3(elements[0]));
|
const leaf = bufferToHex(sha3(elements[0]));
|
||||||
|
|
||||||
var result = await MerkleProofWrapper.methods.verifyProof(badProof, root, leaf).call()
|
const result = await MerkleProofWrapper.methods.verifyProof(badProof, root, leaf).call()
|
||||||
console.log(result);
|
|
||||||
//assert(result, false);
|
assert(!result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -122,7 +122,7 @@ class MerkleTree {
|
||||||
throw new Error("Array is not an array of buffers");
|
throw new Error("Array is not an array of buffers");
|
||||||
}
|
}
|
||||||
|
|
||||||
return "0x" + arr.map(el => el.toString("hex")).join("");
|
return arr.map(el => '0x' + el.toString('hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
sortAndConcat(...args) {
|
sortAndConcat(...args) {
|
||||||
|
|
Loading…
Reference in New Issue