rippled
Loading...
Searching...
No Matches
PendingSaves_test.cpp
1#include <xrpld/app/ledger/PendingSaves.h>
2
3#include <xrpl/beast/unit_test.h>
4
5namespace ripple {
6namespace test {
7
9{
10 void
12 {
13 PendingSaves ps;
14
15 // Basic test
16 BEAST_EXPECT(!ps.pending(0));
17 BEAST_EXPECT(!ps.startWork(0));
18 BEAST_EXPECT(ps.shouldWork(0, true));
19 BEAST_EXPECT(ps.startWork(0));
20 BEAST_EXPECT(ps.pending(0));
21 BEAST_EXPECT(!ps.shouldWork(0, false));
22 ps.finishWork(0);
23 BEAST_EXPECT(!ps.pending(0));
24
25 // Test work stealing
26 BEAST_EXPECT(ps.shouldWork(0, false));
27 BEAST_EXPECT(ps.pending(0));
28 BEAST_EXPECT(ps.shouldWork(0, true));
29 BEAST_EXPECT(ps.pending(0));
30 BEAST_EXPECT(ps.startWork(0));
31 BEAST_EXPECT(!ps.startWork(0));
32 ps.finishWork(0);
33 BEAST_EXPECT(!ps.pending(0));
34 }
35
36 void
37 run() override
38 {
39 testSaves();
40 }
41};
42
43BEAST_DEFINE_TESTSUITE(PendingSaves, ledger, ripple);
44
45} // namespace test
46} // namespace ripple
A testsuite class.
Definition suite.h:52
Keeps track of which ledgers haven't been fully saved.
void finishWork(LedgerIndex seq)
Finish working on a ledger.
bool startWork(LedgerIndex seq)
Start working on a ledger.
bool shouldWork(LedgerIndex seq, bool isSynchronous)
Check if a ledger should be dispatched.
bool pending(LedgerIndex seq)
Return true if a ledger is in the progress of being saved.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
void run() override
Runs the suite.