mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
net: expose transport types/session IDs of connections in RPC and logs
Co-authored-by: Dhruv Mehta <856960+dhruv@users.noreply.github.com>
This commit is contained in:
@@ -1321,6 +1321,14 @@ public:
|
||||
SendPacket(contents);
|
||||
}
|
||||
|
||||
/** Test whether the transport's session ID matches the session ID we expect. */
|
||||
void CompareSessionIDs() const
|
||||
{
|
||||
auto info = m_transport.GetInfo();
|
||||
BOOST_CHECK(info.session_id);
|
||||
BOOST_CHECK(uint256(MakeUCharSpan(m_cipher.GetSessionID())) == *info.session_id);
|
||||
}
|
||||
|
||||
/** Introduce a bit error in the data scheduled to be sent. */
|
||||
void Damage()
|
||||
{
|
||||
@@ -1346,6 +1354,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
|
||||
BOOST_REQUIRE(ret && ret->empty());
|
||||
tester.ReceiveGarbage();
|
||||
tester.ReceiveVersion();
|
||||
tester.CompareSessionIDs();
|
||||
auto msg_data_1 = g_insecure_rand_ctx.randbytes<uint8_t>(InsecureRandRange(100000));
|
||||
auto msg_data_2 = g_insecure_rand_ctx.randbytes<uint8_t>(InsecureRandRange(1000));
|
||||
tester.SendMessage(uint8_t(4), msg_data_1); // cmpctblock short id
|
||||
@@ -1386,6 +1395,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
|
||||
BOOST_REQUIRE(ret && ret->empty());
|
||||
tester.ReceiveGarbage();
|
||||
tester.ReceiveVersion();
|
||||
tester.CompareSessionIDs();
|
||||
auto msg_data_1 = g_insecure_rand_ctx.randbytes<uint8_t>(InsecureRandRange(100000));
|
||||
auto msg_data_2 = g_insecure_rand_ctx.randbytes<uint8_t>(InsecureRandRange(1000));
|
||||
tester.SendMessage(uint8_t(14), msg_data_1); // inv short id
|
||||
@@ -1439,6 +1449,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
|
||||
BOOST_REQUIRE(ret && ret->empty());
|
||||
tester.ReceiveGarbage();
|
||||
tester.ReceiveVersion();
|
||||
tester.CompareSessionIDs();
|
||||
for (unsigned d = 0; d < num_decoys_1; ++d) {
|
||||
auto decoy_data = g_insecure_rand_ctx.randbytes<uint8_t>(InsecureRandRange(1000));
|
||||
tester.SendPacket(/*content=*/decoy_data, /*aad=*/{}, /*ignore=*/true);
|
||||
@@ -1516,6 +1527,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
|
||||
BOOST_REQUIRE(ret && ret->empty());
|
||||
tester.ReceiveGarbage();
|
||||
tester.ReceiveVersion();
|
||||
tester.CompareSessionIDs();
|
||||
auto msg_data_1 = g_insecure_rand_ctx.randbytes<uint8_t>(4000000); // test that receiving 4M payload works
|
||||
auto msg_data_2 = g_insecure_rand_ctx.randbytes<uint8_t>(4000000); // test that sending 4M payload works
|
||||
tester.SendMessage(uint8_t(InsecureRandRange(223) + 33), {}); // unknown short id
|
||||
|
||||
Reference in New Issue
Block a user