Skip to content

Commit

Permalink
Revert "Fix fuzz tests (ordinals#3416)"
Browse files Browse the repository at this point in the history
This reverts commit 3de5a71.
  • Loading branch information
harutyunaraci authored Apr 2, 2024
1 parent 3de5a71 commit d1af770
Show file tree
Hide file tree
Showing 19 changed files with 651 additions and 619 deletions.
1,209 changes: 612 additions & 597 deletions fuzz/Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ arbitrary = { version = "1", features = ["derive"] }
bitcoin = { version = "0.30.0", features = ["rand"] }
libfuzzer-sys = "0.4"
ord = { path = ".." }
ordinals = { path = "../crates/ordinals" }

[[bin]]
name = "runestone-decipher"
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/runestone_decipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
Transaction, TxOut,
},
libfuzzer_sys::fuzz_target,
ordinals::Runestone,
ord::runes::Runestone,
};

fuzz_target!(|input: Vec<Vec<u8>>| {
Expand Down
3 changes: 1 addition & 2 deletions fuzz/fuzz_targets/transaction_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use {
Amount, OutPoint,
},
libfuzzer_sys::fuzz_target,
ord::{FeeRate, Target, TransactionBuilder},
ordinals::SatPoint,
ord::{FeeRate, SatPoint, Target, TransactionBuilder},
std::collections::{BTreeMap, BTreeSet},
};

Expand Down
9 changes: 3 additions & 6 deletions fuzz/fuzz_targets/varint_decode.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#![no_main]

use {libfuzzer_sys::fuzz_target, ordinals::varint};
use {libfuzzer_sys::fuzz_target, ord::runes::varint};

fuzz_target!(|input: &[u8]| {
let mut i = 0;

while i < input.len() {
let Some((decoded, length)) = varint::decode(&input[i..]) else {
break;
};
let (decoded, length) = varint::decode(&input[i..]);
let mut encoded = Vec::new();
varint::encode_to_vec(decoded, &mut encoded);
let (redecoded, redecoded_length) = varint::decode(&input[i..]).unwrap();
let (redecoded, _) = varint::decode(&input[i..]);
assert_eq!(redecoded, decoded);
assert_eq!(redecoded_length, length);
i += length;
}
});
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/varint_encode.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#![no_main]

use {libfuzzer_sys::fuzz_target, ordinals::varint};
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();
let (decoded, length) = varint::decode(&encoded);
assert_eq!(length, encoded.len());
assert_eq!(decoded, input);
});
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ fuzz:
set -euxo pipefail
cd fuzz
while true; do
cargo +nightly fuzz run transaction-builder -- -max_total_time=60
cargo +nightly fuzz run runestone-decipher -- -max_total_time=60
cargo +nightly fuzz run varint-decode -- -max_total_time=60
cargo +nightly fuzz run varint-encode -- -max_total_time=60
cargo +nightly fuzz run transaction-builder -- -max_total_time=60
done
open:
Expand Down
2 changes: 1 addition & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use {
std::{
collections::HashMap,
io::{BufWriter, Write},
sync::Once,
sync::{Mutex, Once},
},
};

Expand Down
1 change: 1 addition & 0 deletions src/inscriptions/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use {
bitcoin::blockdata::{
opcodes,
script::{
self,
Instruction::{self, Op, PushBytes},
Instructions,
},
Expand Down
7 changes: 5 additions & 2 deletions src/inscriptions/inscription.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use {
super::*,
anyhow::ensure,
bitcoin::blockdata::opcodes,
bitcoin::{
blockdata::{opcodes, script},
ScriptBuf,
},
brotli::enc::{writer::CompressorWriter, BrotliEncoderParams},
http::header::HeaderValue,
io::Write,
io::{Cursor, Read, Write},
std::str,
};

Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use {
caches::DirCache,
AcmeConfig,
},
std::{cmp::Ordering, str, sync::Arc},
std::{cmp::Ordering, io::Read, str, sync::Arc},
tokio_stream::StreamExt,
tower_http::{
compression::CompressionLayer,
Expand Down
5 changes: 4 additions & 1 deletion src/subcommand/server/server_config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use {super::*, axum::http::HeaderName};
use {
super::*,
axum::http::{header, HeaderName},
};

#[derive(Default)]
pub(crate) struct ServerConfig {
Expand Down
1 change: 1 addition & 0 deletions src/subcommand/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use {
super::*,
crate::wallet::{batch, Wallet},
bitcoincore_rpc::bitcoincore_rpc_json::ListDescriptorsResult,
reqwest::Url,
shared_args::SharedArgs,
};

Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/wallet/balance.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::*;
use {super::*, std::collections::BTreeSet};

#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct Output {
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/wallet/cardinals.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::*;
use {super::*, std::collections::BTreeSet};

#[derive(Serialize, Deserialize)]
pub struct CardinalUtxo {
Expand Down
7 changes: 6 additions & 1 deletion src/subcommand/wallet/send.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use {super::*, crate::outgoing::Outgoing, base64::Engine, bitcoin::psbt::Psbt};
use {
super::*,
crate::{outgoing::Outgoing, wallet::transaction_builder::Target},
base64::Engine,
bitcoin::psbt::Psbt,
};

#[derive(Debug, Parser)]
pub(crate) struct Send {
Expand Down
4 changes: 4 additions & 0 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ pub(crate) trait PageContent: Display + 'static {
{
PageHtml::new(self, server_config)
}

fn preview_image_url(&self) -> Option<Trusted<String>> {
None
}
}

#[cfg(test)]
Expand Down
4 changes: 4 additions & 0 deletions src/templates/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ impl PageContent for InscriptionHtml {
fn title(&self) -> String {
format!("Inscription {}", self.number)
}

fn preview_image_url(&self) -> Option<Trusted<String>> {
Some(Trusted(format!("/content/{}", self.id)))
}
}

#[cfg(test)]
Expand Down
3 changes: 2 additions & 1 deletion src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use {
bitcoin::{
bip32::{ChildNumber, DerivationPath, ExtendedPrivKey, Fingerprint},
psbt::Psbt,
Network,
},
bitcoincore_rpc::bitcoincore_rpc_json::{Descriptor, ImportDescriptors, Timestamp},
fee_rate::FeeRate,
Expand All @@ -14,7 +15,7 @@ use {
try_join, TryFutureExt,
},
miniscript::descriptor::{DescriptorSecretKey, DescriptorXKey, Wildcard},
reqwest::header,
reqwest::{header, Url},
transaction_builder::TransactionBuilder,
};

Expand Down

0 comments on commit d1af770

Please sign in to comment.