2021-03-11 16:27:22 +01:00
|
|
|
// Copyright (c) 2021-2021 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include <i2p.h>
|
2022-08-18 13:37:25 +02:00
|
|
|
#include <logging.h>
|
2021-03-11 16:27:22 +01:00
|
|
|
#include <netaddress.h>
|
|
|
|
#include <test/util/logging.h>
|
|
|
|
#include <test/util/net.h>
|
|
|
|
#include <test/util/setup_common.h>
|
|
|
|
#include <util/system.h>
|
2022-10-11 15:33:22 +08:00
|
|
|
#include <util/threadinterrupt.h>
|
2021-03-11 16:27:22 +01:00
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_SUITE(i2p_tests, BasicTestingSetup)
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(unlimited_recv)
|
|
|
|
{
|
2022-08-18 13:37:25 +02:00
|
|
|
const auto prev_log_level{LogInstance().LogLevel()};
|
Create BCLog::Level::Trace log severity level
for verbose log messages for development or debugging only, as bitcoind may run
more slowly, that are more granular/frequent than the Debug log level, i.e. for
very high-frequency, low-level messages to be logged distinctly from
higher-level, less-frequent debug logging that could still be usable in production.
An example would be to log higher-level peer events (connection, disconnection,
misbehavior, eviction) as Debug, versus Trace for low-level, high-volume p2p
messages in the BCLog::NET category. This will enable the user to log only the
former without the latter, in order to focus on high-level peer management events.
With respect to the name, "trace" is suggested as the most granular level
in resources like the following:
- https://sematext.com/blog/logging-levels
- https://howtodoinjava.com/log4j2/logging-levels
Update the test framework and add test coverage.
2022-06-01 13:44:59 +02:00
|
|
|
LogInstance().SetLogLevel(BCLog::Level::Trace);
|
2021-03-11 16:27:22 +01:00
|
|
|
auto CreateSockOrig = CreateSock;
|
|
|
|
|
|
|
|
// Mock CreateSock() to create MockSock.
|
|
|
|
CreateSock = [](const CService&) {
|
|
|
|
return std::make_unique<StaticContentsSock>(std::string(i2p::sam::MAX_MSG_SIZE + 1, 'a'));
|
|
|
|
};
|
|
|
|
|
|
|
|
CThreadInterrupt interrupt;
|
2021-05-04 13:00:25 +02:00
|
|
|
i2p::sam::Session session(gArgs.GetDataDirNet() / "test_i2p_private_key", CService{}, &interrupt);
|
2021-03-11 16:27:22 +01:00
|
|
|
|
|
|
|
{
|
2022-06-08 15:27:11 +02:00
|
|
|
ASSERT_DEBUG_LOG("Creating persistent SAM session");
|
2021-03-11 16:27:22 +01:00
|
|
|
ASSERT_DEBUG_LOG("too many bytes without a terminator");
|
|
|
|
|
|
|
|
i2p::Connection conn;
|
|
|
|
bool proxy_error;
|
|
|
|
BOOST_REQUIRE(!session.Connect(CService{}, conn, proxy_error));
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateSock = CreateSockOrig;
|
2022-08-18 13:37:25 +02:00
|
|
|
LogInstance().SetLogLevel(prev_log_level);
|
2021-03-11 16:27:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|