rippled
Loading...
Searching...
No Matches
PendingSaves_test.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5 Permission to use, copy, modify, and/or distribute this software for any
6 purpose with or without fee is hereby granted, provided that the above
7 copyright notice and this permission notice appear in all copies.
8 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16//==============================================================================
17
18#include <xrpld/app/ledger/PendingSaves.h>
19
20#include <xrpl/beast/unit_test.h>
21
22namespace ripple {
23namespace test {
24
26{
27 void
29 {
30 PendingSaves ps;
31
32 // Basic test
33 BEAST_EXPECT(!ps.pending(0));
34 BEAST_EXPECT(!ps.startWork(0));
35 BEAST_EXPECT(ps.shouldWork(0, true));
36 BEAST_EXPECT(ps.startWork(0));
37 BEAST_EXPECT(ps.pending(0));
38 BEAST_EXPECT(!ps.shouldWork(0, false));
39 ps.finishWork(0);
40 BEAST_EXPECT(!ps.pending(0));
41
42 // Test work stealing
43 BEAST_EXPECT(ps.shouldWork(0, false));
44 BEAST_EXPECT(ps.pending(0));
45 BEAST_EXPECT(ps.shouldWork(0, true));
46 BEAST_EXPECT(ps.pending(0));
47 BEAST_EXPECT(ps.startWork(0));
48 BEAST_EXPECT(!ps.startWork(0));
49 ps.finishWork(0);
50 BEAST_EXPECT(!ps.pending(0));
51 }
52
53 void
54 run() override
55 {
56 testSaves();
57 }
58};
59
60BEAST_DEFINE_TESTSUITE(PendingSaves, ledger, ripple);
61
62} // namespace test
63} // namespace ripple
A testsuite class.
Definition suite.h:55
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:25
void run() override
Runs the suite.