scripted-diff: [test] Use g_rng/m_rng directly

-BEGIN VERIFY SCRIPT-

 # Use m_rng in unit test files
 ren() { sed -i "s:\<$1\>:$2:g" $( git grep -l "$1" src/test/*.cpp src/wallet/test/*.cpp src/test/util/setup_common.cpp ) ; }
 ren InsecureRand32                m_rng.rand32
 ren InsecureRand256               m_rng.rand256
 ren InsecureRandBits              m_rng.randbits
 ren InsecureRandRange             m_rng.randrange
 ren InsecureRandBool              m_rng.randbool
 ren g_insecure_rand_ctx           m_rng
 ren g_insecure_rand_ctx_temp_path g_rng_temp_path

-END VERIFY SCRIPT-
This commit is contained in:
MarcoFalke
2024-08-02 11:35:15 +02:00
parent fa54cab473
commit fa0fe08eca
40 changed files with 286 additions and 286 deletions

View File

@@ -31,9 +31,9 @@ inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outpu
CMutableTransaction mtx = CMutableTransaction();
mtx.vin.resize(num_inputs);
mtx.vout.resize(num_outputs);
auto random_script = CScript() << ToByteVector(InsecureRand256()) << ToByteVector(InsecureRand256());
auto random_script = CScript() << ToByteVector(m_rng.rand256()) << ToByteVector(m_rng.rand256());
for (size_t i{0}; i < num_inputs; ++i) {
mtx.vin[i].prevout.hash = Txid::FromUint256(InsecureRand256());
mtx.vin[i].prevout.hash = Txid::FromUint256(m_rng.rand256());
mtx.vin[i].prevout.n = 0;
mtx.vin[i].scriptSig = random_script;
}
@@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(package_sanitization_tests)
// Packages can't have transactions spending the same prevout
CMutableTransaction tx_zero_1;
CMutableTransaction tx_zero_2;
COutPoint same_prevout{Txid::FromUint256(InsecureRand256()), 0};
COutPoint same_prevout{Txid::FromUint256(m_rng.rand256()), 0};
tx_zero_1.vin.emplace_back(same_prevout);
tx_zero_2.vin.emplace_back(same_prevout);
// Different vouts (not the same tx)
@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(package_sanitization_tests)
// IsConsistentPackage only cares about conflicts between transactions, not about a transaction
// conflicting with itself (i.e. duplicate prevouts in vin).
CMutableTransaction dup_tx;
const COutPoint rand_prevout{Txid::FromUint256(InsecureRand256()), 0};
const COutPoint rand_prevout{Txid::FromUint256(m_rng.rand256()), 0};
dup_tx.vin.emplace_back(rand_prevout);
dup_tx.vin.emplace_back(rand_prevout);
Package package_with_dup_tx{MakeTransactionRef(dup_tx)};