diff options
author | fanquake <fanquake@gmail.com> | 2023-11-14 15:38:29 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-11-14 15:44:12 +0000 |
commit | 8992a34ee4b6941eb823f47fd9b1803489af94a8 (patch) | |
tree | eff31a95f5789eeeab87250feb4ed361e8e28214 /src/test | |
parent | fb85bb277670aad28fef51b7313d4a96cdaa760f (diff) | |
parent | 1e5b86171e81ab4b022b9746bb06e1968ecf4086 (diff) | |
download | bitcoin-8992a34ee4b6941eb823f47fd9b1803489af94a8.tar.xz |
Merge bitcoin/bitcoin#28857: test, refactor: Magic bytes array followup
1e5b86171e81ab4b022b9746bb06e1968ecf4086 test: Add test for array serialization (TheCharlatan)
d49d1988406f2f0d350bc5b552625f9823090130 refactor: Initialize magic bytes in constructor initializer (TheCharlatan)
Pull request description:
This is a followup-PR for #28423
* Initialize magic bytes in constructor
* Add a small unit test for serializing arrays.
ACKs for top commit:
sipa:
utACK 1e5b86171e81ab4b022b9746bb06e1968ecf4086
maflcko:
lgtm ACK 1e5b86171e81ab4b022b9746bb06e1968ecf4086
Tree-SHA512: 0f58d2332dc501ca9fd419f40ed4f977c83dce0169e9a0eee1ffc9f8daa2d2ef7e7df18205ba076f55d90ae6c4a20d2b51ab303150d38470a962bcc58a66f6e7
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/serialize_tests.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 49827be559..ec4ffbfb7c 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -85,6 +85,8 @@ BOOST_AUTO_TEST_CASE(sizes) BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U); BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U); BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}, 0), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}, 0), 2U); } BOOST_AUTO_TEST_CASE(varints) @@ -179,6 +181,16 @@ BOOST_AUTO_TEST_CASE(vector_bool) BOOST_CHECK((HashWriter{} << vec1).GetHash() == (HashWriter{} << vec2).GetHash()); } +BOOST_AUTO_TEST_CASE(array) +{ + std::array<uint8_t, 32> array1{1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1}; + DataStream ds; + ds << array1; + std::array<uint8_t, 32> array2; + ds >> array2; + BOOST_CHECK(array1 == array2); +} + BOOST_AUTO_TEST_CASE(noncanonical) { // Write some non-canonical CompactSize encodings, and |