Improve locking, logging, and test output

- Add more info to the error message on some failed tests.
- Add logging details to SHAMapStoreImp
This commit is contained in:
Ed Hennis
2025-07-09 13:46:24 -04:00
parent f67398c6bf
commit b24116a118
2 changed files with 74 additions and 25 deletions

View File

@@ -657,6 +657,25 @@ public:
Env env{*this, envconfig(onlineDelete)};
auto& ns = env.app().getNodeStore();
std::map<LedgerIndex, uint256> hashes;
auto storeHash = [&]() {
hashes.emplace(
env.current()->info().seq, env.current()->info().hash);
auto const& root =
ns.fetchNodeObject(hashes[env.current()->info().seq]);
BEAST_EXPECT(root);
};
auto failureMessage = [&](char const* label,
auto expected,
auto actual) {
std::stringstream ss;
ss << label << ": Expected: " << expected << ", Got: " << actual;
return ss.str();
};
auto const alice = Account("alice");
env.fund(XRP(1000), alice);
env.close();
@@ -713,7 +732,10 @@ public:
BEAST_EXPECTS(
lm.getCompleteLedgers() ==
expectedRange(minSeq, deleteSeq, maxSeq),
lm.getCompleteLedgers());
failureMessage(
"Complete ledgers",
expectedRange(minSeq, deleteSeq, maxSeq),
lm.getCompleteLedgers()));
BEAST_EXPECT(
lm.missingFromCompleteLedgerRange(minSeq, maxSeq) == 1);
@@ -726,11 +748,15 @@ public:
// Nothing has changed
BEAST_EXPECTS(
store.getLastRotated() == lastRotated,
to_string(store.getLastRotated()));
failureMessage(
"lastRotated", lastRotated, store.getLastRotated()));
BEAST_EXPECTS(
lm.getCompleteLedgers() ==
expectedRange(minSeq, deleteSeq, maxSeq),
lm.getCompleteLedgers());
failureMessage(
"Complete ledgers",
expectedRange(minSeq, deleteSeq, maxSeq),
lm.getCompleteLedgers()));
using namespace std::chrono_literals;
// Close 5 more ledgers, waiting one second in between to
@@ -746,11 +772,17 @@ public:
// Nothing has changed
BEAST_EXPECTS(
store.getLastRotated() == lastRotated,
to_string(store.getLastRotated()));
failureMessage(
"lastRotated",
lastRotated,
store.getLastRotated()));
BEAST_EXPECTS(
lm.getCompleteLedgers() ==
expectedRange(minSeq, deleteSeq, maxSeq),
lm.getCompleteLedgers());
failureMessage(
"Complete Ledgers",
expectedRange(minSeq, deleteSeq, maxSeq),
lm.getCompleteLedgers()));
std::this_thread::sleep_for(1s);
}
@@ -766,15 +798,19 @@ public:
BEAST_EXPECT(maxSeq != lastRotated + deleteInterval);
BEAST_EXPECTS(
env.closed()->info().seq == maxSeq,
to_string(env.closed()->info().seq));
failureMessage("maxSeq", maxSeq, env.closed()->info().seq));
BEAST_EXPECTS(
store.getLastRotated() == lastRotated,
to_string(store.getLastRotated()));
failureMessage(
"lastRotated", lastRotated, store.getLastRotated()));
std::stringstream expectedRange;
expectedRange << minSeq << "-" << maxSeq;
BEAST_EXPECTS(
lm.getCompleteLedgers() == expectedRange.str(),
lm.getCompleteLedgers());
failureMessage(
"CompleteLedgers",
expectedRange.str(),
lm.getCompleteLedgers()));
BEAST_EXPECT(
lm.missingFromCompleteLedgerRange(minSeq, maxSeq) == 0);
BEAST_EXPECT(