The AsBytes helpers (or std::as_bytes helpers) are architecture
dependent. For example, the below test case diff [0], applied before
this commit will pass on x86_64, but fail on s390x [1].
Fix this by replacing AsBytes with a new ByteSpanCast in the MakeByteSpan helper.
This will turn the test case diff into a compile failure instead of a runtime error.
[0] test case diff:
diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp
index 09f77d2b61..4e56ffa351 100644
--- a/src/test/serialize_tests.cpp
+++ b/src/test/serialize_tests.cpp
@@ -241,6 +241,15 @@ BOOST_AUTO_TEST_CASE(class_methods)
ss2 << intval << boolval << stringval << charstrval << txval;
ss2 >> methodtest3;
BOOST_CHECK(methodtest3 == methodtest4);
+
+ {
+ DataStream out;
+ std::vector<uint8_t> in_8{0x00, 0x11, 0x22, 0x33};
+ std::vector<uint16_t> in_16{0xaabb, 0xccdd};
+ out.write(MakeByteSpan(in_8));
+ out.write(MakeByteSpan(in_16));
+ BOOST_CHECK_EQUAL(HexStr(out), "00112233bbaaddcc");
+ }
}
BOOST_AUTO_TEST_SUITE_END()
[1] test case failure on s390x:
test/serialize_tests.cpp(251): error: in "serialize_tests/class_methods": check HexStr(out) == "00112233bbaaddcc" has failed [00112233aabbccdd != 00112233bbaaddcc]