Skip to content

Commit

Permalink
Merge pull request #1223 from getlipa/feature/expose-swap-amount-in-mock
Browse files Browse the repository at this point in the history
Expose swap amount in mock
  • Loading branch information
danielgranhao authored Oct 11, 2024
2 parents 9303809 + 4bce8ba commit 577b4ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 3 additions & 2 deletions mock/breez-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const SWAP_TX_WEIGHT: u64 = 800;
const SAT_PER_VBYTE: u64 = 12;
const SWAP_FEE_PERCENTAGE: f64 = 0.5;
const SWAP_ADDRESS_DUMMY: &str = "bc1qftnnghhyhyegmzmh0t7uczysr05e3vx75t96y2";
const SWAP_RECEIVED_SATS_ON_CHAIN: u64 = 100_000;
const TX_ID_DUMMY: &str = "f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16";

const LNURL_PAY_FEE_MSAT: u64 = 8_000;
Expand Down Expand Up @@ -106,6 +105,7 @@ lazy_static! {
static ref CHANNELS: Mutex<Vec<Channel>> = Mutex::new(Vec::new());
static ref CHANNELS_PENDING_CLOSE: Mutex<Vec<Channel>> = Mutex::new(Vec::new());
static ref CHANNELS_CLOSED: Mutex<Vec<Channel>> = Mutex::new(Vec::new());
static ref SWAP_RECEIVED_SATS_ON_CHAIN: Mutex<u64> = Mutex::new(100_000);
}

#[derive(Debug)]
Expand Down Expand Up @@ -453,6 +453,7 @@ impl BreezServices {
req: ReceivePaymentRequest,
) -> Result<ReceivePaymentResponse, ReceivePaymentError> {
// Has nothing to do with receiving a payment, but is a mechanism to control the mock
*SWAP_RECEIVED_SATS_ON_CHAIN.lock().unwrap() = req.amount_msat / 1_000;
match req.description.trim().to_lowercase().as_str() {
"health.operational" => *HEALTH_STATUS.lock().unwrap() = HealthCheckStatus::Operational,
"health.maintenance" => *HEALTH_STATUS.lock().unwrap() = HealthCheckStatus::Maintenance,
Expand Down Expand Up @@ -1042,7 +1043,7 @@ impl BreezServices {
let _: Result<()> = swaps.iter_mut().try_for_each(|swap| {
if now - swap.created_at > secs_until_tx_in_mempool {
swap.total_incoming_txs = 1;
swap.unconfirmed_sats = SWAP_RECEIVED_SATS_ON_CHAIN;
swap.unconfirmed_sats = *SWAP_RECEIVED_SATS_ON_CHAIN.lock().unwrap();
swap.status = SwapStatus::WaitingConfirmation;
self.event_listener.on_event(BreezEvent::SwapUpdated {
details: swap.clone(),
Expand Down
4 changes: 1 addition & 3 deletions tests/print_events_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ impl EventsCallback for PrintEventsHandler {
println!("The Breez SDK health status changed to {status:?}");
}

fn synced(&self) {
println!("A sync has just been successfully performed");
}
fn synced(&self) {}
}

0 comments on commit 577b4ce

Please sign in to comment.