Skip to content

Commit fad8154

Browse files
author
MarcoFalke
committed
test: Avoid testing negative block heights
1 parent 219d728 commit fad8154

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/test/coins_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test)
324324
tx.vout.resize(1);
325325
tx.vout[0].nValue = i; //Keep txs unique unless intended to duplicate
326326
tx.vout[0].scriptPubKey.assign(InsecureRand32() & 0x3F, 0); // Random sizes so we can test memory usage accounting
327-
unsigned int height = InsecureRand32();
327+
const int height{int(InsecureRand32() >> 1)};
328328
Coin old_coin;
329329

330330
// 2/20 times create a new coinbase
@@ -393,11 +393,11 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test)
393393
// Update the expected result to know about the new output coins
394394
assert(tx.vout.size() == 1);
395395
const COutPoint outpoint(tx.GetHash(), 0);
396-
result[outpoint] = Coin{tx.vout[0], int(height), CTransaction(tx).IsCoinBase()};
396+
result[outpoint] = Coin{tx.vout[0], height, CTransaction{tx}.IsCoinBase()};
397397

398398
// Call UpdateCoins on the top cache
399399
CTxUndo undo;
400-
UpdateCoins(CTransaction(tx), *(stack.back()), undo, int(height));
400+
UpdateCoins(CTransaction{tx}, *(stack.back()), undo, height);
401401

402402
// Update the utxo set for future spends
403403
utxoset.insert(outpoint);

src/test/fuzz/coins_view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
211211
return;
212212
}
213213
bool expected_code_path = false;
214-
const int height = fuzzed_data_provider.ConsumeIntegral<int>();
214+
const int height{int(fuzzed_data_provider.ConsumeIntegral<uint32_t>() >> 1)};
215215
const bool possible_overwrite = fuzzed_data_provider.ConsumeBool();
216216
try {
217217
AddCoins(coins_view_cache, transaction, height, possible_overwrite);

test/sanitizer_suppressions/ubsan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ unsigned-integer-overflow:util/strencodings.cpp
6060
unsigned-integer-overflow:validation.cpp
6161
implicit-integer-sign-change:addrman.h
6262
implicit-integer-sign-change:bech32.cpp
63-
implicit-integer-sign-change:coins.h
6463
implicit-integer-sign-change:compat/stdin.cpp
6564
implicit-integer-sign-change:compressor.h
6665
implicit-integer-sign-change:crypto/

0 commit comments

Comments
 (0)