mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 01:04:43 +02:00
Merge bitcoin/bitcoin#28857: test, refactor: Magic bytes array followup
1e5b86171etest: Add test for array serialization (TheCharlatan)d49d198840refactor: 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: utACK1e5b86171emaflcko: lgtm ACK1e5b86171eTree-SHA512: 0f58d2332dc501ca9fd419f40ed4f977c83dce0169e9a0eee1ffc9f8daa2d2ef7e7df18205ba076f55d90ae6c4a20d2b51ab303150d38470a962bcc58a66f6e7
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user