Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions crates/bcr-ebill-api/src/service/bill_service/issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,13 @@
}
}

// send notification to all required recipients
self.notification_service
.send_bill_is_signed_event(&BillChainEvent::new(&bill, &chain, &bill_keys)?)
.await?;

// propagate the bill
let bill_clone = bill.clone();
let self_clone = self.clone();
if let Err(e) = self_clone
.propagate_bill_and_subscribe(
&bill_clone.id,
&bill_clone.drawer.node_id,
&bill_clone.drawee.node_id,
&bill_clone.payee.node_id,
)
// send notification and blocks to all required recipients
if let Err(e) = self
.notification_service
.send_bill_is_signed_event(&BillChainEvent::new(&bill, &chain, &bill_keys, true)?)
.await
{
error!("Error propagating and subscribing to bill: {e}");
error!("Error propagating bill via Nostr {e}");

Check warning on line 191 in crates/bcr-ebill-api/src/service/bill_service/issue.rs

View check run for this annotation

Codecov / codecov/patch

crates/bcr-ebill-api/src/service/bill_service/issue.rs#L191

Added line #L191 was not covered by tests
}

// If we're the drawee, we immediately accept the bill with timestamp increased by 1 sec
Expand Down
38 changes: 19 additions & 19 deletions crates/bcr-ebill-api/src/service/bill_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ pub mod tests {
// Request to sell event should be sent
ctx.notification_service
.expect_send_offer_to_sell_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));
let service = get_service(ctx);

let res = service
Expand Down Expand Up @@ -2258,7 +2258,7 @@ pub mod tests {
// Request to sell event should be sent
ctx.notification_service
.expect_send_bill_is_sold_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));

let service = get_service(ctx);

Expand Down Expand Up @@ -2318,7 +2318,7 @@ pub mod tests {
// Sold event should be sent
ctx.notification_service
.expect_send_bill_is_sold_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));

let service = get_service(ctx);

Expand Down Expand Up @@ -2351,7 +2351,7 @@ pub mod tests {
// Request to sell event should be sent
ctx.notification_service
.expect_send_bill_is_sold_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));
let service = get_service(ctx);

let res = service
Expand Down Expand Up @@ -2579,7 +2579,7 @@ pub mod tests {
});
ctx.notification_service
.expect_send_bill_is_sold_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));

let service = get_service(ctx);

Expand Down Expand Up @@ -2625,7 +2625,7 @@ pub mod tests {
});
ctx.notification_service
.expect_send_bill_is_sold_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));
let service = get_service(ctx);

let res = service.check_bills_offer_to_sell_payment().await;
Expand Down Expand Up @@ -3227,8 +3227,8 @@ pub mod tests {
});
ctx.notification_service
.expect_send_request_to_action_rejected_event()
.with(eq("1234"), always(), eq(ActionType::AcceptBill), always())
.returning(|_, _, _, _| Ok(()));
.with(always(), eq(ActionType::AcceptBill))
.returning(|_, _| Ok(()));

let service = get_service(ctx);
let res = service
Expand Down Expand Up @@ -3271,8 +3271,8 @@ pub mod tests {

ctx.notification_service
.expect_send_request_to_action_rejected_event()
.with(eq("1234"), always(), eq(ActionType::BuyBill), always())
.returning(|_, _, _, _| Ok(()));
.with(always(), eq(ActionType::BuyBill))
.returning(|_, _| Ok(()));
let service = get_service(ctx);

let res = service
Expand Down Expand Up @@ -3328,8 +3328,8 @@ pub mod tests {
});
ctx.notification_service
.expect_send_request_to_action_rejected_event()
.with(eq("1234"), always(), eq(ActionType::PayBill), always())
.returning(|_, _, _, _| Ok(()));
.with(always(), eq(ActionType::PayBill))
.returning(|_, _| Ok(()));
let service = get_service(ctx);

let res = service
Expand Down Expand Up @@ -3388,8 +3388,8 @@ pub mod tests {
});
ctx.notification_service
.expect_send_request_to_action_rejected_event()
.with(eq("1234"), always(), eq(ActionType::RecourseBill), always())
.returning(|_, _, _, _| Ok(()));
.with(always(), eq(ActionType::RecourseBill))
.returning(|_, _| Ok(()));

let service = get_service(ctx);

Expand Down Expand Up @@ -3449,7 +3449,7 @@ pub mod tests {
});
ctx.notification_service
.expect_send_bill_recourse_paid_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));

let service = get_service(ctx);

Expand Down Expand Up @@ -3513,7 +3513,7 @@ pub mod tests {
});
ctx.notification_service
.expect_send_bill_recourse_paid_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));
let service = get_service(ctx);

