diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake index 9a6fc5131e..47ac26a223 100644 --- a/cmake/Hunter/config.cmake +++ b/cmake/Hunter/config.cmake @@ -27,26 +27,26 @@ hunter_config( hunter_config( benchmark - URL https://github.com/google/benchmark/archive/refs/tags/v1.7.1.zip - SHA1 988246a257b0eeb1a8b112cff6ab3edfbe162912 + URL https://github.com/google/benchmark/archive/refs/tags/v1.8.3.zip + SHA1 bf9870756ee3f8d2d3b346b24ee3600a41c74d3d CMAKE_ARGS BENCHMARK_ENABLE_TESTING=OFF ) hunter_config( soralog - VERSION 0.2.2 + VERSION 0.2.3 KEEP_PACKAGE_SOURCES ) hunter_config( libp2p - VERSION 0.1.18 + VERSION 0.1.19 KEEP_PACKAGE_SOURCES ) hunter_config( rocksdb - VERSION 8.0.0 + VERSION 9.0.0 CMAKE_ARGS WITH_GFLAGS=OFF ) diff --git a/cmake/Hunter/hunter-gate-url.cmake b/cmake/Hunter/hunter-gate-url.cmake index d2c8c4ec20..c92ff5b0b7 100644 --- a/cmake/Hunter/hunter-gate-url.cmake +++ b/cmake/Hunter/hunter-gate-url.cmake @@ -1,5 +1,5 @@ HunterGate( - URL https://github.com/qdrvm/hunter/archive/refs/tags/v0.25.3-qdrvm5.zip - SHA1 ae75fdf1850bd21dead239b8580012b6091be855 + URL https://github.com/qdrvm/hunter/archive/refs/tags/v0.25.3-qdrvm7.zip + SHA1 be5869134ef7448fe2420d60dbb9706596b1b8bd LOCAL ) diff --git a/core/network/helpers/stream_proxy_base.hpp b/core/network/helpers/stream_proxy_base.hpp index 13eac061fa..44f16f09ae 100644 --- a/core/network/helpers/stream_proxy_base.hpp +++ b/core/network/helpers/stream_proxy_base.hpp @@ -30,9 +30,6 @@ namespace libp2p::connection { stream->deferReadCallback(res, std::move(cb)); } - void write(BytesIn in, size_t bytes, WriteCallbackFunc cb) override { - stream->write(in, bytes, std::move(cb)); - } void writeSome(BytesIn in, size_t bytes, WriteCallbackFunc cb) override { stream->writeSome(in, bytes, std::move(cb)); } diff --git a/core/network/helpers/stream_read_buffer.hpp b/core/network/helpers/stream_read_buffer.hpp index 861023bc4b..789a0e2766 100644 --- a/core/network/helpers/stream_read_buffer.hpp +++ b/core/network/helpers/stream_read_buffer.hpp @@ -10,6 +10,10 @@ #include #include +#include +#include + +#include "log/logger.hpp" namespace libp2p::connection { /** @@ -99,73 +103,78 @@ namespace kagome::network { StreamWrapper(std::shared_ptr stream) : stream_{std::move(stream)} {} - bool isClosedForRead() const { + bool isClosedForRead() const override { return stream_->isClosedForRead(); } - bool isClosedForWrite() const { + bool isClosedForWrite() const override { return stream_->isClosedForWrite(); } - bool isClosed() const { + bool isClosed() const override { return stream_->isClosed(); } - void close(VoidResultHandlerFunc cb) { + void close(VoidResultHandlerFunc cb) override { check(); stream_->close(std::move(cb)); } - void reset() { + void reset() override { check(); stream_->reset(); } - void adjustWindowSize(uint32_t new_size, VoidResultHandlerFunc cb) { + void adjustWindowSize(uint32_t new_size, + VoidResultHandlerFunc cb) override { stream_->adjustWindowSize(new_size, std::move(cb)); } - outcome::result isInitiator() const { + outcome::result isInitiator() const override { return stream_->isInitiator(); } - outcome::result remotePeerId() const { + outcome::result remotePeerId() const override { return stream_->remotePeerId(); } - outcome::result localMultiaddr() const { + outcome::result localMultiaddr() + const override { return stream_->localMultiaddr(); } - outcome::result remoteMultiaddr() const { + outcome::result remoteMultiaddr() + const override { return stream_->remoteMultiaddr(); } - void read(libp2p::BytesOut out, size_t bytes, ReadCallbackFunc cb) { + void read(libp2p::BytesOut out, + size_t bytes, + ReadCallbackFunc cb) override { check(); stream_->read(out, bytes, std::move(cb)); } - void readSome(libp2p::BytesOut out, size_t bytes, ReadCallbackFunc cb) { + void readSome(libp2p::BytesOut out, + size_t bytes, + ReadCallbackFunc cb) override { check(); stream_->readSome(out, bytes, std::move(cb)); } - void deferReadCallback(outcome::result res, ReadCallbackFunc cb) { + void deferReadCallback(outcome::result res, + ReadCallbackFunc cb) override { stream_->deferReadCallback(std::move(res), std::move(cb)); } - void write(libp2p::BytesIn in, size_t bytes, WriteCallbackFunc cb) { - check(); - stream_->write(in, bytes, std::move(cb)); - } - - void writeSome(libp2p::BytesIn in, size_t bytes, WriteCallbackFunc cb) { + void writeSome(libp2p::BytesIn in, + size_t bytes, + WriteCallbackFunc cb) override { check(); stream_->writeSome(in, bytes, std::move(cb)); } - void deferWriteCallback(std::error_code ec, WriteCallbackFunc cb) { + void deferWriteCallback(std::error_code ec, WriteCallbackFunc cb) override { stream_->deferWriteCallback(ec, std::move(cb)); } }; diff --git a/core/network/impl/protocols/protocol_base_impl.hpp b/core/network/impl/protocols/protocol_base_impl.hpp index 252ee74804..26aa79ce7b 100644 --- a/core/network/impl/protocols/protocol_base_impl.hpp +++ b/core/network/impl/protocols/protocol_base_impl.hpp @@ -49,7 +49,8 @@ namespace kagome::network { bool start(std::weak_ptr wp) { host_.setProtocolHandler( protocols_, - [wp = std::move(wp), log = logger()](auto &&stream_and_proto) { + [wp = std::move(wp), + log = logger()](libp2p::StreamAndProtocol stream_and_proto) { if (auto self = wp.lock()) { BOOST_ASSERT(stream_and_proto.stream); @@ -62,7 +63,7 @@ namespace kagome::network { SL_TRACE(log, "Handled {} protocol stream from {}", protocol, - peer_id); + peer_id.error()); BOOST_ASSERT(stream); self->onIncomingStream(std::move(stream)); return; diff --git a/core/network/notifications/wait_read_close.hpp b/core/network/notifications/wait_read_close.hpp index 4053480d28..361fb27b5f 100644 --- a/core/network/notifications/wait_read_close.hpp +++ b/core/network/notifications/wait_read_close.hpp @@ -13,12 +13,12 @@ namespace kagome::network::notifications { inline void waitReadClose(std::shared_ptr stream) { auto buf = std::make_shared>(1); - auto cb = [stream, buf](libp2p::outcome::result r) { + auto cb = [stream, buf](outcome::result r) { if (r) { stream->reset(); return; } - stream->close([](libp2p::outcome::result) {}); + stream->close([](outcome::result) {}); }; stream->read(*buf, buf->size(), std::move(cb)); } diff --git a/core/outcome/into.hpp b/core/outcome/into.hpp index 7596139cdb..724d721d2e 100644 --- a/core/outcome/into.hpp +++ b/core/outcome/into.hpp @@ -12,13 +12,13 @@ namespace outcome { /// Wraps value or returns original result template struct Into { - static outcome::result into(T &&r) { - return outcome::success(std::move(r)); + static result into(T &&r) { + return success(std::move(r)); } }; template - struct Into> { - static outcome::result into(outcome::result &&r) { + struct Into> { + static result into(result &&r) { return std::move(r); } }; diff --git a/core/outcome/outcome.hpp b/core/outcome/outcome.hpp index e14339ee26..992d68ecad 100644 --- a/core/outcome/outcome.hpp +++ b/core/outcome/outcome.hpp @@ -7,9 +7,3 @@ #pragma once #include - -namespace outcome { - using libp2p::outcome::failure; - using libp2p::outcome::result; - using libp2p::outcome::success; -} // namespace outcome diff --git a/test/core/injector/CMakeLists.txt b/test/core/injector/CMakeLists.txt index 78232570ea..0a7333a8a0 100644 --- a/test/core/injector/CMakeLists.txt +++ b/test/core/injector/CMakeLists.txt @@ -7,4 +7,5 @@ addtest(application_injector_test application_injector_test.cpp) target_link_libraries(application_injector_test application_injector + base_fs_test ) diff --git a/test/core/injector/application_injector_test.cpp b/test/core/injector/application_injector_test.cpp index 3ef88a4201..0404d645f3 100644 --- a/test/core/injector/application_injector_test.cpp +++ b/test/core/injector/application_injector_test.cpp @@ -16,7 +16,7 @@ #include "filesystem/common.hpp" #include "mock/core/application/app_configuration_mock.hpp" #include "network/impl/router_libp2p.hpp" -#include "testutil/prepare_loggers.hpp" +#include "testutil/storage/base_fs_test.hpp" #include "utils/watchdog.hpp" namespace fs = kagome::filesystem; @@ -128,16 +128,12 @@ namespace { } } // namespace -class KagomeInjectorTest : public testing::Test { +class KagomeInjectorTest : public test::BaseFS_Test { public: - static void SetUpTestCase() { - testutil::prepareLoggers(); - fs::create_directories(db_path_); - fs::create_directories(db_path_ / "keys"); - writeKeys(db_path_ / "keys"); - } + KagomeInjectorTest() : BaseFS_Test{db_path_} {} void SetUp() override { + writeKeys(db_path_ / "keys"); config_ = std::make_shared(); initConfig(db_path_, *config_); injector_ = std::make_unique(config_); @@ -148,10 +144,6 @@ class KagomeInjectorTest : public testing::Test { injector_.reset(); } - static void TearDownTestCase() { - fs::remove_all(db_path_); - } - protected: inline static const auto db_path_ = fs::temp_directory_path() / fs::unique_path(); diff --git a/test/core/network/types/message_read_writer_test.cpp b/test/core/network/types/message_read_writer_test.cpp index 03a0861db9..81d7fc2116 100644 --- a/test/core/network/types/message_read_writer_test.cpp +++ b/test/core/network/types/message_read_writer_test.cpp @@ -30,7 +30,7 @@ struct AdapterWrapper { } template - static libp2p::outcome::result::const_iterator> read( + static outcome::result::const_iterator> read( T &out, const std::vector &src, std::vector::const_iterator from) { diff --git a/test/deps/outcome_test.cpp b/test/deps/outcome_test.cpp index ff5046c285..59aeb9a332 100644 --- a/test/deps/outcome_test.cpp +++ b/test/deps/outcome_test.cpp @@ -145,40 +145,3 @@ TEST(Outcome, FormatterBoostSystemErrorCode) { auto actual = fmt::format("{}", ec); EXPECT_EQ(actual, expected); } - -TEST(Outcome, FormatterVoidSuccess) { - auto success = outcome::success(); - - auto expected = ""; - - auto actual = fmt::format("{}", success); - EXPECT_EQ(actual, expected); -} - -TEST(Outcome, FormatterNonVoidSuccess) { - std::string data("Yahoo!"); - auto success = outcome::success(data); - - auto expected = data; - - auto actual = fmt::format("{}", success); - EXPECT_EQ(actual, expected); -} - -TEST(Outcome, FormatterResultSuccess) { - auto outcome = outcome::result("Yahoo!"); - - auto expected = outcome.value(); - - auto actual = fmt::format("{}", outcome); - EXPECT_EQ(actual, expected); -} - -TEST(Outcome, FormatterResultFailure) { - auto outcome = outcome::result(testutil::DummyError::ERROR); - - auto expected = outcome.error().message(); - - auto actual = fmt::format("{}", outcome); - EXPECT_EQ(actual, expected); -} diff --git a/test/mock/libp2p/basic/read_writer_mock.hpp b/test/mock/libp2p/basic/read_writer_mock.hpp index c3d02babb2..a4e2777b53 100644 --- a/test/mock/libp2p/basic/read_writer_mock.hpp +++ b/test/mock/libp2p/basic/read_writer_mock.hpp @@ -23,11 +23,6 @@ namespace libp2p::basic { (BytesOut, size_t, Reader::ReadCallbackFunc), (override)); - MOCK_METHOD(void, - write, - (BytesIn, size_t, Writer::WriteCallbackFunc), - (override)); - MOCK_METHOD(void, writeSome, (BytesIn, size_t, Writer::WriteCallbackFunc), diff --git a/test/testutil/libp2p/message_read_writer_helper.cpp b/test/testutil/libp2p/message_read_writer_helper.cpp index 1aa4e50f22..3391d43dc7 100644 --- a/test/testutil/libp2p/message_read_writer_helper.cpp +++ b/test/testutil/libp2p/message_read_writer_helper.cpp @@ -62,7 +62,7 @@ namespace libp2p::basic { msg.insert(msg.begin(), varint_to_write.toVector().begin(), varint_to_write.toVector().end()); - EXPECT_CALL(*read_writer_mock, write(_, msg.size(), _)) + EXPECT_CALL(*read_writer_mock, writeSome(_, msg.size(), _)) .WillOnce(CheckBytes(msg)); } @@ -78,7 +78,7 @@ namespace libp2p::basic { Return(libp2p::peer::PeerId::fromBase58( "12D3KooWE77U4m1d5mJxmU61AEsXewKjKnG7LiW2UQEPFnS6FXhv") .value())); - EXPECT_CALL(*stream_mock, write(_, msg.size(), _)) // NOLINT + EXPECT_CALL(*stream_mock, writeSome(_, msg.size(), _)) // NOLINT .WillOnce(CheckBytes(msg)); } } // namespace libp2p::basic