mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-03 00:10:52 +02:00
Merge bitcoin/bitcoin#21581: streams: Accept URef obj for VectorReader unserialize
fa2204f6adef493079d1ca5148b0fdc2b55816e6 streams: Accept URef obj for VectorReader unserialize (MarcoFalke) Pull request description: Missed in commit 172f5fa738d419efda99542e2ad2a0f4db5be580. An URef may collapse into an LRef or RRef depending on context. There is no reason to forbid RRef in `VectorReader::operator>>`, so add it for consistency. ACKs for top commit: ryanofsky: Code review ACK fa2204f6adef493079d1ca5148b0fdc2b55816e6, just expanded test since last review Tree-SHA512: 09ff4e8a918e15b08cebd8c125d37e78bfb3a635c38546fc8454a97a882b2c81c55ef552243617e78744799d31127e6fbf78c4e319c030480b370aab6f38b645
This commit is contained in:
commit
3028a1e384
@ -167,7 +167,7 @@ public:
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
VectorReader& operator>>(T& obj)
|
||||
VectorReader& operator>>(T&& obj)
|
||||
{
|
||||
// Unserialize from this stream
|
||||
::Unserialize(*this, obj);
|
||||
|
@ -112,6 +112,17 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader)
|
||||
BOOST_CHECK_THROW(new_reader >> d, std::ios_base::failure);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(streams_vector_reader_rvalue)
|
||||
{
|
||||
std::vector<uint8_t> data{0x82, 0xa7, 0x31};
|
||||
VectorReader reader(SER_NETWORK, INIT_PROTO_VERSION, data, /* pos= */ 0);
|
||||
uint32_t varint = 0;
|
||||
// Deserialize into r-value
|
||||
reader >> VARINT(varint);
|
||||
BOOST_CHECK_EQUAL(varint, 54321);
|
||||
BOOST_CHECK(reader.empty());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bitstream_reader_writer)
|
||||
{
|
||||
CDataStream data(SER_NETWORK, INIT_PROTO_VERSION);
|
||||
|
Loading…
x
Reference in New Issue
Block a user