From 52671bfc99efca136a59aea17e2cf0368193a396 Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Thu, 9 Apr 2026 16:51:26 +0700 Subject: [PATCH] test(rng): add XAHAU_RNG_TEST env var filter for focused test runs Set XAHAU_RNG_TEST= to run only matching test methods. e.g. XAHAU_RNG_TEST=SingleByzantine runs only that test. --- src/test/consensus/ConsensusRng_test.cpp | 44 ++++++++++++++++-------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/test/consensus/ConsensusRng_test.cpp b/src/test/consensus/ConsensusRng_test.cpp index 08e5064e1..04e3d7767 100644 --- a/src/test/consensus/ConsensusRng_test.cpp +++ b/src/test/consensus/ConsensusRng_test.cpp @@ -688,21 +688,35 @@ public: void run() override { - testRngCommitRevealConverges(); - testRngCommitRevealConvergesWithTransactions(); - testRngImpossibleQuorumFallback(); - testRngPersistentLossDoesNotShrinkQuorum(); - testRngTimeoutWithPartialQuorum(); - testRngCommitSetConflictForcesFallback(); - testRngObserverDoesNotExpectSelfCommit(); - testRngIgnoresNonUNLData(); - testRngRejectsRevealWithoutCommit(); - testRngRejectsInvalidReveal(); - testRngCommitChangeClearsStaleReveal(); - testRngRevealTimeoutAsymmetricDelays(); - testRngEntropyConvergesWithPartialReveals(); - testRngEntropyFallbackOnMajorRevealLoss(); - testRngSingleByzantineCannotDenyEntropy(); + // Set XAHAU_RNG_TEST= to run a single test method. + // e.g. XAHAU_RNG_TEST=SingleByzantine + auto const* filter = std::getenv("XAHAU_RNG_TEST"); + std::string f = filter ? filter : ""; + +#define RUN(method) \ + do \ + { \ + if (f.empty() || std::string(#method).find(f) != std::string::npos) \ + method(); \ + } while (false) + + RUN(testRngCommitRevealConverges); + RUN(testRngCommitRevealConvergesWithTransactions); + RUN(testRngImpossibleQuorumFallback); + RUN(testRngPersistentLossDoesNotShrinkQuorum); + RUN(testRngTimeoutWithPartialQuorum); + RUN(testRngCommitSetConflictForcesFallback); + RUN(testRngObserverDoesNotExpectSelfCommit); + RUN(testRngIgnoresNonUNLData); + RUN(testRngRejectsRevealWithoutCommit); + RUN(testRngRejectsInvalidReveal); + RUN(testRngCommitChangeClearsStaleReveal); + RUN(testRngRevealTimeoutAsymmetricDelays); + RUN(testRngEntropyConvergesWithPartialReveals); + RUN(testRngEntropyFallbackOnMajorRevealLoss); + RUN(testRngSingleByzantineCannotDenyEntropy); + +#undef RUN } };