correcting warnings

This commit is contained in:
aaravm
2024-08-26 17:05:22 +05:30
parent e76213441b
commit 59faa52fe9
6 changed files with 14 additions and 15 deletions

View File

@ -372,7 +372,7 @@ async fn test_fetch_taker_bond_requirements() -> Result<()> {
// Call the fetch_taker_bond_requirements function // Call the fetch_taker_bond_requirements function
let result = database let result = database
.fetch_taker_bond_requirements(&offer_id_hex.to_string()) .fetch_taker_bond_requirements(offer_id_hex)
.await?; .await?;
// Verify the result // Verify the result

View File

@ -12,7 +12,6 @@ use bdk::{
Wallet, Wallet,
}; };
use bitcoin; use bitcoin;
use bitcoin::consensus::Decodable;
fn get_backend() -> RpcBlockchain { fn get_backend() -> RpcBlockchain {
dotenv().ok(); dotenv().ok();
@ -152,7 +151,7 @@ async fn test_transaction_without_signature() {
}; };
let result = test_wallet let result = test_wallet
.validate_bond_tx_hex(&bond_without_signature, &requirements) .validate_bond_tx_hex(bond_without_signature, &requirements)
.await; .await;
assert!(result.is_err()); assert!(result.is_err());
test_wallet.shutdown().await; test_wallet.shutdown().await;
@ -170,7 +169,7 @@ async fn test_transaction_with_invalid_signature() {
}; };
let result = test_wallet let result = test_wallet
.validate_bond_tx_hex(&bond_with_invalid_signature, &requirements) .validate_bond_tx_hex(bond_with_invalid_signature, &requirements)
.await; .await;
assert!(result.is_err()); assert!(result.is_err());
test_wallet.shutdown().await; test_wallet.shutdown().await;
@ -187,7 +186,7 @@ async fn test_bond_with_spent_input() {
}; };
let result = test_wallet let result = test_wallet
.validate_bond_tx_hex(&bond_with_spent_input, &requirements) .validate_bond_tx_hex(bond_with_spent_input, &requirements)
.await; .await;
assert!(result.is_err()); assert!(result.is_err());
test_wallet.shutdown().await; test_wallet.shutdown().await;
@ -203,7 +202,7 @@ async fn test_valid_bond_tx() {
bond_address: "tb1p5yh969z6fgatg0mvcyvggd08fujnat8890vcdud277q06rr9xgmqwfdkcx".to_string(), 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()); assert!(result.is_ok());
test_wallet.shutdown().await; test_wallet.shutdown().await;
} }
@ -218,7 +217,7 @@ async fn test_invalid_bond_tx_low_input_sum() {
bond_address: "tb1p5yh969z6fgatg0mvcyvggd08fujnat8890vcdud277q06rr9xgmqwfdkcx".to_string(), 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.is_err());
assert!(result assert!(result
.unwrap_err() .unwrap_err()
@ -237,7 +236,7 @@ async fn test_invalid_bond_tx_low_output_sum() {
bond_address: "tb1p5yh969z6fgatg0mvcyvggd08fujnat8890vcdud277q06rr9xgmqwfdkcx".to_string(), 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; test_wallet.shutdown().await;
assert!(result.is_err()); assert!(result.is_err());
assert!(result assert!(result
@ -256,7 +255,7 @@ async fn test_invalid_bond_tx_low_fee_rate() {
bond_address: "tb1p5yh969z6fgatg0mvcyvggd08fujnat8890vcdud277q06rr9xgmqwfdkcx".to_string(), 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; test_wallet.shutdown().await;
assert!(result.is_err()); assert!(result.is_err());
assert!(result assert!(result
@ -383,7 +382,7 @@ fn test_create_escrow_spending_psbt() {
let escrow_utxo = escrow_output_wallet.list_unspent().unwrap(); let escrow_utxo = escrow_output_wallet.list_unspent().unwrap();
dbg!(&escrow_utxo); dbg!(&escrow_utxo);
assert!(escrow_utxo.len() > 0); assert!(!escrow_utxo.is_empty());
} }
#[test] #[test]

View File

@ -28,7 +28,7 @@ impl PublicOffers {
} }
}; };
if res.status() == 204 { if res.status() == 204 {
return Ok(PublicOffers { offers: None }); Ok(PublicOffers { offers: None })
} else { } else {
match res.json::<PublicOffers>() { match res.json::<PublicOffers>() {
Ok(offers) => { Ok(offers) => {

View File

@ -29,7 +29,7 @@ impl ActiveOffer {
payout_address: payout_address.address.to_string(), payout_address: payout_address.address.to_string(),
musig_pub_nonce_hex: hex::encode(musig_data.nonce.get_pub_for_sharing()?.serialize()), musig_pub_nonce_hex: hex::encode(musig_data.nonce.get_pub_for_sharing()?.serialize()),
musig_pubkey_hex: hex::encode(musig_data.public_key.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(), bdk_psbt_inputs_hex_csv: psbt_inputs_hex_csv.clone(),
client_change_address: escrow_change_address.clone(), client_change_address: escrow_change_address.clone(),
}; };

View File

@ -65,7 +65,7 @@ pub fn run_maker(maker_config: &TraderSettings) -> Result<()> {
offer.used_musig_config, offer.used_musig_config,
)?; )?;
// submit signed payout psbt back to coordinator // 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 { } else {
warn!("Trader unsatisfied. Initiating escrow mode."); warn!("Trader unsatisfied. Initiating escrow mode.");
TradeObligationsUnsatisfied::request_escrow(&offer.offer_id_hex, maker_config)?; 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 // 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 // here we need to handle if the other party is not cooperating
} else { } else {
error!("Trader unsatisfied. Initiating escrow mode."); error!("Trader unsatisfied. Initiating escrow mode.");

View File

@ -251,7 +251,7 @@ impl TradingWallet {
match keyspend_sig { match keyspend_sig {
MaybeScalar::Valid(s) => Ok(s.encode_hex()), MaybeScalar::Valid(s) => Ok(s.encode_hex()),
MaybeScalar::Zero => { MaybeScalar::Zero => {
return Err(anyhow!("keyspend sig maybe scalar is Zero")); Err(anyhow!("keyspend sig maybe scalar is Zero"))
} }
} }
} }