Skip to content

Commit

Permalink
Merge pull request #214 from alfonzii/fix/benchmarks-not-working-fix
Browse files Browse the repository at this point in the history
Changes of types for working benchmarks
  • Loading branch information
Tibo-lg authored May 7, 2024
2 parents af15d5b + c165dde commit 240c274
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dlc-manager/benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bitcoin::hashes::Hash;
use bitcoin::OutPoint;
use bitcoin::Script;
use bitcoin::ScriptBuf;
use bitcoin::WPubkeyHash;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dlc::create_dlc_transactions;
Expand Down Expand Up @@ -138,8 +138,8 @@ fn get_pubkey() -> secp256k1_zkp::PublicKey {
secp256k1_zkp::PublicKey::from_secret_key(SECP256K1, &SecretKey::new(&mut thread_rng()))
}

fn get_p2wpkh_script_pubkey() -> Script {
Script::new_v0_p2wpkh(&WPubkeyHash::hash(&get_pubkey().serialize()))
fn get_p2wpkh_script_pubkey() -> ScriptBuf {
ScriptBuf::new_v0_p2wpkh(&WPubkeyHash::hash(&get_pubkey().serialize()))
}

fn create_oracle_announcements() -> Vec<OracleAnnouncement> {
Expand Down Expand Up @@ -174,7 +174,7 @@ fn create_contract_info() -> ContractInfo {
fn create_txinputinfo_vec() -> Vec<TxInputInfo> {
let tx_input_info = TxInputInfo {
outpoint: OutPoint::default(),
redeem_script: Script::new(),
redeem_script: ScriptBuf::new(),
max_witness_len: 108,
serial_id: 2,
};
Expand Down
17 changes: 12 additions & 5 deletions dlc/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ extern crate test;
#[cfg(all(test, feature = "unstable"))]
mod benches {

use bitcoin::{Script, Transaction};
use bitcoin::{ScriptBuf, Transaction};
use bitcoin_test_utils::tx_from_string;
use dlc::*;
use rayon::prelude::*;
use secp256k1_zkp::{
global::SECP256K1, rand::thread_rng, rand::RngCore, Message, PublicKey, SecretKey,
global::SECP256K1, rand::thread_rng, rand::RngCore, KeyPair, Message, PublicKey, SecretKey,
};

use test::{black_box, Bencher};
Expand All @@ -28,10 +28,17 @@ mod benches {
const ALL_BASE: usize = 2;

fn generate_oracle_info(nb_nonces: usize) -> OracleInfo {
let public_key = SECP256K1.generate_schnorrsig_keypair(&mut thread_rng()).1;
let public_key = KeyPair::new(SECP256K1, &mut thread_rng())
.x_only_public_key()
.0;

let mut nonces = Vec::with_capacity(nb_nonces);
for _ in 0..nb_nonces {
nonces.push(SECP256K1.generate_schnorrsig_keypair(&mut thread_rng()).1);
nonces.push(
KeyPair::new(SECP256K1, &mut thread_rng())
.x_only_public_key()
.0,
);
}

OracleInfo { public_key, nonces }
Expand Down Expand Up @@ -116,7 +123,7 @@ mod benches {
tx_from_string("02000000019246862ea34db0833bd4bd9e657d61e2e5447d0438f6f6181d1cd329e8cf71c30000000000ffffffff02603bea0b000000001600145dedfbf9ea599dd4e3ca6a80b333c472fd0b3f69a0860100000000001600149652d86bedf43ad264362e6e6eba6eb76450812700000000")
}

fn funding_script_pubkey() -> Script {
fn funding_script_pubkey() -> ScriptBuf {
let seckey = SecretKey::new(&mut thread_rng());
make_funding_redeemscript(
&PublicKey::from_secret_key(SECP256K1, &seckey),
Expand Down

0 comments on commit 240c274

Please sign in to comment.