fixing warnings

This commit is contained in:
Lorenzo Tucci 2023-01-11 13:07:11 +01:00
parent 5d301ebbb1
commit b5396798e4
No known key found for this signature in database
GPG Key ID: D98C4FA2CDF590A0
5 changed files with 14 additions and 15 deletions

View File

@ -11,10 +11,10 @@ use anyhow::{Context as AnyContext, Result};
use std::fmt;
use std::net::SocketAddr;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::sync::{Arc};
use url::Url;
use std::sync::Once;
use tokio::sync::broadcast;
use tokio::sync::{broadcast, Mutex};
static START: Once = Once::new();
@ -30,11 +30,14 @@ pub struct Config {
pub is_testnet: bool,
}
// workaround for warning over monero_rpc_process which we must own but not read
#[allow(dead_code)]
pub struct Context {
pub db: Arc<dyn Database + Send + Sync>,
bitcoin_wallet: Option<Arc<bitcoin::Wallet>>,
monero_wallet: Option<Arc<monero::Wallet>>,
monero_rpc_process: Option<monero::WalletRpcProcess>,
running_swap: Arc<Mutex<bool>>,
pub config: Config,
pub shutdown: Arc<broadcast::Sender<()>>,
}
@ -117,6 +120,7 @@ impl Context {
is_testnet,
},
shutdown: Arc::new(shutdown),
running_swap: Arc::new(Mutex::new(false)),
};
Ok(init)
@ -209,7 +213,6 @@ fn env_config_from(testnet: bool) -> EnvConfig {
}
#[cfg(test)]
pub mod api_test {
use super::*;
use crate::tor::DEFAULT_SOCKS5_PORT;
use std::str::FromStr;
use uuid::Uuid;
@ -315,6 +318,3 @@ pub mod api_test {
}
}
}
mod tests {
use super::*;
}

View File

@ -285,7 +285,7 @@ impl Request {
json!({
"signed_tx": signed_tx,
"amount": amount.as_sat(),
"amount": amount.to_sat(),
"txid": signed_tx.txid(),
})
}
@ -297,7 +297,7 @@ impl Request {
loop {
tokio::select! {
_ = self.shutdown.recv() => {
server_handle.stop();
server_handle.stop()?;
return Ok(json!({
"result": []
}))
@ -316,7 +316,7 @@ impl Request {
);
json!({
"balance": bitcoin_balance.as_sat()
"balance": bitcoin_balance.to_sat()
})
}
Method::Resume => {

View File

@ -21,7 +21,7 @@ use tokio::sync::broadcast;
#[tokio::main]
async fn main() -> Result<()> {
let (tx, mut rx1) = broadcast::channel(1);
let (tx, _) = broadcast::channel(1);
let (context, mut request) = match parse_args_and_apply_defaults(env::args_os(), tx).await? {
ParseResult::Context(context, request) => (context, request),
ParseResult::PrintAndExitZero { message } => {

View File

@ -9,7 +9,6 @@ use std::collections::HashMap;
use std::str::FromStr;
use std::sync::Arc;
use uuid::Uuid;
use crate::rpc::Error;
pub fn register_modules(context: Arc<Context>) -> RpcModule<Arc<Context>> {
let mut module = RpcModule::new(context);

View File

@ -24,10 +24,10 @@ use sequential_test::sequential;
// to be replaced with actual "real" testing values
// need to create some kind of swap database and bitcoin environment with some funds
const SERVER_ADDRESS: &str = "127.0.0.1:1234";
const BITCOIN_ADDR: &str = "valid_address";
const MONERO_ADDR: &str = "valid_address";
const SELLER: &str = "some_seller";
const SWAP_ID: &str = "valid_swap_id";
const BITCOIN_ADDR: &str = "tb1qr3em6k3gfnyl8r7q0v7t4tlnyxzgxma3lressv";
const MONERO_ADDR: &str = "53gEuGZUhP9JMEBZoGaFNzhwEgiG7hwQdMCqFxiyiTeFPmkbt1mAoNybEUvYBKHcnrSgxnVWgZsTvRBaHBNXPa8tHiCU51a";
const SELLER: &str = "/ip4/127.0.0.1/tcp/9939/p2p/12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi";
const SWAP_ID: &str = "ea030832-3be9-454f-bb98-5ea9a788406b";
pub async fn initialize_context() -> (Arc<Context>, Request) {
let (is_testnet, debug, json) = (true, false, false);