Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/test/app/LedgerReplay_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <xrpl/basics/Slice.h>
#include <xrpl/basics/base_uint.h>
#include <xrpl/basics/random.h>
#include <xrpl/beast/net/IPAddress.h>
#include <xrpl/beast/net/IPEndpoint.h>
#include <xrpl/beast/unit_test/suite.h>
Expand All @@ -53,6 +52,7 @@
#include <xrpl.pb.h>

#include <algorithm>
#include <atomic>
#include <cassert>
#include <chrono>
#include <cstddef>
Expand Down Expand Up @@ -443,17 +443,13 @@ struct TestPeerSet : public PeerSet
protocol::MessageType type,
std::shared_ptr<Peer> 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)
Expand Down Expand Up @@ -498,6 +494,7 @@ struct TestPeerSet : public PeerSet
LedgerReplayMsgHandler& remote;
std::shared_ptr<TestPeer> dummyPeer;
PeerSetBehavior behavior;
std::atomic<int> sendCount{0};
};

/**
Expand Down
Loading