From 8bf82c0e8b7fb2c906591577933e524c4e901832 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Wed, 16 Sep 2026 11:54:48 +0100 Subject: [PATCH] test(app): run waitForReady on a fresh Env in the freshen test The freshen-resolvable test funded and closed a ledger before calling waitForReady(env), but that helper asserts a freshly built Env (store not yet rotated, validated ledger == 3). Its own assertions failed and threw off ledgerSeq, so goodLedger then failed across the whole run (18 failures). Call waitForReady first, then drive the rotations, mirroring testAutomatic's ledger accounting. --- src/test/app/SHAMapStore_test.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index 418c95e775..7af33f5976 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -1057,29 +1057,20 @@ public: auto& store = env.app().getSHAMapStore(); auto& lm = env.app().getLedgerMaster(); - // Real account state, so the state map carries inner nodes that the - // rotation must copy forward rather than an almost-empty tree. - auto const alice = Account("alice"); - auto const bob = Account("bob"); - env.fund(XRP(10000), alice, bob); - env.close(); - + // waitForReady() must run on a freshly built Env: it asserts the store + // has not rotated yet and that the validated ledger is the third one. auto ledgerSeq = waitForReady(env); - auto lastRotated = store.getLastRotated(); + auto lastRotated = ledgerSeq - 1; + BEAST_EXPECT(store.getLastRotated() == lastRotated); - // Two rotations. A payment each ledger mutates the state map so - // successive rotations copy forward genuinely different nodes, while - // alice's and bob's account roots persist unchanged across the archive - // boundary -- exactly the nodes the copy-forward must preserve. + // Two rotations, so the first rotation's archive is really deleted by + // the second. Funding a fresh account every ledger keeps adding + // state-map nodes, while accounts funded before the boundary must stay + // reachable afterwards -- exactly what the copy-forward preserves. for (int rotation = 0; rotation < 2; ++rotation) { - for (auto const target = store.getLastRotated() + kDeleteInterval + 1; - ledgerSeq < target; - ++ledgerSeq) + for (; ledgerSeq < lastRotated + kDeleteInterval + 1; ++ledgerSeq) { - // A fresh funded account each ledger adds new state-map - // nodes, so each rotation copies forward genuinely new data - // while alice's and bob's roots persist across the boundary. env.fund(XRP(1000), Account("acct" + std::to_string(ledgerSeq))); env.close();