Skip to content

Commit faaaf59

Browse files
author
MarcoFalke
committed
test: Make g_rng_temp_path rand, not dependent on SeedRandomForTest
1 parent fa80b08 commit faaaf59

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/test/util/setup_common.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
7777
constexpr inline auto TEST_DIR_PATH_ELEMENT{"test_common bitcoin"}; // Includes a space to catch possible path escape issues.
7878
/** Random context to get unique temp data dirs. Separate from m_rng, which can be seeded from a const env var */
7979
static FastRandomContext g_rng_temp_path;
80+
static const bool g_rng_temp_path_init{[] {
81+
// Must be initialized before any SeedRandomForTest
82+
(void)g_rng_temp_path.rand64();
83+
return true;
84+
}()};
8085

8186
struct NetworkSetup
8287
{
@@ -134,8 +139,6 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, TestOpts opts)
134139
}
135140
}
136141

137-
// Use randomly chosen seed for deterministic PRNG, so that (by default) test
138-
// data directories use a random name that doesn't overlap with other tests.
139142
SeedRandomForTest(SeedRand::FIXED_SEED);
140143

141144
const std::string test_name{G_TEST_GET_FULL_NAME ? G_TEST_GET_FULL_NAME() : ""};

0 commit comments

Comments
 (0)