21#include <test/jtx/CheckMessageLogs.h>
23#include <xrpld/app/ledger/LedgerHistory.h>
24#include <xrpld/app/ledger/LedgerMaster.h>
25#include <xrpld/app/tx/apply.h>
26#include <xrpld/ledger/OpenView.h>
28#include <xrpl/beast/insight/NullCollector.h>
29#include <xrpl/beast/unit_test.h>
58 return std::make_shared<Ledger>(
64 auto res = std::make_shared<Ledger>(
65 *prev, prev->info().closeTime + closeOffset);
74 res->updateSkipList();
84 res->info().closeTime,
85 res->info().closeTimeResolution,
104 std::make_unique<CheckMessageLogs>(
"MISMATCH ", &found)};
106 auto const genesis =
makeLedger({}, env, lh, 0s);
108 lh.builtLedger(genesis, dummyTxHash, {});
109 lh.validatedLedger(genesis, dummyTxHash);
111 BEAST_EXPECT(!found);
120 std::make_unique<CheckMessageLogs>(
121 "MISMATCH on close time", &found)};
123 auto const genesis =
makeLedger({}, env, lh, 0s);
124 auto const ledgerA =
makeLedger(genesis, env, lh, 4s);
125 auto const ledgerB =
makeLedger(genesis, env, lh, 40s);
128 lh.builtLedger(ledgerA, dummyTxHash, {});
129 lh.validatedLedger(ledgerB, dummyTxHash);
140 std::make_unique<CheckMessageLogs>(
141 "MISMATCH on prior ledger", &found)};
143 auto const genesis =
makeLedger({}, env, lh, 0s);
144 auto const ledgerA =
makeLedger(genesis, env, lh, 4s);
145 auto const ledgerB =
makeLedger(genesis, env, lh, 40s);
146 auto const ledgerAC =
makeLedger(ledgerA, env, lh, 4s);
147 auto const ledgerBD =
makeLedger(ledgerB, env, lh, 4s);
150 lh.builtLedger(ledgerAC, dummyTxHash, {});
151 lh.validatedLedger(ledgerBD, dummyTxHash);
158 for (
bool const txBug : {
true,
false})
161 ?
"MISMATCH with same consensus transaction set"
162 :
"MISMATCH on consensus transaction set";
167 std::make_unique<CheckMessageLogs>(msg, &found)};
172 env.
fund(
XRP(1000), alice, bob);
175 auto const ledgerBase =
183 auto const ledgerB =
makeLedger(ledgerBase, env, lh, 4s, txBob.
stx);
190 txBug ? txAlice.
stx->getTransactionID()
191 : txBob.
stx->getTransactionID());
static std::shared_ptr< Collector > New()
testcase_t testcase
Memberspace for declaring test cases.
virtual Config & config()=0
virtual Family & getNodeFamily()=0
virtual LedgerMaster & getLedgerMaster()=0
Retains historical ledgers.
void builtLedger(std::shared_ptr< Ledger const > const &, uint256 const &consensusHash, Json::Value)
Report that we have locally built a particular ledger.
bool insert(std::shared_ptr< Ledger const > const &ledger, bool validated)
Track a ledger.
void validatedLedger(std::shared_ptr< Ledger const > const &, std::optional< uint256 > const &consensusHash)
Report that we have validated a particular ledger.
std::shared_ptr< Ledger const > getClosedLedger()
Writable ledger view that accumulates state and tx changes.
void run() override
Runs the suite.
void testHandleMismatch()
static std::shared_ptr< Ledger > makeLedger(std::shared_ptr< Ledger const > const &prev, jtx::Env &env, LedgerHistory &lh, NetClock::duration closeOffset, std::shared_ptr< STTx const > stx={})
Generate a new ledger by hand, applying a specific close time offset and optionally inserting a trans...
Immutable cryptographic account descriptor.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
beast::Journal const journal
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
XRP_t const XRP
Converts to XRP Issue or STAmount.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
create_genesis_t const create_genesis
ApplyTransactionResult applyTransaction(Application &app, OpenView &view, STTx const &tx, bool retryAssured, ApplyFlags flags, beast::Journal journal)
Transaction application helper.
Execution context for applying a JSON transaction.
std::shared_ptr< STTx const > stx