20 #include <ripple/app/ledger/LedgerHistory.h>
21 #include <ripple/app/ledger/LedgerMaster.h>
22 #include <ripple/app/tx/apply.h>
23 #include <ripple/beast/insight/NullCollector.h>
24 #include <ripple/beast/unit_test.h>
25 #include <ripple/ledger/OpenView.h>
30 #include <test/jtx/CheckMessageLogs.h>
56 return std::make_shared<Ledger>(
62 auto res = std::make_shared<Ledger>(
63 *prev, prev->info().closeTime + closeOffset);
72 res->updateSkipList();
82 res->info().closeTime,
83 res->info().closeTimeResolution,
92 testcase(
"LedgerHistory mismatch");
102 std::make_unique<CheckMessageLogs>(
"MISMATCH ", &found)};
104 auto const genesis =
makeLedger({}, env, lh, 0s);
106 lh.builtLedger(genesis, dummyTxHash, {});
107 lh.validatedLedger(genesis, dummyTxHash);
109 BEAST_EXPECT(!found);
118 std::make_unique<CheckMessageLogs>(
119 "MISMATCH on close time", &found)};
121 auto const genesis =
makeLedger({}, env, lh, 0s);
122 auto const ledgerA =
makeLedger(genesis, env, lh, 4s);
123 auto const ledgerB =
makeLedger(genesis, env, lh, 40s);
126 lh.builtLedger(ledgerA, dummyTxHash, {});
127 lh.validatedLedger(ledgerB, dummyTxHash);
138 std::make_unique<CheckMessageLogs>(
139 "MISMATCH on prior ledger", &found)};
141 auto const genesis =
makeLedger({}, env, lh, 0s);
142 auto const ledgerA =
makeLedger(genesis, env, lh, 4s);
143 auto const ledgerB =
makeLedger(genesis, env, lh, 40s);
144 auto const ledgerAC =
makeLedger(ledgerA, env, lh, 4s);
145 auto const ledgerBD =
makeLedger(ledgerB, env, lh, 4s);
148 lh.builtLedger(ledgerAC, dummyTxHash, {});
149 lh.validatedLedger(ledgerBD, dummyTxHash);
156 for (
bool const txBug : {
true,
false})
159 ?
"MISMATCH with same consensus transaction set"
160 :
"MISMATCH on consensus transaction set";
165 std::make_unique<CheckMessageLogs>(msg, &found)};
170 env.
fund(
XRP(1000), alice, bob);
173 auto const ledgerBase =
181 auto const ledgerB =
makeLedger(ledgerBase, env, lh, 4s, txBob.
stx);
188 txBug ? txAlice.
stx->getTransactionID()
189 : txBob.
stx->getTransactionID());
Json::Value noop(Account const &account)
The null transaction.
virtual Family & getNodeFamily()=0
const XRP_t XRP
Converts to XRP Issue or STAmount.
Writable ledger view that accumulates state and tx changes.
ApplyResult applyTransaction(Application &app, OpenView &view, STTx const &tx, bool retryAssured, ApplyFlags flags, beast::Journal journal)
Transaction application helper.
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...
std::shared_ptr< STTx const > stx
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
const beast::Journal journal
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Retains historical ledgers.
bool insert(std::shared_ptr< Ledger const > const &ledger, bool validated)
Track a ledger.
void builtLedger(std::shared_ptr< Ledger const > const &, uint256 const &consensusHash, Json::Value)
Report that we have locally built a particular ledger.
virtual LedgerMaster & getLedgerMaster()=0
virtual Config & config()=0
Execution context for applying a JSON transaction.
void validatedLedger(std::shared_ptr< Ledger const > const &, std::optional< uint256 > const &consensusHash)
Report that we have validated a particular ledger.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
std::shared_ptr< Ledger const > getClosedLedger()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
const create_genesis_t create_genesis
void testHandleMismatch()
Immutable cryptographic account descriptor.
static std::shared_ptr< Collector > New()
A transaction testing environment.
BEAST_DEFINE_TESTSUITE(DeliverMin, app, ripple)