-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add target for compact block messages
- Loading branch information
1 parent
7974f01
commit d03ef96
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <fuzzer/FuzzedDataProvider.h> | ||
#include <string> | ||
|
||
#include "cmpctblocks.h" | ||
#include "bitcoin/src/blockencodings.h" | ||
#include "bitcoin/src/streams.h" | ||
|
||
extern "C" char* rust_bitcoin_cmpctblocks(uint8_t *data, size_t len); | ||
|
||
std::string CmpctBlocksCore(Span<const uint8_t> buffer) | ||
{ | ||
DataStream ds{buffer}; | ||
CBlockHeaderAndShortTxIDs block_header_and_short_txids; | ||
try { | ||
ds >> block_header_and_short_txids; | ||
} catch (const std::ios_base::failure& e) { | ||
if (std::string(e.what()).find("Superfluous witness record") != std::string::npos) | ||
return "Superfluous witness record"; | ||
return "1"; | ||
} | ||
return "0"; | ||
} | ||
|
||
void CmpctBlocks(FuzzedDataProvider& provider) | ||
{ | ||
std::vector<uint8_t> buffer{provider.ConsumeRemainingBytes<uint8_t>()}; | ||
std::string core{CmpctBlocksCore(buffer)}; | ||
std::string rust_bitcoin{rust_bitcoin_cmpctblocks(buffer.data(), buffer.size())}; | ||
|
||
if (core == "Superfluous witness record" || rust_bitcoin == "unsupported segwit version") | ||
return; | ||
|
||
assert(core == rust_bitcoin); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef CMPCT_BLOCKS_H | ||
#define CMPCT_BLOCKS_H | ||
|
||
#include <fuzzer/FuzzedDataProvider.h> | ||
|
||
void CmpctBlocks(FuzzedDataProvider& provider); | ||
#endif |