mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Merge bitcoin/bitcoin#21581: streams: Accept URef obj for VectorReader unserialize
fa2204f6adstreams: Accept URef obj for VectorReader unserialize (MarcoFalke) Pull request description: Missed in commit172f5fa738. 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 ACKfa2204f6ad, just expanded test since last review Tree-SHA512: 09ff4e8a918e15b08cebd8c125d37e78bfb3a635c38546fc8454a97a882b2c81c55ef552243617e78744799d31127e6fbf78c4e319c030480b370aab6f38b645
This commit is contained in:
commit
3028a1e384
2 changed files with 12 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue