Skip to content

Commit fff5c0d

Browse files
authored
Fix recourse validation (#666)
1 parent 272574e commit fff5c0d

File tree

20 files changed

+414
-311
lines changed

20 files changed

+414
-311
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
* Fix it so that Anon holders of a bill can do recourse (breaking DB and API change)
1010
* `recourser` went from `BillIdentParticipant` to `BillParticipant`
1111
* Added endpoints `identityApi.dev_mode_get_full_identity_chain()` and `companyApi.dev_mode_get_full_company_chain(company_id)` to show the full identity and company chains as JSON in dev mode
12+
* Fixed request to recourse validation
13+
* The bill is not blocked, if a req to recourse expired, or was rejected
14+
* It's now possible to recourse against the same person again
15+
* The last person in the chain can now reject a recourse (was broken before)
16+
* `get_past_endorsees` is calculated differently now - holders can only recourse against parties before the first block where they became a holder in the bill, even if they have multiple endorsement blocks in the bill
1217

1318
# 0.4.8
1419

crates/bcr-ebill-api/src/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ pub const VALID_FILE_MIME_TYPES: [&str; 3] = ["image/jpeg", "image/png", "applic
77

88
// When subscribing events we subtract this from the last received event time
99
pub const NOSTR_EVENT_TIME_SLACK: u64 = 3600 * 24; // 1 day
10-
pub const CURRENCY_SAT: &str = "sat";
10+
pub use bcr_ebill_core::constants::CURRENCY_SAT;

crates/bcr-ebill-api/src/service/backup_service.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ mod tests {
103103
use super::*;
104104

105105
#[tokio::test]
106+
#[ignore]
106107
async fn test_backup_with_embedded_db() {
107108
let mut store = MockBackupStoreApiMock::new();
108109
let mut identity_store = MockIdentityStoreApiMock::new();
@@ -159,6 +160,7 @@ mod tests {
159160
}
160161

161162
#[tokio::test]
163+
#[ignore]
162164
async fn test_restore_with_embedded_db() {
163165
let mut store = MockBackupStoreApiMock::new();
164166
let mut identity_store = MockIdentityStoreApiMock::new();

crates/bcr-ebill-api/src/service/bill_service/mod.rs

Lines changed: 211 additions & 96 deletions
Large diffs are not rendered by default.

crates/bcr-ebill-api/src/service/bill_service/test_utils.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use bcr_ebill_core::{
3636
},
3737
identity::IdentityBlockchain,
3838
},
39+
constants::CURRENCY_SAT,
3940
contact::{BillIdentParticipant, BillParticipant},
4041
};
4142
use external::{bitcoin::MockBitcoinClientApi, mint::MockMintClientApi};
@@ -102,7 +103,7 @@ pub fn get_baseline_cached_bill(id: BillId) -> BitcreditBillResult {
102103
city_of_issuing: "Vienna".to_string(),
103104
country_of_payment: "AT".to_string(),
104105
city_of_payment: "Vienna".to_string(),
105-
currency: "sat".to_string(),
106+
currency: CURRENCY_SAT.to_string(),
106107
sum: "15000".to_string(),
107108
files: vec![],
108109
active_notification: None,
@@ -337,7 +338,7 @@ pub fn request_to_recourse_block(
337338
.into(),
338339
recoursee: recoursee.to_owned().into(),
339340
sum: 15000,
340-
currency: "sat".to_string(),
341+
currency: CURRENCY_SAT.to_string(),
341342
recourse_reason: BillRecourseReasonBlockData::Pay,
342343
signatory: None,
343344
signing_timestamp: timestamp,
@@ -363,7 +364,7 @@ pub fn recourse_block(
363364
recourser: bill_identified_participant_only_node_id(node_id_test()).into(),
364365
recoursee: recoursee.to_owned().into(),
365366
sum: 15000,
366-
currency: "sat".to_string(),
367+
currency: CURRENCY_SAT.to_string(),
367368
recourse_reason: BillRecourseReasonBlockData::Pay,
368369
signatory: None,
369370
signing_timestamp: first_block.timestamp + 1,
@@ -449,7 +450,7 @@ pub fn offer_to_sell_block(
449450
bill_identified_participant_only_node_id(node_id_test()).into(),
450451
),
451452
buyer: BillParticipantBlockData::Ident(buyer.to_owned().into()),
452-
currency: "sat".to_string(),
453+
currency: CURRENCY_SAT.to_string(),
453454
sum: 15000,
454455
payment_address: VALID_PAYMENT_ADDRESS_TESTNET.to_string(),
455456
signatory: None,
@@ -491,7 +492,7 @@ pub fn sell_block(id: &BillId, first_block: &BillBlock, buyer: &BillIdentPartici
491492
bill_identified_participant_only_node_id(node_id_test()).into(),
492493
),
493494
buyer: BillParticipantBlockData::Ident(buyer.to_owned().into()),
494-
currency: "sat".to_string(),
495+
currency: CURRENCY_SAT.to_string(),
495496
payment_address: VALID_PAYMENT_ADDRESS_TESTNET.to_string(),
496497
sum: 15000,
497498
signatory: None,
@@ -533,7 +534,7 @@ pub fn request_to_pay_block(id: &BillId, first_block: &BillBlock, ts: Option<u64
533534
requester: BillParticipantBlockData::Ident(
534535
bill_identified_participant_only_node_id(node_id_test()).into(),
535536
),
536-
currency: "sat".to_string(),
537+
currency: CURRENCY_SAT.to_string(),
537538
signatory: None,
538539
signing_timestamp: timestamp,
539540
signing_address: Some(empty_address()),

crates/bcr-ebill-api/src/tests/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub mod tests {
88
data::bill::BillKeys,
99
};
1010
use async_trait::async_trait;
11+
use bcr_ebill_core::constants::CURRENCY_SAT;
1112
use bcr_ebill_core::{
1213
NodeId, OptionalPostalAddress, PostalAddress, PublicKey, SecretKey, ServiceTraitBounds,
1314
bill::{BillId, BitcreditBill, BitcreditBillResult, PaymentState},
@@ -574,7 +575,7 @@ pub mod tests {
574575
drawer: empty_bill_identified_participant(),
575576
payee: BillParticipant::Ident(empty_bill_identified_participant()),
576577
endorsee: None,
577-
currency: "sat".to_string(),
578+
currency: CURRENCY_SAT.to_string(),
578579
sum: 5000,
579580
maturity_date: "2099-11-12".to_string(),
580581
issue_date: "2099-08-12".to_string(),

0 commit comments

Comments
 (0)