Skip to content

Commit

Permalink
Fix db editor and trie tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Harrm committed Apr 21, 2022
1 parent 003078b commit 199aeb7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 7 additions & 2 deletions core/storage/trie/polkadot_trie/polkadot_trie_cursor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,11 @@ namespace kagome::storage::trie {
return outcome::success();
}

SL_TRACE(log_, "Searching next key, current is {}", key().value());
if (key().has_value()) {
SL_TRACE(log_, "Searching next key, current is {}", key().value());
} else {
SL_TRACE(log_, "Searching next key, no current key");
}

if (std::holds_alternative<UninitializedState>(state_)) {
state_ = SearchState{*trie_->getRoot()};
Expand Down Expand Up @@ -339,8 +343,9 @@ namespace kagome::storage::trie {
if (not found) {
SL_TRACE(log_, "Not found anything");
state_ = ReachedEndState{};
} else {
SL_TRACE(log_, "Found {}", key().value());
}
SL_TRACE(log_, "Found {}", key().value());
return outcome::success();
}

Expand Down
1 change: 1 addition & 0 deletions test/core/storage/trie/polkadot_trie/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_link_libraries(polkadot_trie_test
Boost::boost
trie_serializer
trie_error
log_configurator
)

addtest(polkadot_trie_cursor_test
Expand Down
6 changes: 3 additions & 3 deletions test/core/storage/trie/polkadot_trie/polkadot_trie_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "storage/in_memory/in_memory_storage.hpp"
#include "storage/trie/polkadot_trie/polkadot_trie_impl.hpp"
#include "storage/trie/polkadot_trie/trie_error.hpp"
#include "testutil/prepare_loggers.hpp"
#include "testutil/literals.hpp"
#include "testutil/outcome.hpp"
#include "testutil/storage/polkadot_trie_printer.hpp"
Expand Down Expand Up @@ -39,6 +40,8 @@ class TrieTest
TrieTest() {}

void SetUp() override {
testutil::prepareLoggers(soralog::Level::OFF);

trie = std::make_unique<PolkadotTrieImpl>();
}

Expand Down Expand Up @@ -323,7 +326,6 @@ TEST_F(TrieTest, ClearPrefix) {
for (auto &entry : data) {
ASSERT_OUTCOME_SUCCESS_TRY(trie->put(entry.first, entry.second));
}
std::cout << *trie << "\n";
ASSERT_OUTCOME_SUCCESS_TRY(
trie->clearPrefix("bar"_buf, std::nullopt, [](const auto &, auto &&) {
return outcome::success();
Expand Down Expand Up @@ -394,9 +396,7 @@ TEST_P(DeleteTest, DeleteData) {
for (auto &entry : GetParam().data) {
ASSERT_OUTCOME_SUCCESS_TRY(trie->put(entry, "123"_buf));
}
std::cout << *trie << "\n==================\n";
ASSERT_OUTCOME_SUCCESS_TRY(trie->remove(GetParam().key));
std::cout << *trie << "\n==================\n";
ASSERT_EQ(size(trie->getRoot()), GetParam().size);
}

Expand Down

0 comments on commit 199aeb7

Please sign in to comment.