-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
9 changed files
with
119 additions
and
17 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#![no_main] | ||
|
||
use { | ||
bitcoin::{ | ||
locktime, opcodes, | ||
script::{self, PushBytes}, | ||
Transaction, TxOut, | ||
}, | ||
libfuzzer_sys::fuzz_target, | ||
ord::runes::Runestone, | ||
}; | ||
|
||
fuzz_target!(|input: Vec<Vec<u8>>| { | ||
let mut builder = script::Builder::new() | ||
.push_opcode(opcodes::all::OP_RETURN) | ||
.push_slice(b"RUNE_TEST"); | ||
|
||
for slice in input { | ||
let Ok(push): Result<&PushBytes, _> = slice.as_slice().try_into() else { | ||
continue; | ||
}; | ||
builder = builder.push_slice(push); | ||
} | ||
|
||
let tx = Transaction { | ||
input: Vec::new(), | ||
lock_time: locktime::absolute::LockTime::ZERO, | ||
output: vec![TxOut { | ||
script_pubkey: builder.into_script(), | ||
value: 0, | ||
}], | ||
version: 0, | ||
}; | ||
|
||
Runestone::from_transaction(&tx); | ||
}); |
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,17 @@ | ||
#![no_main] | ||
|
||
use {libfuzzer_sys::fuzz_target, ord::runes::varint}; | ||
|
||
fuzz_target!(|input: &[u8]| { | ||
let mut i = 0; | ||
|
||
while i < input.len() { | ||
let Ok((decoded, length)) = varint::decode(&input[i..]) else { | ||
break; | ||
}; | ||
let mut encoded = Vec::new(); | ||
varint::encode_to_vec(decoded, &mut encoded); | ||
assert_eq!(encoded, &input[i..i + length]); | ||
i += length; | ||
} | ||
}); |
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,11 @@ | ||
#![no_main] | ||
|
||
use {libfuzzer_sys::fuzz_target, ord::runes::varint}; | ||
|
||
fuzz_target!(|input: u128| { | ||
let mut encoded = Vec::new(); | ||
varint::encode_to_vec(input, &mut encoded); | ||
let (decoded, length) = varint::decode(&encoded).unwrap(); | ||
assert_eq!(length, encoded.len()); | ||
assert_eq!(decoded, input); | ||
}); |
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