Changeset View
Changeset View
Standalone View
Standalone View
src/test/fuzz/string.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | void test_one_input(const std::vector<uint8_t> &buffer) { | ||||
try { | try { | ||||
throw scriptnum_error{random_string_1}; | throw scriptnum_error{random_string_1}; | ||||
} catch (const std::runtime_error &) { | } catch (const std::runtime_error &) { | ||||
} | } | ||||
{ | { | ||||
CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; | CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; | ||||
std::string s; | std::string s; | ||||
LimitedString<10> limited_string = LIMITED_STRING(s, 10); | auto limited_string = LIMITED_STRING(s, 10); | ||||
data_stream << random_string_1; | data_stream << random_string_1; | ||||
try { | try { | ||||
data_stream >> limited_string; | data_stream >> limited_string; | ||||
assert(data_stream.empty()); | assert(data_stream.empty()); | ||||
assert(s.size() <= random_string_1.size()); | assert(s.size() <= random_string_1.size()); | ||||
assert(s.size() <= 10); | assert(s.size() <= 10); | ||||
if (!random_string_1.empty()) { | if (!random_string_1.empty()) { | ||||
assert(!s.empty()); | assert(!s.empty()); | ||||
} | } | ||||
} catch (const std::ios_base::failure &) { | } catch (const std::ios_base::failure &) { | ||||
} | } | ||||
} | } | ||||
{ | { | ||||
CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; | CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; | ||||
const LimitedString<10> limited_string = | const auto limited_string = LIMITED_STRING(random_string_1, 10); | ||||
LIMITED_STRING(random_string_1, 10); | |||||
data_stream << limited_string; | data_stream << limited_string; | ||||
std::string deserialized_string; | std::string deserialized_string; | ||||
data_stream >> deserialized_string; | data_stream >> deserialized_string; | ||||
assert(data_stream.empty()); | assert(data_stream.empty()); | ||||
assert(deserialized_string == random_string_1); | assert(deserialized_string == random_string_1); | ||||
} | } | ||||
{ | { | ||||
int64_t amount_out; | int64_t amount_out; | ||||
Show All 12 Lines |