Skip to content

Commit d8b66a4

Browse files
committed
bench: added txout_index_lookahead test
1 parent 62767f0 commit d8b66a4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use bitcoin::key::Secp256k1;
2+
use criterion::{criterion_group, criterion_main, Criterion};
3+
use miniscript::{Descriptor, DescriptorPublicKey};
4+
use bdk_chain::{DescriptorExt, Indexer};
5+
use bdk_chain::keychain_txout::{ChangeSet, KeychainTxOutIndex};
6+
7+
#[test]
8+
fn cache_and_load_spks(target_index: u32) {
9+
const DESC: &str = "tr([ab28dc00/86h/1h/0h]tpubDCdDtzAMZZrkwKBxwNcGCqe4FRydeD9rfMisoi7qLdraG79YohRfPW4YgdKQhpgASdvh612xXNY5xYzoqnyCgPbkpK4LSVcH5Xv4cK7johH/0/*)";
10+
11+
let (desc, _) =
12+
<Descriptor<DescriptorPublicKey>>::parse_descriptor(&Secp256k1::new(), DESC).unwrap();
13+
let mut txout_index = KeychainTxOutIndex::new(0, false);
14+
txout_index.insert_descriptor((), desc.clone()).unwrap();
15+
let lookahead_changeset = txout_index.lookahead_to_target((), target_index);
16+
dbg!(&lookahead_changeset);
17+
}
18+
19+
fn criterion_benchmark(c: &mut Criterion) {
20+
c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
21+
}
22+
23+
criterion_group!(benches, criterion_benchmark);
24+
criterion_main!(benches);

0 commit comments

Comments
 (0)