diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-03-25 07:34:54 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-03-25 07:35:03 -0400 |
commit | 3f5107d008e15efa364c53bd3ed4e819cd2c6712 (patch) | |
tree | 801b3e821db3766a5eb0edf2eaf1817031116aad /src/test/fuzz/integer.cpp | |
parent | 5b4a9f4bdf9d90f29921425e13e50a0076edffab (diff) | |
parent | 102f3267e9e7925a7ea42f1181303cf1da8ce643 (diff) |
Merge #18423: tests: Add fuzzing harness for classes/functions in blockfilter.h. Add integer {de,}serialization fuzzing.
102f3267e9e7925a7ea42f1181303cf1da8ce643 tests: Add fuzzing harness for classes/functions in blockfilter.h (practicalswift)
87d24e67bb8f6a01ff710df4f14cb7d1caf651ae tests: Add integer serialization/deserialization fuzzing harness (practicalswift)
Pull request description:
Add fuzzing harness for classes/functions in `blockfilter.h`.
Add integer serialization/deserialization fuzzing harness.
Top commit has no ACKs.
Tree-SHA512: 729e6bc1adf5873a64ca334a0ddc279c6cddf208923ca37cec712e9c73d0216a641045e10084925b055230f9d31fbd85ba61e59e4da3f865a544c5f8afc05e05
Diffstat (limited to 'src/test/fuzz/integer.cpp')
-rw-r--r-- | src/test/fuzz/integer.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/fuzz/integer.cpp b/src/test/fuzz/integer.cpp index 24459c21be..63b9296574 100644 --- a/src/test/fuzz/integer.cpp +++ b/src/test/fuzz/integer.cpp @@ -227,4 +227,44 @@ void test_one_input(const std::vector<uint8_t>& buffer) (void)HasAllDesirableServiceFlags(service_flags); (void)MayHaveUsefulAddressDB(service_flags); } + + { + CDataStream stream(SER_NETWORK, INIT_PROTO_VERSION); + + ser_writedata64(stream, u64); + const uint64_t deserialized_u64 = ser_readdata64(stream); + assert(u64 == deserialized_u64 && stream.empty()); + + ser_writedata32(stream, u32); + const uint32_t deserialized_u32 = ser_readdata32(stream); + assert(u32 == deserialized_u32 && stream.empty()); + + ser_writedata32be(stream, u32); + const uint32_t deserialized_u32be = ser_readdata32be(stream); + assert(u32 == deserialized_u32be && stream.empty()); + + ser_writedata16(stream, u16); + const uint16_t deserialized_u16 = ser_readdata16(stream); + assert(u16 == deserialized_u16 && stream.empty()); + + ser_writedata16be(stream, u16); + const uint16_t deserialized_u16be = ser_readdata16be(stream); + assert(u16 == deserialized_u16be && stream.empty()); + + ser_writedata8(stream, u8); + const uint8_t deserialized_u8 = ser_readdata8(stream); + assert(u8 == deserialized_u8 && stream.empty()); + } + + { + CDataStream stream(SER_NETWORK, INIT_PROTO_VERSION); + + WriteCompactSize(stream, u64); + try { + const uint64_t deserialized_u64 = ReadCompactSize(stream); + assert(u64 == deserialized_u64 && stream.empty()); + } + catch (const std::ios_base::failure&) { + } + } } |