@@ -576,9 +576,14 @@ TYPED_TEST_P(TransportBaseTest, TestKexInitFailureAfterVersionExchange) {
576576TYPED_TEST_P (TransportBaseTest, TestDecryptPacketFailure) {
577577 EXPECT_CALL (this ->Client (), onKexStarted (true ));
578578 EXPECT_CALL (this ->Server (), onKexStarted (true ));
579- EXPECT_CALL (this ->Client (), onKexCompleted (_, true ));
579+ absl::Notification clientKexCompleted;
580+ EXPECT_CALL (this ->Client (), onKexCompleted (_, true ))
581+ .WillOnce (Invoke ([this , &clientKexCompleted](std::shared_ptr<KexResult> result, bool initial) {
582+ this ->Client ().TransportBase ::onKexCompleted (result, initial);
583+ clientKexCompleted.Notify ();
584+ }));
580585 EXPECT_CALL (this ->Server (), onKexCompleted (_, true ))
581- .WillOnce (Invoke ([this ](std::shared_ptr<KexResult> result, bool initial) {
586+ .WillOnce (Invoke ([this , &clientKexCompleted ](std::shared_ptr<KexResult> result, bool initial) {
582587 this ->Server ().TransportBase ::onKexCompleted (result, initial);
583588 if (result->algorithms .server_to_client .cipher == CipherAES128GCM ||
584589 result->algorithms .server_to_client .cipher == CipherAES256GCM ||
@@ -588,6 +593,9 @@ TYPED_TEST_P(TransportBaseTest, TestDecryptPacketFailure) {
588593 // In AES-GCM, the sequence number is implicitly contained in the cipher IV. The number
589594 // we track ourselves is not used when encrypting and decrypting packets, so changing it
590595 // manually here would not have the desired effect.
596+
597+ // Wait for the client's onKexCompleted, otherwise the expectation will fail
598+ clientKexCompleted.WaitForNotificationWithTimeout (defaultTimeout ());
591599 this ->Client ().Exit ();
592600 this ->Server ().Exit ();
593601 GTEST_SKIP () << " not applicable for aes-gcm" ;
0 commit comments