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>
73 ,
msg_{std::move(msg)}
83 return std::make_unique<CheckMessageSink>(
threshold, *
this);
105 return std::make_shared<Ledger>(
111 auto res = std::make_shared<Ledger>(
112 *prev, prev->info().closeTime + closeOffset);
121 res->updateSkipList();
131 res->info().closeTime,
132 res->info().closeTimeResolution,
142 testcase(
"LedgerHistory mismatch");
152 std::make_unique<CheckMessageLogs>(
"MISMATCH ", found)};
154 auto const genesis =
makeLedger({}, env, lh, 0s);
156 lh.builtLedger(genesis, dummyTxHash, {});
157 lh.validatedLedger(genesis, dummyTxHash);
159 BEAST_EXPECT(!found);
168 std::make_unique<CheckMessageLogs>(
169 "MISMATCH on close time", found)};
171 auto const genesis =
makeLedger({}, env, lh, 0s);
172 auto const ledgerA =
makeLedger(genesis, env, lh, 4s);
173 auto const ledgerB =
makeLedger(genesis, env, lh, 40s);
176 lh.builtLedger(ledgerA, dummyTxHash, {});
177 lh.validatedLedger(ledgerB, dummyTxHash);
188 std::make_unique<CheckMessageLogs>(
189 "MISMATCH on prior ledger", found)};
191 auto const genesis =
makeLedger({}, env, lh, 0s);
192 auto const ledgerA =
makeLedger(genesis, env, lh, 4s);
193 auto const ledgerB =
makeLedger(genesis, env, lh, 40s);
194 auto const ledgerAC =
makeLedger(ledgerA, env, lh, 4s);
195 auto const ledgerBD =
makeLedger(ledgerB, env, lh, 4s);
198 lh.builtLedger(ledgerAC, dummyTxHash, {});
199 lh.validatedLedger(ledgerBD, dummyTxHash);
206 for (
bool const txBug : {
true,
false})
209 ?
"MISMATCH with same consensus transaction set"
210 :
"MISMATCH on consensus transaction set";
215 std::make_unique<CheckMessageLogs>(msg, found)};
220 env.
fund(
XRP(1000), alice, bob);
223 auto const ledgerBase =
231 auto const ledgerB =
makeLedger(ledgerBase, env, lh, 4s, txBob.
stx);
238 txBug ? txAlice.
stx->getTransactionID()
239 : txBob.
stx->getTransactionID());
Abstraction for the underlying message destination.
Json::Value noop(Account const &account)
The null transaction.
const XRP_t XRP
Converts to XRP Issue or STAmount.
CheckMessageSink(beast::severities::Severity threshold, CheckMessageLogs &owner)
BEAST_DEFINE_TESTSUITE(AccountDelete, app, ripple)
std::unique_ptr< beast::Journal::Sink > makeSink(std::string const &partition, beast::severities::Severity threshold) override
Manages partitions for logging.
CheckMessageLogs(std::string msg, bool &found)
Constructor.
CheckMessageLogs & owner_
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.
void builtLedger(std::shared_ptr< Ledger const > const &, uint256 const &consensusHash, Json::Value)
Report that we have locally built a particular ledger.
Log manager that searches for a specific message substring.
bool insert(std::shared_ptr< Ledger const > ledger, bool validated)
Track a ledger.
virtual Family & family()=0
virtual LedgerMaster & getLedgerMaster()=0
virtual Config & config()=0
Execution context for applying a JSON transaction.
void validatedLedger(std::shared_ptr< Ledger const > const &, boost::optional< uint256 > const &consensusHash)
Report that we have validated a particular ledger.
void write(beast::severities::Severity level, std::string const &text) override
Write text to the sink at the specified severity.
std::shared_ptr< Ledger const > getClosedLedger()
beast::severities::Severity threshold() const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual Severity threshold() const
Returns the minimum severity level this sink will report.
Severity
Severity level / threshold of a Journal message.
bool close(NetClock::time_point closeTime, boost::optional< std::chrono::milliseconds > consensusDelay=boost::none)
Close and advance the ledger.
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.