16#include <boost/test/unit_test.hpp>
58 return intval ==
rhs.intval &&
59 boolval ==
rhs.boolval &&
60 stringval ==
rhs.stringval &&
61 strcmp(charstrval,
rhs.charstrval) == 0 &&
62 txval->Equals(*
rhs.txval);
112 for (
int i = 0; i < 100000; i++) {
118 for (
uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
125 for (
int i = 0; i < 100000; i++) {
131 for (
uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
132 uint64_t j = std::numeric_limits<uint64_t>::max();
162 std::vector<char>::size_type i,
j;
191 std::vector<uint8_t>
vec1{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};
192 std::vector<bool>
vec2{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};
200 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};
203 std::array<uint8_t, 32>
array2;
213 std::vector<char>::size_type n;
216 ss << std::span{
"\xfd\x00\x00"}.first(3);
220 ss << std::span{
"\xfd\xfc\x00"}.first(3);
224 ss << std::span{
"\xfd\xfd\x00"}.first(3);
229 ss << std::span{
"\xfe\x00\x00\x00\x00"}.first(5);
233 ss << std::span{
"\xfe\xff\xff\x00\x00"}.first(5);
237 ss << std::span{
"\xff\x00\x00\x00\x00\x00\x00\x00\x00"}.first(9);
241 ss << std::span{
"\xff\xff\xff\xff\x01\x00\x00\x00\x00"}.first(9);
248 for (
const char* hex : {
"fd",
"fd01",
"fe010000",
"ff01000000000000"}) {
256 const std::string_view
sv{
"hello, world"};
266 const std::vector<int> v = {1,2,3,4,-5,-6,-7,-8,-9,-10,10000,20000,-30000};
268 auto check = [&]<
size_t N>() {
276 }
catch (
const std::ios_base::failure&) {
280 check.operator()<0>();
281 check.operator()<10>();
282 check.operator()<12>();
283 check.operator()<13>();
284 check.operator()<14>();
285 check.operator()<100>();
292 std::string stringval(
"testing");
293 const uint8_t charstrval[16]{
"testing charstr"};
316 const std::string in{
"ab"};
317 ds << std::span{in} << std::byte{
'c'};
318 std::array<std::byte, 2> out;
346 template <
typename Stream>
356 template <
typename Stream>
362 std::string hex{
"aa"};
363 s >> std::span{hex}.first(hex.size());
415 template <
typename Stream>
422 template <
typename Stream>
499 std::vector<Base> v{
Base{0x0F},
Base{0xFF}};
506 v[0].m_base_data = 0;
507 v[1].m_base_data = 0;
518 v[0].m_base_data = 0;
519 v[1].m_base_data = 0;
(Un)serialize a number as raw byte or 2 hexadecimal chars.
void Unserialize(Stream &s)
void Serialize(Stream &s) const
SERIALIZE_METHODS(CSerializeMethodsTestMany, obj)
CSerializeMethodsTestSingle(int intvalin, bool boolvalin, std::string stringvalin, const uint8_t *charstrvalin, const CTransactionRef &txvalin)
CSerializeMethodsTestSingle()=default
SERIALIZE_METHODS(CSerializeMethodsTestSingle, obj)
bool operator==(const CSerializeMethodsTestSingle &rhs) const
Double ended buffer combining vector and stream-like interfaces.
vector_type::size_type size_type
std::string m_derived_data
SERIALIZE_METHODS(Derived, obj)
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
A writer stream (for serialization) that computes a 256-bit hash.
Checker for value of OtherParam.
void Unserialize(Stream &s) const
void Serialize(Stream &s) const
Wrapper that overrides the GetParams() function of a stream.
UncopyableStream & operator=(const UncopyableStream &)=delete
UncopyableStream(const UncopyableStream &)=delete
UncopyableStream(UncopyableStream &&) noexcept=default
static const PrecomputedData data
Precomputed COutPoint and CCoins values.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
std::string HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
BOOST_CHECK_GT(excessive_headers.size(), MAX_HEADERS_SIZE)
BOOST_CHECK_EXCEPTION(HTTPHeaders{}.Read(reader), std::runtime_error, HasReason{"Empty HTTP header name"})
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
constexpr TransactionSerParams TX_WITH_WITNESS
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
#define VARINT_MODE(obj, mode)
#define SER_PARAMS(type)
Formatter methods can retrieve parameters attached to a stream using the SER_PARAMS(type) macro as lo...
constexpr uint64_t MAX_SIZE
The maximum size of a serialized object in bytes or number of elements (for eg vectors) when the size...
#define LIMITED_VECTOR(obj, n)
void WriteCompactSize(SizeComputer &os, uint64_t nSize)
#define SER_READ(obj, code)
#define SER_PARAMS_OPFUNC
Helper macro for SerParams structs.
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
uint64_t GetSerializeSize(const T &t)
constexpr DerivedAndBaseFormat HEX_UPPER
constexpr DerivedAndBaseFormat RAW_LOWER
static bool isCanonicalException(const std::ios_base::failure &ex)
BOOST_AUTO_TEST_CASE(sizes)
auto MakeByteSpan(const V &v) noexcept
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
A mutable version of CTransaction.
std::string ToUpper(std::string_view str)
Returns the uppercase equivalent of the given string.
std::string ToLower(std::string_view str)
Returns the lowercase equivalent of the given string.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.