@@ -1321,6 +1321,14 @@ class V2TransportTester
1321
1321
SendPacket (contents);
1322
1322
}
1323
1323
1324
+ /* * Test whether the transport's session ID matches the session ID we expect. */
1325
+ void CompareSessionIDs () const
1326
+ {
1327
+ auto info = m_transport.GetInfo ();
1328
+ BOOST_CHECK (info.session_id );
1329
+ BOOST_CHECK (uint256 (MakeUCharSpan (m_cipher.GetSessionID ())) == *info.session_id );
1330
+ }
1331
+
1324
1332
/* * Introduce a bit error in the data scheduled to be sent. */
1325
1333
void Damage ()
1326
1334
{
@@ -1346,6 +1354,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
1346
1354
BOOST_REQUIRE (ret && ret->empty ());
1347
1355
tester.ReceiveGarbage ();
1348
1356
tester.ReceiveVersion ();
1357
+ tester.CompareSessionIDs ();
1349
1358
auto msg_data_1 = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (100000 ));
1350
1359
auto msg_data_2 = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (1000 ));
1351
1360
tester.SendMessage (uint8_t (4 ), msg_data_1); // cmpctblock short id
@@ -1386,6 +1395,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
1386
1395
BOOST_REQUIRE (ret && ret->empty ());
1387
1396
tester.ReceiveGarbage ();
1388
1397
tester.ReceiveVersion ();
1398
+ tester.CompareSessionIDs ();
1389
1399
auto msg_data_1 = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (100000 ));
1390
1400
auto msg_data_2 = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (1000 ));
1391
1401
tester.SendMessage (uint8_t (14 ), msg_data_1); // inv short id
@@ -1439,6 +1449,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
1439
1449
BOOST_REQUIRE (ret && ret->empty ());
1440
1450
tester.ReceiveGarbage ();
1441
1451
tester.ReceiveVersion ();
1452
+ tester.CompareSessionIDs ();
1442
1453
for (unsigned d = 0 ; d < num_decoys_1; ++d) {
1443
1454
auto decoy_data = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (1000 ));
1444
1455
tester.SendPacket (/* content=*/ decoy_data, /* aad=*/ {}, /* ignore=*/ true );
@@ -1516,6 +1527,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
1516
1527
BOOST_REQUIRE (ret && ret->empty ());
1517
1528
tester.ReceiveGarbage ();
1518
1529
tester.ReceiveVersion ();
1530
+ tester.CompareSessionIDs ();
1519
1531
auto msg_data_1 = g_insecure_rand_ctx.randbytes <uint8_t >(4000000 ); // test that receiving 4M payload works
1520
1532
auto msg_data_2 = g_insecure_rand_ctx.randbytes <uint8_t >(4000000 ); // test that sending 4M payload works
1521
1533
tester.SendMessage (uint8_t (InsecureRandRange (223 ) + 33 ), {}); // unknown short id
0 commit comments