15#include <boost/test/unit_test.hpp>
57 return intval ==
rhs.intval &&
58 boolval ==
rhs.boolval &&
59 stringval ==
rhs.stringval &&
60 strcmp(charstrval,
rhs.charstrval) == 0 &&
111 for (
int i = 0; i < 100000; i++) {
117 for (
uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
124 for (
int i = 0; i < 100000; i++) {
130 for (
uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
131 uint64_t j = std::numeric_limits<uint64_t>::max();
161 std::vector<char>::size_type i,
j;
190 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};
191 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};
199 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};
202 std::array<uint8_t, 32>
array2;
212 std::vector<char>::size_type n;
215 ss << std::span{
"\xfd\x00\x00"}.first(3);
219 ss << std::span{
"\xfd\xfc\x00"}.first(3);
223 ss << std::span{
"\xfd\xfd\x00"}.first(3);
228 ss << std::span{
"\xfe\x00\x00\x00\x00"}.first(5);
232 ss << std::span{
"\xfe\xff\xff\x00\x00"}.first(5);
236 ss << std::span{
"\xff\x00\x00\x00\x00\x00\x00\x00\x00"}.first(9);
240 ss << std::span{
"\xff\xff\xff\xff\x01\x00\x00\x00\x00"}.first(9);
248 std::string stringval(
"testing");
249 const uint8_t charstrval[16]{
"testing charstr"};
272 const std::string in{
"ab"};
273 ds << std::span{in} << std::byte{
'c'};
274 std::array<std::byte, 2> out;
302 template <
typename Stream>
312 template <
typename Stream>
318 std::string
hex{
"aa"};
319 s >> std::span{
hex}.first(
hex.size());
371 template <
typename Stream>
378 template <
typename Stream>
455 std::vector<Base> v{
Base{0x0F},
Base{0xFF}};
462 v[0].m_base_data = 0;
463 v[1].m_base_data = 0;
474 v[0].m_base_data = 0;
475 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)
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
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.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static 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...
static constexpr uint64_t MAX_SIZE
The maximum size of a serialized object in bytes or number of elements (for eg vectors) when the size...
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
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.