mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Merge pull request #7009
7414e2bac
Change epee binary output from std::stringstream to byte_stream (Lee Clagett)
This commit is contained in:
commit
1e9483a2d5
23 changed files with 126 additions and 106 deletions
|
@ -56,13 +56,13 @@ namespace
|
|||
{
|
||||
}
|
||||
|
||||
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, test_levin_connection_context& context)
|
||||
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, test_levin_connection_context& context)
|
||||
{
|
||||
m_invoke_counter.inc();
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
m_last_command = command;
|
||||
m_last_in_buf = std::string((const char*)in_buff.data(), in_buff.size());
|
||||
buff_out = m_invoke_out_buf;
|
||||
buff_out = m_invoke_out_buf.clone();
|
||||
return m_return_code;
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,7 @@ namespace
|
|||
int return_code() const { return m_return_code; }
|
||||
void return_code(int v) { m_return_code = v; }
|
||||
|
||||
const std::string& invoke_out_buf() const { return m_invoke_out_buf; }
|
||||
void invoke_out_buf(const std::string& v) { m_invoke_out_buf = v; }
|
||||
void invoke_out_buf(std::string v) { m_invoke_out_buf = epee::byte_slice{std::move(v)}; }
|
||||
|
||||
int last_command() const { return m_last_command; }
|
||||
const std::string& last_in_buf() const { return m_last_in_buf; }
|
||||
|
@ -118,7 +117,7 @@ namespace
|
|||
boost::mutex m_mutex;
|
||||
|
||||
int m_return_code;
|
||||
std::string m_invoke_out_buf;
|
||||
epee::byte_slice m_invoke_out_buf;
|
||||
|
||||
int m_last_command;
|
||||
std::string m_last_in_buf;
|
||||
|
|
|
@ -238,9 +238,9 @@ namespace
|
|||
return {connection, std::move(request)};
|
||||
}
|
||||
|
||||
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, cryptonote::levin::detail::p2p_context& context) override final
|
||||
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, cryptonote::levin::detail::p2p_context& context) override final
|
||||
{
|
||||
buff_out.clear();
|
||||
buff_out = nullptr;
|
||||
invoked_.push_back(
|
||||
{context.m_connection_id, command, std::string{reinterpret_cast<const char*>(in_buff.data()), in_buff.size()}}
|
||||
);
|
||||
|
|
|
@ -245,7 +245,7 @@ namespace
|
|||
|
||||
TEST(tor_address, epee_serializev_v2)
|
||||
{
|
||||
std::string buffer{};
|
||||
epee::byte_slice buffer{};
|
||||
{
|
||||
test_command_tor command{MONERO_UNWRAP(net::tor_address::make(v2_onion, 10))};
|
||||
EXPECT_FALSE(command.tor.is_unknown());
|
||||
|
@ -266,7 +266,7 @@ TEST(tor_address, epee_serializev_v2)
|
|||
EXPECT_EQ(0u, command.tor.port());
|
||||
|
||||
epee::serialization::portable_storage stg{};
|
||||
EXPECT_TRUE(stg.load_from_binary(buffer));
|
||||
EXPECT_TRUE(stg.load_from_binary(epee::to_span(buffer)));
|
||||
EXPECT_TRUE(command.load(stg));
|
||||
}
|
||||
EXPECT_FALSE(command.tor.is_unknown());
|
||||
|
@ -277,7 +277,7 @@ TEST(tor_address, epee_serializev_v2)
|
|||
// make sure that exceeding max buffer doesn't destroy tor_address::_load
|
||||
{
|
||||
epee::serialization::portable_storage stg{};
|
||||
stg.load_from_binary(buffer);
|
||||
stg.load_from_binary(epee::to_span(buffer));
|
||||
|
||||
std::string host{};
|
||||
ASSERT_TRUE(stg.get_value("host", host, stg.open_section("tor", nullptr, false)));
|
||||
|
@ -296,7 +296,7 @@ TEST(tor_address, epee_serializev_v2)
|
|||
|
||||
TEST(tor_address, epee_serializev_v3)
|
||||
{
|
||||
std::string buffer{};
|
||||
epee::byte_slice buffer{};
|
||||
{
|
||||
test_command_tor command{MONERO_UNWRAP(net::tor_address::make(v3_onion, 10))};
|
||||
EXPECT_FALSE(command.tor.is_unknown());
|
||||
|
@ -317,7 +317,7 @@ TEST(tor_address, epee_serializev_v3)
|
|||
EXPECT_EQ(0u, command.tor.port());
|
||||
|
||||
epee::serialization::portable_storage stg{};
|
||||
EXPECT_TRUE(stg.load_from_binary(buffer));
|
||||
EXPECT_TRUE(stg.load_from_binary(epee::to_span(buffer)));
|
||||
EXPECT_TRUE(command.load(stg));
|
||||
}
|
||||
EXPECT_FALSE(command.tor.is_unknown());
|
||||
|
@ -328,7 +328,7 @@ TEST(tor_address, epee_serializev_v3)
|
|||
// make sure that exceeding max buffer doesn't destroy tor_address::_load
|
||||
{
|
||||
epee::serialization::portable_storage stg{};
|
||||
stg.load_from_binary(buffer);
|
||||
stg.load_from_binary(epee::to_span(buffer));
|
||||
|
||||
std::string host{};
|
||||
ASSERT_TRUE(stg.get_value("host", host, stg.open_section("tor", nullptr, false)));
|
||||
|
@ -347,7 +347,7 @@ TEST(tor_address, epee_serializev_v3)
|
|||
|
||||
TEST(tor_address, epee_serialize_unknown)
|
||||
{
|
||||
std::string buffer{};
|
||||
epee::byte_slice buffer{};
|
||||
{
|
||||
test_command_tor command{net::tor_address::unknown()};
|
||||
EXPECT_TRUE(command.tor.is_unknown());
|
||||
|
@ -368,7 +368,7 @@ TEST(tor_address, epee_serialize_unknown)
|
|||
EXPECT_EQ(0u, command.tor.port());
|
||||
|
||||
epee::serialization::portable_storage stg{};
|
||||
EXPECT_TRUE(stg.load_from_binary(buffer));
|
||||
EXPECT_TRUE(stg.load_from_binary(epee::to_span(buffer)));
|
||||
EXPECT_TRUE(command.load(stg));
|
||||
}
|
||||
EXPECT_TRUE(command.tor.is_unknown());
|
||||
|
@ -379,7 +379,7 @@ TEST(tor_address, epee_serialize_unknown)
|
|||
// make sure that exceeding max buffer doesn't destroy tor_address::_load
|
||||
{
|
||||
epee::serialization::portable_storage stg{};
|
||||
stg.load_from_binary(buffer);
|
||||
stg.load_from_binary(epee::to_span(buffer));
|
||||
|
||||
std::string host{};
|
||||
ASSERT_TRUE(stg.get_value("host", host, stg.open_section("tor", nullptr, false)));
|
||||
|
@ -700,7 +700,7 @@ namespace
|
|||
|
||||
TEST(i2p_address, epee_serializev_b32)
|
||||
{
|
||||
std::string buffer{};
|
||||
epee::byte_slice buffer{};
|
||||
{
|
||||
test_command_i2p command{MONERO_UNWRAP(net::i2p_address::make(b32_i2p, 10))};
|
||||
EXPECT_FALSE(command.i2p.is_unknown());
|
||||
|
@ -721,7 +721,7 @@ TEST(i2p_address, epee_serializev_b32)
|
|||
EXPECT_EQ(0u, command.i2p.port());
|
||||
|
||||
epee::serialization::portable_storage stg{};
|
||||
EXPECT_TRUE(stg.load_from_binary(buffer));
|
||||
EXPECT_TRUE(stg.load_from_binary(epee::to_span(buffer)));
|
||||
EXPECT_TRUE(command.load(stg));
|
||||
}
|
||||
EXPECT_FALSE(command.i2p.is_unknown());
|
||||
|
@ -732,7 +732,7 @@ TEST(i2p_address, epee_serializev_b32)
|
|||
// make sure that exceeding max buffer doesn't destroy i2p_address::_load
|
||||
{
|
||||
epee::serialization::portable_storage stg{};
|
||||
stg.load_from_binary(buffer);
|
||||
stg.load_from_binary(epee::to_span(buffer));
|
||||
|
||||
std::string host{};
|
||||
ASSERT_TRUE(stg.get_value("host", host, stg.open_section("i2p", nullptr, false)));
|
||||
|
@ -751,7 +751,7 @@ TEST(i2p_address, epee_serializev_b32)
|
|||
|
||||
TEST(i2p_address, epee_serialize_unknown)
|
||||
{
|
||||
std::string buffer{};
|
||||
epee::byte_slice buffer{};
|
||||
{
|
||||
test_command_i2p command{net::i2p_address::unknown()};
|
||||
EXPECT_TRUE(command.i2p.is_unknown());
|
||||
|
@ -772,7 +772,7 @@ TEST(i2p_address, epee_serialize_unknown)
|
|||
EXPECT_EQ(0u, command.i2p.port());
|
||||
|
||||
epee::serialization::portable_storage stg{};
|
||||
EXPECT_TRUE(stg.load_from_binary(buffer));
|
||||
EXPECT_TRUE(stg.load_from_binary(epee::to_span(buffer)));
|
||||
EXPECT_TRUE(command.load(stg));
|
||||
}
|
||||
EXPECT_TRUE(command.i2p.is_unknown());
|
||||
|
@ -783,7 +783,7 @@ TEST(i2p_address, epee_serialize_unknown)
|
|||
// make sure that exceeding max buffer doesn't destroy i2p_address::_load
|
||||
{
|
||||
epee::serialization::portable_storage stg{};
|
||||
stg.load_from_binary(buffer);
|
||||
stg.load_from_binary(epee::to_span(buffer));
|
||||
|
||||
std::string host{};
|
||||
ASSERT_TRUE(stg.get_value("host", host, stg.open_section("i2p", nullptr, false)));
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
TEST(protocol_pack, protocol_pack_command)
|
||||
{
|
||||
std::string buff;
|
||||
epee::byte_slice buff;
|
||||
cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request r;
|
||||
r.start_height = 1;
|
||||
r.total_height = 3;
|
||||
|
@ -47,7 +47,7 @@ TEST(protocol_pack, protocol_pack_command)
|
|||
ASSERT_TRUE(res);
|
||||
|
||||
cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request r2;
|
||||
res = epee::serialization::load_t_from_binary(r2, buff);
|
||||
res = epee::serialization::load_t_from_binary(r2, epee::to_span(buff));
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_TRUE(r.m_block_ids.size() == i);
|
||||
ASSERT_TRUE(r.start_height == 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue