mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-19 06:54:25 +01:00
Fix clippy test issues (#850)
* Fix clippy test issues * Address review feedback
This commit is contained in:
@@ -5,5 +5,5 @@ set -e
|
|||||||
# Cargo syntax checks
|
# Cargo syntax checks
|
||||||
dirs=("lib" "cli")
|
dirs=("lib" "cli")
|
||||||
for dir in ${dirs[@]}; do
|
for dir in ${dirs[@]}; do
|
||||||
(cd $dir; exec cargo fmt; exec cargo clippy -- -D warnings)
|
(cd $dir; exec cargo fmt; exec cargo clippy --all-targets -- -D warnings)
|
||||||
done
|
done
|
||||||
|
|||||||
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -48,11 +48,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Clippy bindings
|
- name: Clippy bindings
|
||||||
working-directory: lib/bindings
|
working-directory: lib/bindings
|
||||||
run: cargo clippy -- -D warnings
|
run: cargo clippy --all-targets -- -D warnings
|
||||||
|
|
||||||
- name: Clippy core
|
- name: Clippy core
|
||||||
working-directory: lib/core
|
working-directory: lib/core
|
||||||
run: cargo clippy -- -D warnings
|
run: cargo clippy --all-targets -- -D warnings
|
||||||
|
|
||||||
- name: Clippy cli
|
- name: Clippy cli
|
||||||
working-directory: cli
|
working-directory: cli
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -12,10 +12,8 @@ fmt:
|
|||||||
clippy: cargo-clippy wasm-clippy
|
clippy: cargo-clippy wasm-clippy
|
||||||
|
|
||||||
cargo-clippy:
|
cargo-clippy:
|
||||||
cd lib/bindings && cargo clippy -- -D warnings
|
cd lib/bindings && cargo clippy --all-targets -- -D warnings
|
||||||
cd lib/bindings && cargo clippy --tests -- -D warnings
|
cd lib/core && cargo clippy --all-targets -- -D warnings
|
||||||
cd lib/core && cargo clippy -- -D warnings
|
|
||||||
cd lib/core && cargo clippy --tests -- -D warnings
|
|
||||||
cd cli && cargo clippy -- -D warnings
|
cd cli && cargo clippy -- -D warnings
|
||||||
|
|
||||||
wasm-clippy:
|
wasm-clippy:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ test: cargo-test wasm-test
|
|||||||
regtest-test: cargo-regtest-test wasm-regtest-test
|
regtest-test: cargo-regtest-test wasm-regtest-test
|
||||||
|
|
||||||
cargo-clippy:
|
cargo-clippy:
|
||||||
cargo clippy -- -D warnings
|
cargo clippy --all-targets -- -D warnings
|
||||||
|
|
||||||
cargo-test:
|
cargo-test:
|
||||||
cargo test
|
cargo test
|
||||||
@@ -40,7 +40,7 @@ cargo-regtest-test: check-regtest
|
|||||||
$(REGTEST_PREFIX) cargo test $(REGTEST_TESTS) --features "regtest"
|
$(REGTEST_PREFIX) cargo test $(REGTEST_TESTS) --features "regtest"
|
||||||
|
|
||||||
wasm-clippy:
|
wasm-clippy:
|
||||||
$(CLANG_PREFIX) cargo clippy --target=wasm32-unknown-unknown -- -D warnings
|
$(CLANG_PREFIX) cargo clippy --all-targets --target=wasm32-unknown-unknown -- -D warnings
|
||||||
|
|
||||||
BROWSER ?= firefox
|
BROWSER ?= firefox
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
#[cfg(test)]
|
#![cfg(test)]
|
||||||
mod tests {
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use bip39::rand::{self, RngCore};
|
use bip39::rand::{self, RngCore};
|
||||||
use lwk_wollet::bitcoin;
|
use lwk_wollet::bitcoin;
|
||||||
use lwk_wollet::elements::address::AddressParams;
|
use lwk_wollet::elements::address::AddressParams;
|
||||||
use lwk_wollet::elements::confidential::{
|
use lwk_wollet::elements::confidential::{Asset, AssetBlindingFactor, Value, ValueBlindingFactor};
|
||||||
Asset, AssetBlindingFactor, Value, ValueBlindingFactor,
|
|
||||||
};
|
|
||||||
use lwk_wollet::elements::secp256k1_zkp::SecretKey;
|
use lwk_wollet::elements::secp256k1_zkp::SecretKey;
|
||||||
use lwk_wollet::elements::{secp256k1_zkp, Address, AssetId, Script, TxOutSecrets, Txid};
|
use lwk_wollet::elements::{secp256k1_zkp, Address, AssetId, Script, TxOutSecrets, Txid};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@@ -26,8 +23,7 @@ mod tests {
|
|||||||
fn create_test_input(asset_id: AssetId, sk: &SecretKey) -> PsetInput {
|
fn create_test_input(asset_id: AssetId, sk: &SecretKey) -> PsetInput {
|
||||||
// Create a dummy txid
|
// Create a dummy txid
|
||||||
let txid =
|
let txid =
|
||||||
Txid::from_str("0000000000000000000000000000000000000000000000000000000000000001")
|
Txid::from_str("0000000000000000000000000000000000000000000000000000000000000001").unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Create a dummy script pubkey
|
// Create a dummy script pubkey
|
||||||
let script_pub_key =
|
let script_pub_key =
|
||||||
@@ -37,11 +33,8 @@ mod tests {
|
|||||||
let secp = secp256k1_zkp::Secp256k1::new();
|
let secp = secp256k1_zkp::Secp256k1::new();
|
||||||
|
|
||||||
let asset_bf = AssetBlindingFactor::from_slice(&sk.secret_bytes()).unwrap();
|
let asset_bf = AssetBlindingFactor::from_slice(&sk.secret_bytes()).unwrap();
|
||||||
let asset_gen = secp256k1_zkp::Generator::new_blinded(
|
let asset_gen =
|
||||||
&secp,
|
secp256k1_zkp::Generator::new_blinded(&secp, asset_id.into_tag(), asset_bf.into_inner());
|
||||||
asset_id.into_tag(),
|
|
||||||
asset_bf.into_inner(),
|
|
||||||
);
|
|
||||||
let asset_commitment = Asset::Confidential(asset_gen);
|
let asset_commitment = Asset::Confidential(asset_gen);
|
||||||
|
|
||||||
// Create a Pedersen commitment for the value
|
// Create a Pedersen commitment for the value
|
||||||
@@ -73,8 +66,7 @@ mod tests {
|
|||||||
let secp = secp256k1_zkp::Secp256k1::new();
|
let secp = secp256k1_zkp::Secp256k1::new();
|
||||||
let blinding_key =
|
let blinding_key =
|
||||||
bitcoin::PublicKey::new(secp256k1_zkp::PublicKey::from_secret_key(&secp, sk));
|
bitcoin::PublicKey::new(secp256k1_zkp::PublicKey::from_secret_key(&secp, sk));
|
||||||
let address_pk =
|
let address_pk = bitcoin::PublicKey::new(secp256k1_zkp::PublicKey::from_secret_key(&secp, sk));
|
||||||
bitcoin::PublicKey::new(secp256k1_zkp::PublicKey::from_secret_key(&secp, sk));
|
|
||||||
|
|
||||||
let address = Address::p2pkh(
|
let address = Address::p2pkh(
|
||||||
&address_pk,
|
&address_pk,
|
||||||
@@ -197,4 +189,3 @@ mod tests {
|
|||||||
let result = construct_pset(request);
|
let result = construct_pset(request);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[cfg(test)]
|
#![cfg(test)]
|
||||||
mod tests {
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use lwk_wollet::elements::AssetId;
|
use lwk_wollet::elements::AssetId;
|
||||||
@@ -7,8 +6,8 @@ mod tests {
|
|||||||
use crate::payjoin::{
|
use crate::payjoin::{
|
||||||
model::InOut,
|
model::InOut,
|
||||||
utxo_select::{
|
utxo_select::{
|
||||||
utxo_select, utxo_select_basic, utxo_select_best, utxo_select_fixed,
|
utxo_select, utxo_select_basic, utxo_select_best, utxo_select_fixed, utxo_select_in_range,
|
||||||
utxo_select_in_range, UtxoSelectRequest,
|
UtxoSelectRequest,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -385,4 +384,3 @@ mod tests {
|
|||||||
// Check that we're not wasting fees unnecessarily
|
// Check that we're not wasting fees unnecessarily
|
||||||
assert!(selection.cost <= selection.server_fee.value);
|
assert!(selection.cost <= selection.server_fee.value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ impl LiquidChainService for MockLiquidChainService {
|
|||||||
_script: &ElementsScript,
|
_script: &ElementsScript,
|
||||||
_retries: u64,
|
_retries: u64,
|
||||||
) -> Result<Vec<LBtcHistory>> {
|
) -> Result<Vec<LBtcHistory>> {
|
||||||
Ok(self.get_history().into_iter().map(Into::into).collect())
|
Ok(self.get_history().into_iter().collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_script_history(&self, _script: &ElementsScript) -> Result<Vec<LBtcHistory>> {
|
async fn get_script_history(&self, _script: &ElementsScript) -> Result<Vec<LBtcHistory>> {
|
||||||
@@ -156,14 +156,7 @@ impl BitcoinChainService for MockBitcoinChainService {
|
|||||||
_script: &Script,
|
_script: &Script,
|
||||||
_retries: u64,
|
_retries: u64,
|
||||||
) -> Result<Vec<BtcHistory>> {
|
) -> Result<Vec<BtcHistory>> {
|
||||||
Ok(self
|
Ok(self.history.lock().unwrap().clone().into_iter().collect())
|
||||||
.history
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.map(Into::into)
|
|
||||||
.collect())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_script_history(&self, _scripts: &Script) -> Result<Vec<BtcHistory>> {
|
async fn get_script_history(&self, _scripts: &Script) -> Result<Vec<BtcHistory>> {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ init:
|
|||||||
rustup target add wasm32-unknown-unknown
|
rustup target add wasm32-unknown-unknown
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
$(CLANG_PREFIX) cargo clippy --target=wasm32-unknown-unknown -- -D warnings
|
$(CLANG_PREFIX) cargo clippy --all-targets --target=wasm32-unknown-unknown -- -D warnings
|
||||||
|
|
||||||
build: build-bundle build-deno build-node build-web
|
build: build-bundle build-deno build-node build-web
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user