rippled
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Types | List of all members
ripple::test::reduce_relay_test Class Reference
Inheritance diagram for ripple::test::reduce_relay_test:
Inheritance graph
[legend]
Collaboration diagram for ripple::test::reduce_relay_test:
Collaboration graph
[legend]

Classes

struct  Event
 
struct  Handler
 

Public Member Functions

 reduce_relay_test ()
 
void run () override
 

Protected Types

enum  State { On, Off, WaitReset }
 
enum  EventType { LinkDown = 0, PeerDisconnected = 1 }
 

Protected Member Functions

void printPeers (const std::string &msg, std::uint16_t validator=0)
 
Peer::id_t sendSquelch (PublicKey const &validator, PeerWPtr const &peerPtr, std::optional< std::uint32_t > duration)
 Send squelch (if duration is set) or unsquelch (if duration not set) More...
 
void random (bool log)
 Randomly brings the link between a validator and a peer down. More...
 
bool checkCounting (PublicKey const &validator, bool isCountingState)
 
void doTest (const std::string &msg, bool log, std::function< void(bool)> f)
 
void testInitialRound (bool log)
 Initial counting round: three peers receive message "faster" then others. More...
 
void testPeerUnsquelchedTooSoon (bool log)
 Receiving message from squelched peer too soon should not change the slot's state to Counting. More...
 
void testPeerUnsquelched (bool log)
 Receiving message from squelched peer should change the slot's state to Counting. More...
 
bool propagateAndSquelch (bool log, bool purge=true, bool resetClock=true)
 Propagate enough messages to generate one squelch event. More...
 
bool propagateNoSquelch (bool log, std::uint16_t nMessages, bool countingState, bool purge=true, bool resetClock=true)
 Send fewer message so that squelch event is not generated. More...
 
void testNewPeer (bool log)
 Receiving a message from new peer should change the slot's state to Counting. More...
 
void testSelectedPeerDisconnects (bool log)
 Selected peer disconnects. More...
 
void testSelectedPeerStopsRelaying (bool log)
 Selected peer stops relaying. More...
 
void testSquelchedPeerDisconnects (bool log)
 Squelched peer disconnects. More...
 
void testConfig (bool log)
 
void testInternalHashRouter (bool log)
 
void testRandomSquelch (bool l)
 
void testHandshake (bool log)
 

Protected Attributes

jtx::Env env_
 
Network network_
 

Private Types

using Slot = reduce_relay::Slot< ManualClock >
 
using id_t = Peer::id_t
 

Detailed Description

Definition at line 877 of file reduce_relay_test.cpp.

Member Typedef Documentation

◆ Slot

Definition at line 879 of file reduce_relay_test.cpp.

◆ id_t

Definition at line 880 of file reduce_relay_test.cpp.

Member Enumeration Documentation

◆ State

Enumerator
On 
Off 
WaitReset 

Definition at line 915 of file reduce_relay_test.cpp.

◆ EventType

Enumerator
LinkDown 
PeerDisconnected 

Definition at line 916 of file reduce_relay_test.cpp.

Constructor & Destructor Documentation

◆ reduce_relay_test()

ripple::test::reduce_relay_test::reduce_relay_test ( )

Definition at line 1557 of file reduce_relay_test.cpp.

Member Function Documentation

◆ printPeers()

void ripple::test::reduce_relay_test::printPeers ( const std::string msg,
std::uint16_t  validator = 0 
)
protected

Definition at line 884 of file reduce_relay_test.cpp.

◆ sendSquelch()

Peer::id_t ripple::test::reduce_relay_test::sendSquelch ( PublicKey const &  validator,
PeerWPtr const &  peerPtr,
std::optional< std::uint32_t duration 
)
protected

Send squelch (if duration is set) or unsquelch (if duration not set)

Definition at line 898 of file reduce_relay_test.cpp.

◆ random()

void ripple::test::reduce_relay_test::random ( bool  log)
protected

Randomly brings the link between a validator and a peer down.

Randomly disconnects a peer. Those events are generated one at a time.

Definition at line 938 of file reduce_relay_test.cpp.

◆ checkCounting()

