mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
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:
@@ -116,7 +116,7 @@ void TestBIP324PacketVector(
|
||||
|
||||
// Seek to the numbered packet.
|
||||
if (in_idx == 0 && error == 12) continue;
|
||||
uint32_t dec_idx = in_idx ^ (error == 12 ? (1U << InsecureRandRange(16)) : 0);
|
||||
uint32_t dec_idx = in_idx ^ (error == 12 ? (1U << m_rng.randrange(16)) : 0);
|
||||
for (uint32_t i = 0; i < dec_idx; ++i) {
|
||||
unsigned use_idx = i < in_idx ? i : 0;
|
||||
bool dec_ignore{false};
|
||||
@@ -128,7 +128,7 @@ void TestBIP324PacketVector(
|
||||
// Decrypt length
|
||||
auto to_decrypt = ciphertext;
|
||||
if (error >= 2 && error <= 9) {
|
||||
to_decrypt[InsecureRandRange(to_decrypt.size())] ^= std::byte(1U << (error - 2));
|
||||
to_decrypt[m_rng.randrange(to_decrypt.size())] ^= std::byte(1U << (error - 2));
|
||||
}
|
||||
|
||||
// Decrypt length and resize ciphertext to accommodate.
|
||||
@@ -139,7 +139,7 @@ void TestBIP324PacketVector(
|
||||
auto dec_aad = in_aad;
|
||||
if (error == 10) {
|
||||
if (in_aad.size() == 0) continue;
|
||||
dec_aad[InsecureRandRange(dec_aad.size())] ^= std::byte(1U << InsecureRandRange(8));
|
||||
dec_aad[m_rng.randrange(dec_aad.size())] ^= std::byte(1U << m_rng.randrange(8));
|
||||
}
|
||||
if (error == 11) dec_aad.push_back({});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user