29TEST(stdlib_indexed_tree, can_create)
32 IndexedTree<ArrayStore, LeavesCache, HashPolicy> tree = IndexedTree<ArrayStore, LeavesCache, HashPolicy>(store, 10);
33 EXPECT_EQ(tree.size(), 1ULL);
36 EXPECT_EQ(memdb.
root(), tree.root());
39TEST(stdlib_indexed_tree, test_size)
42 auto db = IndexedTree<ArrayStore, LeavesCache, HashPolicy>(store, 32);
45 EXPECT_EQ(db.size(), 1ULL);
49 EXPECT_EQ(db.size(), 2ULL);
53 EXPECT_EQ(db.size(), 3ULL);
57 EXPECT_EQ(db.size(), 4ULL);
60TEST(stdlib_indexed_tree, test_get_hash_path)
65 auto db = IndexedTree<ArrayStore, LeavesCache, HashPolicy>(store, 10);
67 EXPECT_EQ(memdb.
root(), db.root());
72 db.add_value(VALUES[512]);
76 for (
size_t i = 0; i < 512; ++i) {
78 db.add_value(VALUES[i]);
86 const size_t batch_size = 16;
87 const size_t num_batches = 16;
92 IndexedTree<ArrayStore, LeavesCache, HashPolicy> tree1 =
93 IndexedTree<ArrayStore, LeavesCache, HashPolicy>(store1, depth, batch_size);
96 IndexedTree<ArrayStore, LeavesCache, HashPolicy> tree2 =
97 IndexedTree<ArrayStore, LeavesCache, HashPolicy>(store2, depth, batch_size);
99 EXPECT_EQ(memdb.
root(), tree1.root());
100 EXPECT_EQ(tree1.root(), tree2.root());
103 EXPECT_EQ(tree1.get_hash_path(0), tree2.get_hash_path(0));
105 EXPECT_EQ(memdb.
get_hash_path(512), tree1.get_hash_path(512));
106 EXPECT_EQ(tree1.get_hash_path(512), tree2.get_hash_path(512));
108 for (
size_t i = 0; i < num_batches; i++) {
109 std::vector<fr> batch;
111 for (
size_t j = 0; j < batch_size; j++) {
114 memory_tree_hash_paths.push_back(path);
118 EXPECT_EQ(memdb.
root(), tree1.root());
119 EXPECT_EQ(tree1.root(), tree2.root());
122 EXPECT_EQ(tree1.get_hash_path(0), tree2.get_hash_path(0));
124 EXPECT_EQ(memdb.
get_hash_path(512), tree1.get_hash_path(512));
125 EXPECT_EQ(tree1.get_hash_path(512), tree2.get_hash_path(512));
127 for (
size_t j = 0; j < batch_size; j++) {
128 EXPECT_EQ(tree1_hash_paths[j], tree2_hash_paths[j]);
153TEST(stdlib_indexed_tree, test_indexed_memory)
156 constexpr size_t depth = 3;
158 IndexedTree<ArrayStore, LeavesCache, HashPolicy> tree =
159 IndexedTree<ArrayStore, LeavesCache, HashPolicy>(store, depth, 1);
170 indexed_leaf zero_leaf = { 0, 0, 0 };
171 EXPECT_EQ(tree.size(), 1);
172 EXPECT_EQ(tree.get_leaf(0), zero_leaf);
184 EXPECT_EQ(tree.size(), 2);
198 EXPECT_EQ(tree.size(), 3);
213 EXPECT_EQ(tree.size(), 4);
237 EXPECT_EQ(tree.size(), 5);
270 EXPECT_EQ(tree.get_hash_path(0), expected);
271 EXPECT_EQ(tree.get_hash_path(1), expected);
277 EXPECT_EQ(tree.get_hash_path(2), expected2);
278 EXPECT_EQ(tree.get_hash_path(3), expected2);
279 EXPECT_EQ(tree.root(), root);
287 EXPECT_EQ(tree.get_hash_path(6), expected);
288 EXPECT_EQ(tree.get_hash_path(7), expected);
291TEST(stdlib_indexed_tree, test_indexed_tree)
294 constexpr size_t depth = 8;
296 IndexedTree<ArrayStore, LeavesCache, HashPolicy> tree =
297 IndexedTree<ArrayStore, LeavesCache, HashPolicy>(store, depth, 1);
299 indexed_leaf zero_leaf = { 0, 0, 0 };
300 EXPECT_EQ(tree.size(), 1);
304 for (
size_t i = 0; i < 20; i++) {
306 tree.add_value(
value);
320 for (
size_t i = 0; i < size_t(tree.size()); i++) {
323 differences.push_back(diff_hi + diff_lo);
326 auto index =
static_cast<size_t>(it - differences.begin());
329 auto hash_path = tree.get_hash_path(index);
void test_batch_insert(uint32_t batchSize, std::string directory, uint64_t mapSize, uint64_t maxReaders)