16#include <boost/test/unit_test.hpp>
54 const std::optional<CService> addr{
Lookup(
"127.0.0.1", 9000,
false)};
55 const Proxy sam_proxy(addr.value(),
false);
70 size_t num_sockets{0};
75 if (num_sockets == 1) {
76 return std::make_unique<StaticContentsSock>(
78 "HELLO REPLY RESULT=OK VERSION=3.1\n"
80 "DEST REPLY PUB=WnGOLXRBqHQhdVjFlWqRxJwz9hxx~2~wGc2Vplta1KhacY4tdEGodCF1WMWVapHEnDP2HHH~b~AZzZWmW1rUqFpxji10Qah0IXVYxZVqkcScM~Yccf9v8BnNlaZbWtSoWnGOLXRBqHQhdVjFlWqRxJwz9hxx~2~wGc2Vplta1KhacY4tdEGodCF1WMWVapHEnDP2HHH~b~AZzZWmW1rUqFpxji10Qah0IXVYxZVqkcScM~Yccf9v8BnNlaZbWtSoWnGOLXRBqHQhdVjFlWqRxJwz9hxx~2~wGc2Vplta1KhacY4tdEGodCF1WMWVapHEnDP2HHH~b~AZzZWmW1rUqFpxji10Qah0IXVYxZVqkcScM~Yccf9v8BnNlaZbWtSoWnGOLXRBqHQhdVjFlWqRxJwz9hxx~2~wGc2Vplta1KhacY4tdEGodCF1WMWVapHEnDP2HHH~b~AZzZWmW1rUqLE4SD-yjT48UNI7qiTUfIPiDitCoiTTz2cr4QGfw89rBQAEAAcAAA== PRIV=WnGOLXRBqHQhdVjFlWqRxJwz9hxx~2~wGc2Vplta1KhacY4tdEGodCF1WMWVapHEnDP2HHH~b~AZzZWmW1rUqFpxji10Qah0IXVYxZVqkcScM~Yccf9v8BnNlaZbWtSoWnGOLXRBqHQhdVjFlWqRxJwz9hxx~2~wGc2Vplta1KhacY4tdEGodCF1WMWVapHEnDP2HHH~b~AZzZWmW1rUqFpxji10Qah0IXVYxZVqkcScM~Yccf9v8BnNlaZbWtSoWnGOLXRBqHQhdVjFlWqRxJwz9hxx~2~wGc2Vplta1KhacY4tdEGodCF1WMWVapHEnDP2HHH~b~AZzZWmW1rUqFpxji10Qah0IXVYxZVqkcScM~Yccf9v8BnNlaZbWtSoWnGOLXRBqHQhdVjFlWqRxJwz9hxx~2~wGc2Vplta1KhacY4tdEGodCF1WMWVapHEnDP2HHH~b~AZzZWmW1rUqLE4SD-yjT48UNI7qiTUfIPiDitCoiTTz2cr4QGfw89rBQAEAAcAAOvuCIKTyv5f~1QgGq7XQl-IqBULTB5WzB3gw5yGPtd1p0AeoADrq1ccZggLPQ4ZLUsGK-HVw373rcTfvxrcuwenqVjiN4tbbYLWtP7xXGWj6fM6HyORhU63GphrjEePpMUHDHXd3o7pWGM-ieVVQSK~1MzF9P93pQWI3Do52EeNAayz4HbpPjNhVBzG1hUEFwznfPmUZBPuaOR4-uBm1NEWEuONlNOCctE4-U0Ukh94z-Qb55U5vXjR5G4apmBblr68t6Wm1TKlzpgFHzSqLryh3stWqrOKY1H0z9eZ2z1EkHFOpD5LyF6nf51e-lV7HLMl44TYzoEHK8RRVodtLcW9lacVdBpv~tOzlZERIiDziZODPETENZMz5oy9DQ7UUw==\n"
82 "SESSION STATUS RESULT=OK\n"
88 if (num_sockets % 2 == 0) {
90 return std::make_unique<StaticContentsSock>(
92 "HELLO REPLY RESULT=OK VERSION=3.1\n"
94 "STREAM STATUS RESULT=OK\n"
99 "STREAM STATUS RESULT=I2P_ERROR MESSAGE=\"Session was closed\"\n"
103 return std::make_unique<StaticContentsSock>(
105 "HELLO REPLY RESULT=OK VERSION=3.1\n"
107 "SESSION STATUS RESULT=OK\n"
116 const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), 7656};
117 const Proxy sam_proxy(addr,
false);
123 for (
size_t i = 0; i < 5; ++i) {
128 BOOST_REQUIRE(session.
Listen(conn));
129 BOOST_REQUIRE(!session.
Accept(conn));
136 return std::make_unique<StaticContentsSock>(
"HELLO REPLY RESULT=OK VERSION=3.1\n"
137 "SESSION STATUS RESULT=OK DESTINATION=\n");
140 const auto i2p_private_key_file = m_args.GetDataDirNet() /
"test_i2p_private_key_damaged";
142 for (
const auto& [file_contents, expected_error] : std::vector<std::tuple<std::string, std::string>>{
143 {
"",
"The private key is too short (0 < 387)"},
145 {
"abcd",
"The private key is too short (4 < 387)"},
147 {std::string(386,
'\0'),
"The private key is too short (386 < 387)"},
149 {std::string(385,
'\0') +
'\0' +
'\1',
150 "Certificate length (1) designates that the private key should be 388 bytes, but it is only "
153 {std::string(385,
'\0') +
'\0' +
'\5' +
"abcd",
154 "Certificate length (5) designates that the private key should be 392 bytes, but it is only "
159 const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), 7656};
160 const Proxy sam_proxy{addr,
false};
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
void SetLogLevel(Level level)
A combination of a network address (CNetAddr) and a (TCP) port.
A helper class for interruptible sleeps.
Save the log level and the value of CreateSock and restore them when the test ends.
EnvTestingSetup(const ChainType chainType=ChainType::MAIN, TestOpts opts={})
const decltype(CreateSock) m_create_sock_orig
const BCLog::Level m_prev_log_level
bool Listen(Connection &conn) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Start listening for an incoming connection.
bool Connect(const CService &to, Connection &conn, bool &proxy_error) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Connect to an I2P peer.
bool Accept(Connection &conn) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Wait for and accept a new incoming connection.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(unlimited_recv)
BCLog::Logger & LogInstance()
static constexpr size_t MAX_MSG_SIZE
The maximum size of an incoming message from the I2P SAM proxy (in bytes).
std::vector< CService > Lookup(const std::string &name, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function)
Resolve a service string to its corresponding service.
std::function< std::unique_ptr< Sock >(int, int, int)> CreateSock
Socket factory.
#define BOOST_CHECK(expr)
bool WriteBinaryFile(const fs::path &filename, const std::string &data)
Write contents of std::string to a file.
An established connection with another peer.
#define ASSERT_DEBUG_LOG(message)