Skip to content

Commit

Permalink
Update hunter to v0.25.3-qdrvm7 (#2035)
Browse files Browse the repository at this point in the history
* Update hunter to v0.25.3-qdrvm7

Signed-off-by: turuslan <[email protected]>

---------

Signed-off-by: turuslan <[email protected]>
Co-authored-by: turuslan <[email protected]>
  • Loading branch information
kamilsa and turuslan authored Apr 9, 2024
1 parent 558a56a commit 6799f97
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 101 deletions.
10 changes: 5 additions & 5 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 2 additions & 2 deletions cmake/Hunter/hunter-gate-url.cmake
Original file line number Diff line number Diff line change
@@ -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
)
3 changes: 0 additions & 3 deletions core/network/helpers/stream_proxy_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
49 changes: 29 additions & 20 deletions core/network/helpers/stream_read_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

#include <libp2p/basic/read_return_size.hpp>
#include <libp2p/common/ambigous_size.hpp>
#include <libp2p/connection/stream_and_protocol.hpp>
#include <thread>

#include "log/logger.hpp"

namespace libp2p::connection {
/**
Expand Down Expand Up @@ -99,73 +103,78 @@ namespace kagome::network {
StreamWrapper(std::shared_ptr<libp2p::connection::StreamReadBuffer> 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<bool> isInitiator() const {
outcome::result<bool> isInitiator() const override {
return stream_->isInitiator();
}

outcome::result<libp2p::peer::PeerId> remotePeerId() const {
outcome::result<libp2p::peer::PeerId> remotePeerId() const override {
return stream_->remotePeerId();
}

outcome::result<libp2p::multi::Multiaddress> localMultiaddr() const {
outcome::result<libp2p::multi::Multiaddress> localMultiaddr()
const override {
return stream_->localMultiaddr();
}

outcome::result<libp2p::multi::Multiaddress> remoteMultiaddr() const {
outcome::result<libp2p::multi::Multiaddress> 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<size_t> res, ReadCallbackFunc cb) {
void deferReadCallback(outcome::result<size_t> 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));
}
};
Expand Down
5 changes: 3 additions & 2 deletions core/network/impl/protocols/protocol_base_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ namespace kagome::network {
bool start(std::weak_ptr<T> 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);

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/network/notifications/wait_read_close.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ namespace kagome::network::notifications {

inline void waitReadClose(std::shared_ptr<Stream> stream) {
auto buf = std::make_shared<std::vector<uint8_t>>(1);
auto cb = [stream, buf](libp2p::outcome::result<size_t> r) {
auto cb = [stream, buf](outcome::result<size_t> r) {
if (r) {
stream->reset();
return;
}
stream->close([](libp2p::outcome::result<void>) {});
stream->close([](outcome::result<void>) {});
};
stream->read(*buf, buf->size(), std::move(cb));
}
Expand Down
8 changes: 4 additions & 4 deletions core/outcome/into.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace outcome {
/// Wraps value or returns original result
template <typename T>
struct Into {
static outcome::result<T> into(T &&r) {
return outcome::success(std::move(r));
static result<T> into(T &&r) {
return success(std::move(r));
}
};
template <typename T>
struct Into<outcome::result<T>> {
static outcome::result<T> into(outcome::result<T> &&r) {
struct Into<result<T>> {
static result<T> into(result<T> &&r) {
return std::move(r);
}
};
Expand Down
6 changes: 0 additions & 6 deletions core/outcome/outcome.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@
#pragma once

#include <libp2p/outcome/outcome.hpp>

namespace outcome {
using libp2p::outcome::failure;
using libp2p::outcome::result;
using libp2p::outcome::success;
} // namespace outcome
1 change: 1 addition & 0 deletions test/core/injector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
addtest(application_injector_test application_injector_test.cpp)
target_link_libraries(application_injector_test
application_injector
base_fs_test
)
16 changes: 4 additions & 12 deletions test/core/injector/application_injector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<kagome::application::AppConfigurationMock>();
initConfig(db_path_, *config_);
injector_ = std::make_unique<kagome::injector::KagomeNodeInjector>(config_);
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/core/network/types/message_read_writer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct AdapterWrapper {
}

template <typename T>
static libp2p::outcome::result<std::vector<uint8_t>::const_iterator> read(
static outcome::result<std::vector<uint8_t>::const_iterator> read(
T &out,
const std::vector<uint8_t> &src,
std::vector<uint8_t>::const_iterator from) {
Expand Down
37 changes: 0 additions & 37 deletions test/deps/outcome_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<success>";

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<std::string>("Yahoo!");

auto expected = outcome.value();

auto actual = fmt::format("{}", outcome);
EXPECT_EQ(actual, expected);
}

TEST(Outcome, FormatterResultFailure) {
auto outcome = outcome::result<std::string>(testutil::DummyError::ERROR);

auto expected = outcome.error().message();

auto actual = fmt::format("{}", outcome);
EXPECT_EQ(actual, expected);
}
5 changes: 0 additions & 5 deletions test/mock/libp2p/basic/read_writer_mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions test/testutil/libp2p/message_read_writer_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -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

0 comments on commit 6799f97

Please sign in to comment.