diff options
author | Pieter Wuille <pieter@wuille.net> | 2021-12-06 15:45:38 -0500 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2021-12-06 16:18:14 -0500 |
commit | 31ba1af74a0aaec690a01ea061264a6d5039d885 (patch) | |
tree | 9c2d76a9fd160cece7095a8beddb35af586318e5 /src/test/streams_tests.cpp | |
parent | 786ffb3ae488061e13c02ad3fb34a5d2fc785b3d (diff) | |
download | bitcoin-31ba1af74a0aaec690a01ea061264a6d5039d885.tar.xz |
Remove unused (and broken) functionality in SpanReader
This removes the ability to set an offset in the SpanReader constructor,
as the current code is broken. All call sites use pos=0, so it is actually
unused. If future call sites need it, SpanReader{a, b, c, d} is equivalent
to SpanReader{a, b, c.subspan(d)}.
It also removes the ability to deserialize from SpanReader directly from
the constructor. This too is unused, and can be more idiomatically
simulated using (SpanReader{a, b, c} >> x >> y >> z) instead of
SpanReader{a, b, c, x, y, z}.
Diffstat (limited to 'src/test/streams_tests.cpp')
-rw-r--r-- | src/test/streams_tests.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp index f551663789..8d44e92f97 100644 --- a/src/test/streams_tests.cpp +++ b/src/test/streams_tests.cpp @@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader) { std::vector<unsigned char> vch = {1, 255, 3, 4, 5, 6}; - SpanReader reader{SER_NETWORK, INIT_PROTO_VERSION, vch, 0}; + SpanReader reader{SER_NETWORK, INIT_PROTO_VERSION, vch}; BOOST_CHECK_EQUAL(reader.size(), 6U); BOOST_CHECK(!reader.empty()); @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader) BOOST_CHECK_THROW(reader >> d, std::ios_base::failure); // Read a 4 bytes as a signed int from the beginning of the buffer. - SpanReader new_reader{SER_NETWORK, INIT_PROTO_VERSION, vch, 0}; + SpanReader new_reader{SER_NETWORK, INIT_PROTO_VERSION, vch}; new_reader >> d; BOOST_CHECK_EQUAL(d, 67370753); // 1,255,3,4 in little-endian base-256 BOOST_CHECK_EQUAL(new_reader.size(), 2U); @@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader) BOOST_AUTO_TEST_CASE(streams_vector_reader_rvalue) { std::vector<uint8_t> data{0x82, 0xa7, 0x31}; - SpanReader reader{SER_NETWORK, INIT_PROTO_VERSION, data, /* pos= */ 0}; + SpanReader reader{SER_NETWORK, INIT_PROTO_VERSION, data}; uint32_t varint = 0; // Deserialize into r-value reader >> VARINT(varint); |