test: refactor: Give unit test functions access to test state

Add unit test subclasses as needed so unit test functions that need to access
members like m_rng can reference it directly.
This commit is contained in:
Ryan Ofsky
2024-08-14 07:58:26 -04:00
committed by MarcoFalke
parent fab023e177
commit 3dc527f460
16 changed files with 145 additions and 81 deletions

View File

@@ -22,7 +22,13 @@
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(bloom_tests, BasicTestingSetup)
namespace bloom_tests {
struct BloomTest : public BasicTestingSetup {
std::vector<unsigned char> RandomData();
};
} // namespace bloom_tests
BOOST_FIXTURE_TEST_SUITE(bloom_tests, BloomTest)
BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
{
@@ -455,7 +461,7 @@ BOOST_AUTO_TEST_CASE(merkle_block_4_test_update_none)
BOOST_CHECK(!filter.contains(COutPoint(Txid::FromHex("02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041").value(), 0)));
}
static std::vector<unsigned char> RandomData()
std::vector<unsigned char> BloomTest::RandomData()
{
uint256 r = InsecureRand256();
return std::vector<unsigned char>(r.begin(), r.end());