fix leaf count

This commit is contained in:
Alexey 2019-09-11 11:17:32 +03:00
parent 3f4e686899
commit 3404acef48
2 changed files with 2 additions and 2 deletions

View File

@ -58,7 +58,7 @@ contract MerkleTreeWithHistory {
function _insert(uint256 leaf) internal {
uint32 current_index = next_index;
require(current_index != 2**levels, "Merkle tree is full");
require(current_index != 2**(levels - 1), "Merkle tree is full");
next_index += 1;
uint256 current_level_hash = leaf;
uint256 left;

View File

@ -180,7 +180,7 @@ contract('MerkleTreeWithHistory', accounts => {
zeroValue = 1337
merkleTreeWithHistory = await MerkleTreeWithHistory.new(levels, zeroValue)
for (let i = 0; i < 2**levels; i++) {
for (let i = 0; i < 2**(levels - 1); i++) {
await merkleTreeWithHistory.insert(i+42).should.be.fulfilled
}