@@ -1321,6 +1321,14 @@ class V2TransportTester
13211321 SendPacket (contents);
13221322 }
13231323
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+
13241332 /* * Introduce a bit error in the data scheduled to be sent. */
13251333 void Damage ()
13261334 {
@@ -1346,6 +1354,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
13461354 BOOST_REQUIRE (ret && ret->empty ());
13471355 tester.ReceiveGarbage ();
13481356 tester.ReceiveVersion ();
1357+ tester.CompareSessionIDs ();
13491358 auto msg_data_1 = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (100000 ));
13501359 auto msg_data_2 = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (1000 ));
13511360 tester.SendMessage (uint8_t (4 ), msg_data_1); // cmpctblock short id
@@ -1386,6 +1395,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
13861395 BOOST_REQUIRE (ret && ret->empty ());
13871396 tester.ReceiveGarbage ();
13881397 tester.ReceiveVersion ();
1398+ tester.CompareSessionIDs ();
13891399 auto msg_data_1 = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (100000 ));
13901400 auto msg_data_2 = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (1000 ));
13911401 tester.SendMessage (uint8_t (14 ), msg_data_1); // inv short id
@@ -1439,6 +1449,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
14391449 BOOST_REQUIRE (ret && ret->empty ());
14401450 tester.ReceiveGarbage ();
14411451 tester.ReceiveVersion ();
1452+ tester.CompareSessionIDs ();
14421453 for (unsigned d = 0 ; d < num_decoys_1; ++d) {
14431454 auto decoy_data = g_insecure_rand_ctx.randbytes <uint8_t >(InsecureRandRange (1000 ));
14441455 tester.SendPacket (/* content=*/ decoy_data, /* aad=*/ {}, /* ignore=*/ true );
@@ -1516,6 +1527,7 @@ BOOST_AUTO_TEST_CASE(v2transport_test)
15161527 BOOST_REQUIRE (ret && ret->empty ());
15171528 tester.ReceiveGarbage ();
15181529 tester.ReceiveVersion ();
1530+ tester.CompareSessionIDs ();
15191531 auto msg_data_1 = g_insecure_rand_ctx.randbytes <uint8_t >(4000000 ); // test that receiving 4M payload works
15201532 auto msg_data_2 = g_insecure_rand_ctx.randbytes <uint8_t >(4000000 ); // test that sending 4M payload works
15211533 tester.SendMessage (uint8_t (InsecureRandRange (223 ) + 33 ), {}); // unknown short id
0 commit comments