-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
4f46170
commit 12d4d33
Showing
12 changed files
with
195 additions
and
27 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 |
---|---|---|
@@ -1,27 +1,5 @@ | ||
[package] | ||
authors = [ | ||
"Yancy Ribbens <[email protected]>", | ||
[workspace] | ||
members = [ | ||
"bitcoin-coin-selection", "fuzz", | ||
] | ||
edition = "2018" | ||
homepage = "https://github.com/rust-bitcoin/rust-bitcoin-coin-selection/" | ||
license = "CC0-1.0" | ||
name = "bitcoin-coin-selection" | ||
repository = "https://github.com/rust-bitcoin/rust-bitcoin-coin-selection/" | ||
version = "0.5.0" | ||
# documentation = "https://docs.rs/bitcoin-coin-selection/" | ||
description = "Libary providing utility functions to efficiently select a set of UTXOs." | ||
keywords = ["bitcoin", "coin-selection", "coin", "coinselection", "utxo"] | ||
readme = "README.md" | ||
|
||
[dependencies] | ||
bitcoin = "0.32.2" | ||
rand = {version = "0.8.5", default-features = false, optional = true} | ||
|
||
[dev-dependencies] | ||
criterion = "0.3" | ||
bitcoin-coin-selection = {path = ".", features = ["rand"]} | ||
rand = "0.8.5" | ||
|
||
[[bench]] | ||
name = "coin_selection" | ||
harness = false | ||
resolver = "1" |
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,27 @@ | ||
[package] | ||
authors = [ | ||
"Yancy Ribbens <[email protected]>", | ||
] | ||
edition = "2018" | ||
homepage = "https://github.com/rust-bitcoin/rust-bitcoin-coin-selection/" | ||
license = "CC0-1.0" | ||
name = "bitcoin-coin-selection" | ||
repository = "https://github.com/rust-bitcoin/rust-bitcoin-coin-selection/" | ||
version = "0.5.0" | ||
# documentation = "https://docs.rs/bitcoin-coin-selection/" | ||
description = "Libary providing utility functions to efficiently select a set of UTXOs." | ||
keywords = ["bitcoin", "coin-selection", "coin", "coinselection", "utxo"] | ||
readme = "README.md" | ||
|
||
[dependencies] | ||
bitcoin = { git = "https://github.com/yancyribbens/rust-bitcoin.git", rev = "edcd2fb5d78be71a60709d18fb367fd56171ff26" } | ||
rand = {version = "0.8.5", default-features = false, optional = true} | ||
|
||
[dev-dependencies] | ||
criterion = "0.3" | ||
bitcoin-coin-selection = {path = ".", features = ["rand"]} | ||
rand = "0.8.5" | ||
|
||
[[bench]] | ||
name = "coin_selection" | ||
harness = false |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,23 @@ | ||
[package] | ||
name = "fuzz-coin-selection" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
honggfuzz = "0.5.56" | ||
bitcoin-coin-selection = { path= "../bitcoin-coin-selection", features=["rand"] } | ||
rand = "0.8.5" | ||
bitcoin = { git = "https://github.com/yancyribbens/rust-bitcoin.git", rev = "edcd2fb5d78be71a60709d18fb367fd56171ff26" } | ||
arbitrary = { version = "1", features = ["derive"] } | ||
|
||
[[bin]] | ||
name = "single_random_draw_select_coins" | ||
path = "fuzz_targets/single_random_draw_select_coins.rs" | ||
|
||
[[bin]] | ||
name = "branch_and_bound_select_coins" | ||
path = "fuzz_targets/branch_and_bound_select_coins.rs" | ||
|
||
[[bin]] | ||
name = "select_coins" | ||
path = "fuzz_targets/select_coins.rs" |
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,44 @@ | ||
use bitcoin_coin_selection::WeightedUtxo; | ||
|
||
use bitcoin_coin_selection::select_coins_bnb; | ||
use honggfuzz::fuzz; | ||
use arbitrary::Arbitrary; | ||
|
||
use bitcoin::TxOut; | ||
use bitcoin::Amount; | ||
use bitcoin::FeeRate; | ||
use bitcoin::Weight; | ||
|
||
#[derive(Arbitrary, Debug)] | ||
pub struct Utxo { | ||
output: TxOut, | ||
satisfaction_weight: Weight | ||
} | ||
|
||
impl WeightedUtxo for Utxo { | ||
fn satisfaction_weight(&self) -> Weight { | ||
self.satisfaction_weight | ||
} | ||
|
||
fn value(&self) -> Amount { | ||
self.output.value | ||
} | ||
} | ||
|
||
#[derive(Arbitrary, Debug)] | ||
pub struct Params { | ||
target: Amount, | ||
cost_of_change: Amount, | ||
fee_rate: FeeRate, | ||
long_term_fee_rate: FeeRate, | ||
weighted_utxos: Vec<Utxo>, | ||
} | ||
|
||
fn main() { | ||
loop { | ||
fuzz!(|params: Params| { | ||
let Params { target: t, cost_of_change: c, fee_rate: f, long_term_fee_rate: ltf, weighted_utxos: wu } = params; | ||
select_coins_bnb(t, c, f, ltf, &wu); | ||
}); | ||
} | ||
} |
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,44 @@ | ||
use bitcoin_coin_selection::WeightedUtxo; | ||
|
||
use bitcoin_coin_selection::select_coins; | ||
use honggfuzz::fuzz; | ||
use arbitrary::Arbitrary; | ||
|
||
use bitcoin::TxOut; | ||
use bitcoin::Amount; | ||
use bitcoin::FeeRate; | ||
use bitcoin::Weight; | ||
|
||
#[derive(Arbitrary, Debug)] | ||
pub struct Utxo { | ||
output: TxOut, | ||
satisfaction_weight: Weight | ||
} | ||
|
||
impl WeightedUtxo for Utxo { | ||
fn satisfaction_weight(&self) -> Weight { | ||
self.satisfaction_weight | ||
} | ||
|
||
fn value(&self) -> Amount { | ||
self.output.value | ||
} | ||
} | ||
|
||
#[derive(Arbitrary, Debug)] | ||
pub struct Params { | ||
target: Amount, | ||
cost_of_change: Amount, | ||
fee_rate: FeeRate, | ||
long_term_fee_rate: FeeRate, | ||
weighted_utxos: Vec<Utxo>, | ||
} | ||
|
||
fn main() { | ||
loop { | ||
fuzz!(|params: Params| { | ||
let Params { target: t, cost_of_change: c, fee_rate: f, long_term_fee_rate: ltf, weighted_utxos: wu } = params; | ||
select_coins(t, c, f, ltf, &wu); | ||
}); | ||
} | ||
} |
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,44 @@ | ||
use bitcoin_coin_selection::WeightedUtxo; | ||
|
||
use bitcoin_coin_selection::select_coins_srd; | ||
use honggfuzz::fuzz; | ||
use arbitrary::Arbitrary; | ||
|
||
use rand::thread_rng; | ||
|
||
use bitcoin::TxOut; | ||
use bitcoin::FeeRate; | ||
use bitcoin::Amount; | ||
use bitcoin::Weight; | ||
|
||
#[derive(Arbitrary, Debug)] | ||
pub struct Utxo { | ||
output: TxOut, | ||
satisfaction_weight: Weight | ||
} | ||
|
||
impl WeightedUtxo for Utxo { | ||
fn satisfaction_weight(&self) -> Weight { | ||
self.satisfaction_weight | ||
} | ||
|
||
fn value(&self) -> Amount { | ||
self.output.value | ||
} | ||
} | ||
|
||
#[derive(Arbitrary, Debug)] | ||
pub struct Params { | ||
target: Amount, | ||
fee_rate: FeeRate, | ||
weighted_utxos: Vec<Utxo>, | ||
} | ||
|
||
fn main() { | ||
loop { | ||
fuzz!(|params: Params| { | ||
let Params { target: t, fee_rate: f, weighted_utxos: wu } = params; | ||
select_coins_srd(t, f, &wu, &mut thread_rng()); | ||
}); | ||
} | ||
} |