-
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.
- Loading branch information
Showing
6 changed files
with
61 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
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,31 @@ | ||
#include <fuzzer/FuzzedDataProvider.h> | ||
#include <iostream> | ||
#include <stdio.h> | ||
|
||
#include "script.h" | ||
#include "bitcoin/src/streams.h" | ||
#include "bitcoin/src/script/script.h" | ||
|
||
extern "C" bool rust_bitcoin_script(uint8_t *data, size_t len); | ||
|
||
bool CoreScript(Span<const uint8_t> buffer) | ||
{ | ||
DataStream ds{buffer}; | ||
CScript script; | ||
try { | ||
ds >> script; | ||
} catch (const std::ios_base::failure& e) { | ||
return false; | ||
} | ||
if (script.IsUnspendable()) return false; | ||
return true; | ||
} | ||
|
||
|
||
void Script(FuzzedDataProvider& provider) | ||
{ | ||
std::vector<uint8_t> buffer{provider.ConsumeRemainingBytes<uint8_t>()}; | ||
bool core{CoreScript(buffer)}; | ||
bool rust_bitcoin{rust_bitcoin_script(buffer.data(), buffer.size())}; | ||
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 SCRIPT_H | ||
#define SCRIPT_H | ||
|
||
#include <fuzzer/FuzzedDataProvider.h> | ||
|
||
void Script(FuzzedDataProvider& provider); | ||
#endif |