bool ripple::test::reduce_relay_test::checkCounting ( PublicKey const &  validator,
bool  isCountingState 
)
protected

Definition at line 1112 of file reduce_relay_test.cpp.

◆ doTest()

void ripple::test::reduce_relay_test::doTest ( const std::string msg,
bool  log,
std::function< void(bool)>  f 
)
protected

Definition at line 1120 of file reduce_relay_test.cpp.

◆ testInitialRound()

void ripple::test::reduce_relay_test::testInitialRound ( bool  log)
protected

Initial counting round: three peers receive message "faster" then others.

Once the message count for the three peers reaches threshold the rest of the peers are squelched and the slot for the given validator is in Selected state.

Definition at line 1132 of file reduce_relay_test.cpp.

◆ testPeerUnsquelchedTooSoon()

void ripple::test::reduce_relay_test::testPeerUnsquelchedTooSoon ( bool  log)
protected

Receiving message from squelched peer too soon should not change the slot's state to Counting.

Definition at line 1143 of file reduce_relay_test.cpp.

◆ testPeerUnsquelched()

void ripple::test::reduce_relay_test::testPeerUnsquelched ( bool  log)
protected

Receiving message from squelched peer should change the slot's state to Counting.

Definition at line 1154 of file reduce_relay_test.cpp.

◆ propagateAndSquelch()

bool ripple::test::reduce_relay_test::propagateAndSquelch ( bool  log,
bool  purge = true,
bool  resetClock = true 
)
protected

Propagate enough messages to generate one squelch event.

Definition at line 1164 of file reduce_relay_test.cpp.

◆ propagateNoSquelch()

bool ripple::test::reduce_relay_test::propagateNoSquelch ( bool  log,
std::uint16_t  nMessages,
bool  countingState,
bool  purge = true,
bool  resetClock = true 
)
protected

Send fewer message so that squelch event is not generated.

Definition at line 1200 of file reduce_relay_test.cpp.

◆ testNewPeer()

void ripple::test::reduce_relay_test::testNewPeer ( bool  log)
protected

Receiving a message from new peer should change the slot's state to Counting.

Definition at line 1231 of file reduce_relay_test.cpp.

◆ testSelectedPeerDisconnects()

void ripple::test::reduce_relay_test::testSelectedPeerDisconnects ( bool  log)
protected

Selected peer disconnects.

Should change the state to counting and unsquelch squelched peers.

Definition at line 1243 of file reduce_relay_test.cpp.

◆ testSelectedPeerStopsRelaying()

void ripple::test::reduce_relay_test::testSelectedPeerStopsRelaying ( bool  log)
protected

Selected peer stops relaying.

Should change the state to counting and unsquelch squelched peers.

Definition at line 1263 of file reduce_relay_test.cpp.

◆ testSquelchedPeerDisconnects()

void ripple::test::reduce_relay_test::testSquelchedPeerDisconnects ( bool  log)
protected

Squelched peer disconnects.

Should not change the state to counting.

Definition at line 1284 of file reduce_relay_test.cpp.

◆ testConfig()

void ripple::test::reduce_relay_test::testConfig ( bool  log)
protected

Definition at line 1306 of file reduce_relay_test.cpp.

◆ testInternalHashRouter()

void ripple::test::reduce_relay_test::testInternalHashRouter ( bool  log)
protected

Definition at line 1348 of file reduce_relay_test.cpp.

◆ testRandomSquelch()

void ripple::test::reduce_relay_test::testRandomSquelch ( bool  l)
protected

Definition at line 1410 of file reduce_relay_test.cpp.

◆ testHandshake()

void ripple::test::reduce_relay_test::testHandshake ( bool  log)
protected

Definition at line 1489 of file reduce_relay_test.cpp.

◆ run()

void ripple::test::reduce_relay_test::run ( )
override

Definition at line 1562 of file reduce_relay_test.cpp.

Member Data Documentation

◆ env_

jtx::Env ripple::test::reduce_relay_test::env_
protected

Definition at line 1553 of file reduce_relay_test.cpp.

◆ network_

Network ripple::test::reduce_relay_test::network_
protected

Definition at line 1554 of file reduce_relay_test.cpp.