Changeset View
Changeset View
Standalone View
Standalone View
src/test/test_bitcoin_fuzzy.cpp
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include <config/bitcoin-config.h> | #include <config/bitcoin-config.h> | ||||
#endif | #endif | ||||
#include <addrman.h> | #include <addrman.h> | ||||
#include <blockencodings.h> | |||||
#include <chain.h> | #include <chain.h> | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <compressor.h> | #include <compressor.h> | ||||
#include <consensus/merkle.h> | #include <consensus/merkle.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <protocol.h> | #include <protocol.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
Show All 23 Lines | enum TEST_ID { | ||||
CNETADDR_DESERIALIZE, | CNETADDR_DESERIALIZE, | ||||
CSERVICE_DESERIALIZE, | CSERVICE_DESERIALIZE, | ||||
CMESSAGEHEADER_DESERIALIZE, | CMESSAGEHEADER_DESERIALIZE, | ||||
CADDRESS_DESERIALIZE, | CADDRESS_DESERIALIZE, | ||||
CINV_DESERIALIZE, | CINV_DESERIALIZE, | ||||
CBLOOMFILTER_DESERIALIZE, | CBLOOMFILTER_DESERIALIZE, | ||||
CDISKBLOCKINDEX_DESERIALIZE, | CDISKBLOCKINDEX_DESERIALIZE, | ||||
CTXOUTCOMPRESSOR_DESERIALIZE, | CTXOUTCOMPRESSOR_DESERIALIZE, | ||||
BLOCKTRANSACTIONS_DESERIALIZE, | |||||
BLOCKTRANSACTIONSREQUEST_DESERIALIZE, | |||||
TEST_ID_END | TEST_ID_END | ||||
}; | }; | ||||
static bool read_stdin(std::vector<char> &data) { | static bool read_stdin(std::vector<char> &data) { | ||||
char buffer[1024]; | char buffer[1024]; | ||||
ssize_t length = 0; | ssize_t length = 0; | ||||
while ((length = read(STDIN_FILENO, buffer, 1024)) > 0) { | while ((length = read(STDIN_FILENO, buffer, 1024)) > 0) { | ||||
data.insert(data.end(), buffer, buffer + length); | data.insert(data.end(), buffer, buffer + length); | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | switch (test_id) { | ||||
try { | try { | ||||
ds >> toc; | ds >> toc; | ||||
} catch (const std::ios_base::failure &e) { | } catch (const std::ios_base::failure &e) { | ||||
return 0; | return 0; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
case BLOCKTRANSACTIONS_DESERIALIZE: { | |||||
try { | |||||
BlockTransactions bt; | |||||
ds >> bt; | |||||
} catch (const std::ios_base::failure &e) { | |||||
return 0; | |||||
} | |||||
break; | |||||
} | |||||
case BLOCKTRANSACTIONSREQUEST_DESERIALIZE: { | |||||
try { | |||||
BlockTransactionsRequest btr; | |||||
ds >> btr; | |||||
} catch (const std::ios_base::failure &e) { | |||||
return 0; | |||||
} | |||||
break; | |||||
} | |||||
default: | default: | ||||
return 0; | return 0; | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
int main(int argc, char **argv) { | int main(int argc, char **argv) { | ||||
ECCVerifyHandle globalVerifyHandle; | ECCVerifyHandle globalVerifyHandle; | ||||
Show All 17 Lines |