Skip to content

Commit fab023e

Browse files
author
MarcoFalke
committed
test: refactor: Make unsigned promotion explicit
Integer promotion will already turn the `signed` into `unsigned` in those lines. However, make the `unsigned` explicit so that the code is clearer and a compiler warning is avoided when switching to m_rng: | test/validation_block_tests.cpp: warning: comparison of integers of different signs: 'int' and 'const unsigned int' [-Wsign-compare] | 136 | bool gen_invalid = m_rng.randrange(100) < invalid_rate; | | ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ | 137 | bool gen_fork = m_rng.randrange(100) < branch_rate; | | ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~ | 2 warnings generated.
1 parent fa2cb65 commit fab023e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/test/validation_block_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018-2022 The Bitcoin Core developers
1+
// Copyright (c) 2018-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -133,8 +133,8 @@ void MinerTestingSetup::BuildChain(const uint256& root, int height, const unsign
133133
{
134134
if (height <= 0 || blocks.size() >= max_size) return;
135135

136-
bool gen_invalid = InsecureRandRange(100) < invalid_rate;
137-
bool gen_fork = InsecureRandRange(100) < branch_rate;
136+
bool gen_invalid = m_rng.randrange(100U) < invalid_rate;
137+
bool gen_fork = m_rng.randrange(100U) < branch_rate;
138138

139139
const std::shared_ptr<const CBlock> pblock = gen_invalid ? BadBlock(root) : GoodBlock(root);
140140
blocks.push_back(pblock);

0 commit comments

Comments
 (0)