added XRPL_ASSERTs to enable fuzzing/chaos testing

This commit is contained in:
Valentin Balaschenko
2026-07-07 17:06:11 +01:00
parent 6bed4582c6
commit 6054797dc7
2 changed files with 12 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
#include <xrpl/basics/IntrusivePointer.ipp>
#include <xrpl/basics/Log.h> // IWYU pragma: keep
#include <xrpl/basics/TaggedCache.h>
#include <xrpl/beast/utility/instrumentation.h>
namespace xrpl {
@@ -673,6 +674,10 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
auto entry = std::make_shared<T>();
canonicalize(key, entry, [](SharedPointerType const&) { return false; });
XRPL_ASSERT(
entry != nullptr,
"xrpl::TaggedCache::fetchAndModify : entry present after canonicalize");
callback(*entry);
}

View File

@@ -504,6 +504,9 @@ LedgerHistory::validatedLedger(
consensusValidated_.fetchAndModify(index, [&](CvEntry& entry) {
if (entry.built && !entry.validated)
{
XRPL_ASSERT(
entry.consensus.has_value(),
"xrpl::LedgerHistory::validatedLedger : consensus set when built set");
if (entry.built.value() != hash)
{
JLOG(j_.error()) << "MISMATCH: seq=" << index << " built:" << entry.built.value()
@@ -597,6 +600,10 @@ LedgerHistory::clearLedgerCachePrior(LedgerIndex seq)
}
}
indexSize = lock->byIndex.size();
XRPL_ASSERT(
lock->byIndex.empty() || lock->byIndex.begin()->first >= seq,
"xrpl::LedgerHistory::clearLedgerCachePrior : byIndex pruned to seq");
}
JLOG(j_.debug()) << "LedgersByHash: cleared " << hashesCleared << " entries before seq " << seq