Skip to content

Commit fcac16f

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24190: test: Fix sanitizer suppresions in streams_tests
faa630a test: Fix sanitizer suppresions in streams_tests (MarcoFalke) Pull request description: Two changes (that also make sense on their own) to remove the file-wide sanitizer suppression: * `FindByte` no longer takes a `char`, but an `uint8_t`, after commit 196b459. * The `key` vector of unsigned chars can be removed and inlined as initializer-list. This avoids a bunch of verbose code like `clear()` and `push_back` of `char`s. ACKs for top commit: PastaPastaPasta: utACK faa630a, I have reviewed the changes and agree it makes sense to merge Tree-SHA512: 747b9d4676fad6d07f3955668639c93333625e69199ff4c499f01167de3875990d93db85e775a7f5b1b684575dceaec8aa000b4db15525fc47b699bac1c85e3d
2 parents 8f137e6 + faa630a commit fcac16f

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

src/test/streams_tests.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,10 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
162162
{
163163
std::vector<std::byte> in;
164164
std::vector<char> expected_xor;
165-
std::vector<unsigned char> key;
166165
CDataStream ds(in, 0, 0);
167166

168167
// Degenerate case
169-
170-
key.push_back('\x00');
171-
key.push_back('\x00');
172-
ds.Xor(key);
168+
ds.Xor({0x00, 0x00});
173169
BOOST_CHECK_EQUAL(
174170
std::string(expected_xor.begin(), expected_xor.end()),
175171
ds.str());
@@ -183,10 +179,8 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
183179

184180
ds.clear();
185181
ds.insert(ds.begin(), in.begin(), in.end());
186-
key.clear();
187182

188-
key.push_back('\xff');
189-
ds.Xor(key);
183+
ds.Xor({0xff});
190184
BOOST_CHECK_EQUAL(
191185
std::string(expected_xor.begin(), expected_xor.end()),
192186
ds.str());
@@ -203,11 +197,7 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
203197
ds.clear();
204198
ds.insert(ds.begin(), in.begin(), in.end());
205199

206-
key.clear();
207-
key.push_back('\xff');
208-
key.push_back('\x0f');
209-
210-
ds.Xor(key);
200+
ds.Xor({0xff, 0x0f});
211201
BOOST_CHECK_EQUAL(
212202
std::string(expected_xor.begin(), expected_xor.end()),
213203
ds.str());
@@ -421,7 +411,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file_rand)
421411
size_t find = currentPos + InsecureRandRange(8);
422412
if (find >= fileSize)
423413
find = fileSize - 1;
424-
bf.FindByte(static_cast<char>(find));
414+
bf.FindByte(uint8_t(find));
425415
// The value at each offset is the offset.
426416
BOOST_CHECK_EQUAL(bf.GetPos(), find);
427417
currentPos = find;

test/sanitizer_suppressions/ubsan

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ implicit-integer-sign-change:prevector.h
7171
implicit-integer-sign-change:script/bitcoinconsensus.cpp
7272
implicit-integer-sign-change:script/interpreter.cpp
7373
implicit-integer-sign-change:serialize.h
74-
implicit-integer-sign-change:test/streams_tests.cpp
7574
implicit-integer-sign-change:txmempool.cpp
7675
implicit-integer-sign-change:zmq/zmqpublishnotifier.cpp
7776
implicit-signed-integer-truncation:addrman.cpp

0 commit comments

Comments
 (0)