From 59faa52fe9bcafddd290fd8cfd75482755195ba5 Mon Sep 17 00:00:00 2001 From: aaravm Date: Mon, 26 Aug 2024 17:05:22 +0530 Subject: [PATCH] correcting warnings --- .../coordinator/src/database/db_tests.rs | 2 +- .../coordinator/src/wallet/wallet_tests.rs | 17 ++++++++--------- .../trader/src/communication/taker_requests.rs | 2 +- .../trader/src/trading/maker_utils.rs | 2 +- taptrade-cli-demo/trader/src/trading/mod.rs | 4 ++-- taptrade-cli-demo/trader/src/wallet/mod.rs | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/taptrade-cli-demo/coordinator/src/database/db_tests.rs b/taptrade-cli-demo/coordinator/src/database/db_tests.rs index 7fef77a..2053f8b 100644 --- a/taptrade-cli-demo/coordinator/src/database/db_tests.rs +++ b/taptrade-cli-demo/coordinator/src/database/db_tests.rs @@ -372,7 +372,7 @@ async fn test_fetch_taker_bond_requirements() -> Result<()> { // Call the fetch_taker_bond_requirements function let result = database - .fetch_taker_bond_requirements(&offer_id_hex.to_string()) + .fetch_taker_bond_requirements(offer_id_hex) .await?; // Verify the result diff --git a/taptrade-cli-demo/coordinator/src/wallet/wallet_tests.rs b/taptrade-cli-demo/coordinator/src/wallet/wallet_tests.rs index 11c81db..057f325 100644 --- a/taptrade-cli-demo/coordinator/src/wallet/wallet_tests.rs +++ b/taptrade-cli-demo/coordinator/src/wallet/wallet_tests.rs @@ -12,7 +12,6 @@ use bdk::{ Wallet, }; use bitcoin; -use bitcoin::consensus::Decodable; fn get_backend() -> RpcBlockchain { dotenv().ok(); @@ -152,7 +151,7 @@ async fn test_transaction_without_signature() { }; let result = test_wallet - .validate_bond_tx_hex(&bond_without_signature, &requirements) + .validate_bond_tx_hex(bond_without_signature, &requirements) .await; assert!(result.is_err()); test_wallet.shutdown().await; @@ -170,7 +169,7 @@ async fn test_transaction_with_invalid_signature() { }; let result = test_wallet - .validate_bond_tx_hex(&bond_with_invalid_signature, &requirements) + .validate_bond_tx_hex(bond_with_invalid_signature, &requirements) .await; assert!(result.is_err()); test_wallet.shutdown().await; @@ -187,7 +186,7 @@ async fn test_bond_with_spent_input() { }; let result = test_wallet - .validate_bond_tx_hex(&bond_with_spent_input, &requirements) + .validate_bond_tx_hex(bond_with_spent_input, &requirements) .await; assert!(result.is_err()); test_wallet.shutdown().await; @@ -203,7 +202,7 @@ async fn test_valid_bond_tx() { bond_address: "tb1p5yh969z6fgatg0mvcyvggd08fujnat8890vcdud277q06rr9xgmqwfdkcx".to_string(), }; - let result = test_wallet.validate_bond_tx_hex(&bond, &requirements).await; + let result = test_wallet.validate_bond_tx_hex(bond, &requirements).await; assert!(result.is_ok()); test_wallet.shutdown().await; } @@ -218,7 +217,7 @@ async fn test_invalid_bond_tx_low_input_sum() { bond_address: "tb1p5yh969z6fgatg0mvcyvggd08fujnat8890vcdud277q06rr9xgmqwfdkcx".to_string(), }; - let result = test_wallet.validate_bond_tx_hex(&bond, &requirements).await; + let result = test_wallet.validate_bond_tx_hex(bond, &requirements).await; assert!(result.is_err()); assert!(result .unwrap_err() @@ -237,7 +236,7 @@ async fn test_invalid_bond_tx_low_output_sum() { bond_address: "tb1p5yh969z6fgatg0mvcyvggd08fujnat8890vcdud277q06rr9xgmqwfdkcx".to_string(), }; - let result = test_wallet.validate_bond_tx_hex(&bond, &requirements).await; + let result = test_wallet.validate_bond_tx_hex(bond, &requirements).await; test_wallet.shutdown().await; assert!(result.is_err()); assert!(result @@ -256,7 +255,7 @@ async fn test_invalid_bond_tx_low_fee_rate() { bond_address: "tb1p5yh969z6fgatg0mvcyvggd08fujnat8890vcdud277q06rr9xgmqwfdkcx".to_string(), }; - let result = test_wallet.validate_bond_tx_hex(&bond, &requirements).await; + let result = test_wallet.validate_bond_tx_hex(bond, &requirements).await; test_wallet.shutdown().await; assert!(result.is_err()); assert!(result @@ -383,7 +382,7 @@ fn test_create_escrow_spending_psbt() { let escrow_utxo = escrow_output_wallet.list_unspent().unwrap(); dbg!(&escrow_utxo); - assert!(escrow_utxo.len() > 0); + assert!(!escrow_utxo.is_empty()); } #[test] diff --git a/taptrade-cli-demo/trader/src/communication/taker_requests.rs b/taptrade-cli-demo/trader/src/communication/taker_requests.rs index bcc4b52..b09ef9a 100644 --- a/taptrade-cli-demo/trader/src/communication/taker_requests.rs +++ b/taptrade-cli-demo/trader/src/communication/taker_requests.rs @@ -28,7 +28,7 @@ impl PublicOffers { } }; if res.status() == 204 { - return Ok(PublicOffers { offers: None }); + Ok(PublicOffers { offers: None }) } else { match res.json::() { Ok(offers) => { diff --git a/taptrade-cli-demo/trader/src/trading/maker_utils.rs b/taptrade-cli-demo/trader/src/trading/maker_utils.rs index a54499f..a9dcc34 100644 --- a/taptrade-cli-demo/trader/src/trading/maker_utils.rs +++ b/taptrade-cli-demo/trader/src/trading/maker_utils.rs @@ -29,7 +29,7 @@ impl ActiveOffer { payout_address: payout_address.address.to_string(), musig_pub_nonce_hex: hex::encode(musig_data.nonce.get_pub_for_sharing()?.serialize()), musig_pubkey_hex: hex::encode(musig_data.public_key.serialize()), - taproot_pubkey_hex: hex::encode(&trading_wallet.taproot_pubkey.serialize()), + taproot_pubkey_hex: hex::encode(trading_wallet.taproot_pubkey.serialize()), bdk_psbt_inputs_hex_csv: psbt_inputs_hex_csv.clone(), client_change_address: escrow_change_address.clone(), }; diff --git a/taptrade-cli-demo/trader/src/trading/mod.rs b/taptrade-cli-demo/trader/src/trading/mod.rs index a0938ae..33895ee 100644 --- a/taptrade-cli-demo/trader/src/trading/mod.rs +++ b/taptrade-cli-demo/trader/src/trading/mod.rs @@ -65,7 +65,7 @@ pub fn run_maker(maker_config: &TraderSettings) -> Result<()> { offer.used_musig_config, )?; // submit signed payout psbt back to coordinator - PayoutSignatureRequest::send(&maker_config, &signature, &offer.offer_id_hex)?; + PayoutSignatureRequest::send(maker_config, &signature, &offer.offer_id_hex)?; } else { warn!("Trader unsatisfied. Initiating escrow mode."); TradeObligationsUnsatisfied::request_escrow(&offer.offer_id_hex, maker_config)?; @@ -108,7 +108,7 @@ pub fn run_taker(taker_config: &TraderSettings) -> Result<()> { )?; // submit partial signature back to coordinator - PayoutSignatureRequest::send(&taker_config, &signature, &accepted_offer.offer_id_hex)?; + PayoutSignatureRequest::send(taker_config, &signature, &accepted_offer.offer_id_hex)?; // here we need to handle if the other party is not cooperating } else { error!("Trader unsatisfied. Initiating escrow mode."); diff --git a/taptrade-cli-demo/trader/src/wallet/mod.rs b/taptrade-cli-demo/trader/src/wallet/mod.rs index 425966a..efde2ff 100644 --- a/taptrade-cli-demo/trader/src/wallet/mod.rs +++ b/taptrade-cli-demo/trader/src/wallet/mod.rs @@ -251,7 +251,7 @@ impl TradingWallet { match keyspend_sig { MaybeScalar::Valid(s) => Ok(s.encode_hex()), MaybeScalar::Zero => { - return Err(anyhow!("keyspend sig maybe scalar is Zero")); + Err(anyhow!("keyspend sig maybe scalar is Zero")) } } }