all files / contracts/test/ MerkleTreeTest.sol

100% Statements 8/8
100% Branches 0/0
100% Functions 7/7
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                            15× 15× 15×       160×       722×       566×       160×       722×       566×      
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
 
import {LazyMerkleTree, LazyTreeData} from '../libraries/LazyMerkleTree.sol';
import {ReusableMerkleTree, ReusableTreeData} from '../libraries/ReusableMerkleTree.sol';
 
import 'hardhat/console.sol';
 
contract MerkleTreeTest {
    LazyTreeData data;
    ReusableTreeData data0;
    uint8 depth;
 
    constructor(uint8 _depth) {
        depth = _depth;
        LazyMerkleTree.init(data, uint8(_depth));
        ReusableMerkleTree.init(data0, _depth);
    }
 
    function insertLazy(uint256 leaf) public {
        LazyMerkleTree.insert(data, leaf);
    }
 
    function rootLazy() public view returns (uint256) {
        return LazyMerkleTree.root(data, depth);
    }
 
    function updateLazy(uint256 leaf, uint40 index) public {
        LazyMerkleTree.update(data, leaf, index);
    }
 
    function insertReusable(uint256 leaf) public {
        ReusableMerkleTree.insert(data0, leaf);
    }
 
    function rootReusable() public view returns (uint256) {
        return data0.root;
    }
 
    function updateReusable(uint256 leaf, uint256 index) public {
        ReusableMerkleTree.update(data0, leaf, index);
    }
}