diff options
author | fanquake <fanquake@gmail.com> | 2024-02-26 11:34:10 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2024-02-26 11:54:29 +0000 |
commit | 1ce5accc325cd7d3382f67a314dec018cfdc0a3e (patch) | |
tree | ffc2f9987ce3c0cf73e5ba550e0b578fc21e422f /src/test/serialize_tests.cpp | |
parent | 8087626cbda97f6def4fb51cdac6f204486ee6fb (diff) | |
parent | 9f13dc1ed3020d55ba79b1a62ca0db6b510357ab (diff) |
Merge bitcoin/bitcoin#29464: [25.2] Final backports and changes for 25.2rc1v25.2rc1
9f13dc1ed3020d55ba79b1a62ca0db6b510357ab doc: Update release notes for 25.2rc1 (Ava Chow)
a27662b16a626ade5f26613e9f5323edcd6e9105 doc: update manpages for 25.2rc1 (Ava Chow)
65c617178420d5904fd43399eb3c87e00aff524e build: Bump to 25.2rc1 (Ava Chow)
cf0f43ee42f0bf8d345b109b0ba552faf7cb62e1 wallet: Fix use-after-free in WalletBatch::EraseRecords (MarcoFalke)
6acfc4324cc98a10e083e5f391435bbfde4d8f69 Use only Span{} constructor for byte-like types where possible (MarcoFalke)
b40d10787b2dc161e236e50eb296bdf02f93933f util: Allow std::byte and char Span serialization (MarcoFalke)
Pull request description:
Backport:
* #29176
* #27927
#29176 does not cleanly backport, and it also requires 27927 to work. Both are still fairly simple backports.
Also does the rest of the version bump tasks for 25.2rc1.
ACKs for top commit:
fanquake:
ACK 9f13dc1ed3020d55ba79b1a62ca0db6b510357ab
Tree-SHA512: 9d9dbf415f8559410eba9a431b61a8fc94216898d2d1fd8398e1f7a22a04790faade810e65324c7a797456b33396c3a58f991e81319aaaa63d3ab441e5e20dbc
Diffstat (limited to 'src/test/serialize_tests.cpp')
-rw-r--r-- | src/test/serialize_tests.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 09f77d2b61..b445ff8ffc 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -186,32 +186,32 @@ BOOST_AUTO_TEST_CASE(noncanonical) std::vector<char>::size_type n; // zero encoded with three bytes: - ss.write(MakeByteSpan("\xfd\x00\x00").first(3)); + ss << Span{"\xfd\x00\x00"}.first(3); BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException); // 0xfc encoded with three bytes: - ss.write(MakeByteSpan("\xfd\xfc\x00").first(3)); + ss << Span{"\xfd\xfc\x00"}.first(3); BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException); // 0xfd encoded with three bytes is OK: - ss.write(MakeByteSpan("\xfd\xfd\x00").first(3)); + ss << Span{"\xfd\xfd\x00"}.first(3); n = ReadCompactSize(ss); BOOST_CHECK(n == 0xfd); // zero encoded with five bytes: - ss.write(MakeByteSpan("\xfe\x00\x00\x00\x00").first(5)); + ss << Span{"\xfe\x00\x00\x00\x00"}.first(5); BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException); // 0xffff encoded with five bytes: - ss.write(MakeByteSpan("\xfe\xff\xff\x00\x00").first(5)); + ss << Span{"\xfe\xff\xff\x00\x00"}.first(5); BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException); // zero encoded with nine bytes: - ss.write(MakeByteSpan("\xff\x00\x00\x00\x00\x00\x00\x00\x00").first(9)); + ss << Span{"\xff\x00\x00\x00\x00\x00\x00\x00\x00"}.first(9); BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException); // 0x01ffffff encoded with nine bytes: - ss.write(MakeByteSpan("\xff\xff\xff\xff\x01\x00\x00\x00\x00").first(9)); + ss << Span{"\xff\xff\xff\xff\x01\x00\x00\x00\x00"}.first(9); BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalException); } @@ -241,6 +241,15 @@ BOOST_AUTO_TEST_CASE(class_methods) ss2 << intval << boolval << stringval << charstrval << txval; ss2 >> methodtest3; BOOST_CHECK(methodtest3 == methodtest4); + { + DataStream ds; + const std::string in{"ab"}; + ds << Span{in}; + std::array<std::byte, 2> out; + ds >> Span{out}; + BOOST_CHECK_EQUAL(out.at(0), std::byte{'a'}); + BOOST_CHECK_EQUAL(out.at(1), std::byte{'b'}); + } } BOOST_AUTO_TEST_SUITE_END() |