def _test_partial(num_entries: int, step: int = 1) -> None: """ Take the first 'num_entries' from TEST_VALUES. Cut them at each possible place and submit them as two halves to the contract, receiving back the root for the updated tree. """ leaves = TEST_VALUES[:num_entries] mktree = MerkleTree.empty_with_depth(ZETH_MERKLE_TREE_DEPTH) for leaf in leaves: mktree.insert(leaf) expected_root = mktree.recompute_root() for cut in range(0, num_entries + 1, step): print(f"_test_partial: num_entries={num_entries}, cut={cut}") first = leaves[:cut] second = leaves[cut:] root = contract.functions.testAddLeaves(first, second).call() assert_root(expected_root, root, f"num_entries: {num_entries}, cut: {cut}: ")
def test_tree_empty(contract: Any) -> None: mktree = MerkleTree.empty_with_depth(ZETH_MERKLE_TREE_DEPTH) expected_root = mktree.recompute_root() root = contract.functions.testAddLeaves([], []).call() assert_root(expected_root, root, "test_tree_empty")