Skip to content

Commit

Permalink
Merge pull request #1313 from getlipa/mock/mock-reverse-swap-state-ch…
Browse files Browse the repository at this point in the history
…ange-events

Mock reverse swap state change events
  • Loading branch information
gcomte authored Dec 20, 2024
2 parents 800a786 + fddad9d commit 6b8307c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mock/breez-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,20 +1195,27 @@ impl BreezServices {
Ok(())
}
async fn issue_clear_wallet_tx(&self) {
Self::change_status_of_all_reverse_swaps(ReverseSwapStatus::CompletedSeen).await;
self.change_status_of_all_reverse_swaps(ReverseSwapStatus::CompletedSeen)
.await;
}
async fn confirm_clear_wallet_tx(&self) {
Self::change_status_of_all_reverse_swaps(ReverseSwapStatus::CompletedConfirmed).await;
self.change_status_of_all_reverse_swaps(ReverseSwapStatus::CompletedConfirmed)
.await;
}
async fn simulate_clear_wallet_cancellation(&self) {
Self::change_status_of_all_reverse_swaps(ReverseSwapStatus::Cancelled).await;
self.change_status_of_all_reverse_swaps(ReverseSwapStatus::Cancelled)
.await;
}

async fn change_status_of_all_reverse_swaps(status: ReverseSwapStatus) {
async fn change_status_of_all_reverse_swaps(&self, status: ReverseSwapStatus) {
PAYMENTS.lock().unwrap().iter_mut().for_each(|payment| {
if let Ln { ref mut data } = payment.details {
if let Some(reverse_swap_info) = &mut data.reverse_swap_info {
reverse_swap_info.status = status;
self.event_listener
.on_event(BreezEvent::ReverseSwapUpdated {
details: reverse_swap_info.clone(),
});
}
}
});
Expand Down

0 comments on commit 6b8307c

Please sign in to comment.