From 199aeb73127075114fd0b5cc3c401e91746f781d Mon Sep 17 00:00:00 2001 From: Harrm Date: Thu, 21 Apr 2022 18:20:40 +0300 Subject: [PATCH] Fix db editor and trie tests --- .../trie/polkadot_trie/polkadot_trie_cursor_impl.cpp | 9 +++++++-- test/core/storage/trie/polkadot_trie/CMakeLists.txt | 1 + .../storage/trie/polkadot_trie/polkadot_trie_test.cpp | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/storage/trie/polkadot_trie/polkadot_trie_cursor_impl.cpp b/core/storage/trie/polkadot_trie/polkadot_trie_cursor_impl.cpp index f159f41d51..9a3977b7b5 100644 --- a/core/storage/trie/polkadot_trie/polkadot_trie_cursor_impl.cpp +++ b/core/storage/trie/polkadot_trie/polkadot_trie_cursor_impl.cpp @@ -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(state_)) { state_ = SearchState{*trie_->getRoot()}; @@ -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(); } diff --git a/test/core/storage/trie/polkadot_trie/CMakeLists.txt b/test/core/storage/trie/polkadot_trie/CMakeLists.txt index 2c66163ac9..bbe93c2008 100644 --- a/test/core/storage/trie/polkadot_trie/CMakeLists.txt +++ b/test/core/storage/trie/polkadot_trie/CMakeLists.txt @@ -10,6 +10,7 @@ target_link_libraries(polkadot_trie_test Boost::boost trie_serializer trie_error + log_configurator ) addtest(polkadot_trie_cursor_test diff --git a/test/core/storage/trie/polkadot_trie/polkadot_trie_test.cpp b/test/core/storage/trie/polkadot_trie/polkadot_trie_test.cpp index 162b62248f..8e5b75f537 100644 --- a/test/core/storage/trie/polkadot_trie/polkadot_trie_test.cpp +++ b/test/core/storage/trie/polkadot_trie/polkadot_trie_test.cpp @@ -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" @@ -39,6 +40,8 @@ class TrieTest TrieTest() {} void SetUp() override { + testutil::prepareLoggers(soralog::Level::OFF); + trie = std::make_unique(); } @@ -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(); @@ -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); }