diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 7b521402a40..adc8c7b3241 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -53,6 +52,7 @@ #include #include +#include #include #include #include @@ -443,17 +443,13 @@ struct TestPeerSet : public PeerSet protocol::MessageType type, std::shared_ptr const& peer) override { - int dropRate = 0; - if (behavior == PeerSetBehavior::Drop50) - { - dropRate = 50; - } - else if (behavior == PeerSetBehavior::DropAll) - { - dropRate = 100; - } + if (behavior == PeerSetBehavior::DropAll) + return; - if (randInt(1, 100) <= dropRate) + // Drop every other message deterministically. Alternating drops + // still exercise the timeout/retry path while guaranteeing every + // subtask eventually gets a reply. + if (behavior == PeerSetBehavior::Drop50 && sendCount++ % 2 == 0) return; switch (type) @@ -498,6 +494,7 @@ struct TestPeerSet : public PeerSet LedgerReplayMsgHandler& remote; std::shared_ptr dummyPeer; PeerSetBehavior behavior; + std::atomic sendCount{0}; }; /**