let res = service.check_bills_in_recourse_payment().await;
Expand Down Expand Up @@ -3588,7 +3588,7 @@ pub mod tests {
// Request to recourse event should be sent
ctx.notification_service
.expect_send_recourse_action_event()
.returning(|_, _, _, _| Ok(()));
.returning(|_, _, _| Ok(()));
let service = get_service(ctx);

let res = service
Expand Down Expand Up @@ -3675,7 +3675,7 @@ pub mod tests {
// Request to recourse event should be sent
ctx.notification_service
.expect_send_recourse_action_event()
.returning(|_, _, _, _| Ok(()));
.returning(|_, _, _| Ok(()));
let service = get_service(ctx);

let res = service
Expand Down Expand Up @@ -3737,7 +3737,7 @@ pub mod tests {
// Recourse paid event should be sent
ctx.notification_service
.expect_send_bill_recourse_paid_event()
.returning(|_, _, _| Ok(()));
.returning(|_, _| Ok(()));

let service = get_service(ctx);

Expand Down
77 changes: 6 additions & 71 deletions crates/bcr-ebill-api/src/service/bill_service/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
use super::service::BillService;
use crate::service::bill_service::{BillAction, BillServiceApi};
use bcr_ebill_core::{
blockchain::{
Blockchain,
bill::{OfferToSellWaitingForPayment, RecourseWaitingForPayment},
},
blockchain::bill::{OfferToSellWaitingForPayment, RecourseWaitingForPayment},
company::{Company, CompanyKeys},
contact::IdentityPublicData,
identity::{Identity, IdentityWithAll},
util::BcrKeys,
};
use log::{error, info};
use log::info;
use std::collections::HashMap;

impl BillService {
Expand Down Expand Up @@ -74,7 +71,7 @@
if let Some(signer_identity) =
IdentityPublicData::new(identity.identity.clone())
{
let chain = self
let _ = self
.execute_bill_action(
bill_id,
BillAction::Recourse(
Expand All @@ -88,23 +85,6 @@
now,
)
.await?;

if let Err(e) = self
.propagate_block(bill_id, chain.get_latest_block())
.await
{
error!("Error propagating block: {e}");
}

if let Err(e) = self
.propagate_bill_for_node_id(
bill_id,
&payment_info.recoursee.node_id,
)
.await
{
error!("Error propagating bill for node_id: {e}");
}
}
return Ok(()); // return early
}
Expand All @@ -121,7 +101,7 @@
.iter()
.any(|s| s == &identity.identity.node_id)
{
let chain = self
let _ = self

Check warning on line 104 in crates/bcr-ebill-api/src/service/bill_service/payment.rs

View check run for this annotation

Codecov / codecov/patch

crates/bcr-ebill-api/src/service/bill_service/payment.rs#L104

Added line #L104 was not covered by tests
.execute_bill_action(
bill_id,
BillAction::Recourse(self.extend_bill_chain_identity_data_from_contacts_or_identity(
Expand All @@ -136,23 +116,6 @@
now,
)
.await?;

if let Err(e) = self
.propagate_block(bill_id, chain.get_latest_block())
.await
{
error!("Error propagating block: {e}");
}

if let Err(e) = self
.propagate_bill_for_node_id(
bill_id,
&payment_info.recoursee.node_id,
)
.await
{
error!("Error propagating bill for node_id: {e}");
}
}
}
}
Expand Down Expand Up @@ -185,7 +148,7 @@
if let Some(signer_identity) =
IdentityPublicData::new(identity.identity.clone())
{
let chain = self
let _ = self

Check warning on line 151 in crates/bcr-ebill-api/src/service/bill_service/payment.rs

View check run for this annotation

Codecov / codecov/patch

crates/bcr-ebill-api/src/service/bill_service/payment.rs#L151

Added line #L151 was not covered by tests
.execute_bill_action(
bill_id,
BillAction::Sell(
Expand All @@ -202,20 +165,6 @@
now,
)
.await?;

if let Err(e) = self
.propagate_block(bill_id, chain.get_latest_block())
.await
{
error!("Error propagating block: {e}");
}

if let Err(e) = self
.propagate_bill_for_node_id(bill_id, &payment_info.buyer.node_id)
.await
{
error!("Error propagating bill for node_id: {e}");
}
}
return Ok(()); // return early
}
Expand All @@ -231,7 +180,7 @@
.iter()
.any(|s| s == &identity.identity.node_id)
{
let chain = self
let _ = self

Check warning on line 183 in crates/bcr-ebill-api/src/service/bill_service/payment.rs

View check run for this annotation

Codecov / codecov/patch

crates/bcr-ebill-api/src/service/bill_service/payment.rs#L183

Added line #L183 was not covered by tests
.execute_bill_action(
bill_id,
BillAction::Sell(
Expand All @@ -250,20 +199,6 @@
now,
)
.await?;

if let Err(e) = self
.propagate_block(bill_id, chain.get_latest_block())
.await
{
error!("Error propagating block: {e}");
}

if let Err(e) = self
.propagate_bill_for_node_id(bill_id, &payment_info.buyer.node_id)
.await
{
error!("Error propagating bill for node_id: {e}");
}
}
}
}
Expand Down
Loading