commit 4019ab323771ee02486072b50adb13b5836c8f6b
parent 425313290a4ed284a97b430a9ada4f0ac5990264
Author: Antoine A <>
Date: Thu, 9 Jul 2026 08:44:53 +0200
common: fix prepared transfer db procedure
Diffstat:
5 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/adapters/taler-cyclos/db/cyclos-procedures.sql b/adapters/taler-cyclos/db/cyclos-procedures.sql
@@ -1,6 +1,6 @@
--
-- This file is part of TALER
--- Copyright (C) 2025, 2026 Taler Systems SA
+-- Copyright (C) 2025-2026 Taler Systems SA
--
-- TALER is free software; you can redistribute it and/or modify it under the
-- terms of the GNU General Public License as published by the Free Software
@@ -128,7 +128,9 @@ IF out_pending THEN
ELSIF in_type IS NOT NULL THEN
UPDATE prepared_in
SET tx_in_id = out_tx_row_id
- WHERE (tx_in_id IS NULL AND account_pub = in_metadata) OR authorization_pub = local_authorization_pub;
+ WHERE (
+ tx_in_id IS NULL AND account_pub = in_metadata AND type='reserve'
+ ) OR authorization_pub = local_authorization_pub;
-- Insert new incoming talerable transaction
INSERT INTO taler_in (
tx_in_id,
diff --git a/adapters/taler-magnet-bank/db/magnet-bank-procedures.sql b/adapters/taler-magnet-bank/db/magnet-bank-procedures.sql
@@ -1,6 +1,6 @@
--
-- This file is part of TALER
--- Copyright (C) 2025, 2026 Taler Systems SA
+-- Copyright (C) 2025-2026 Taler Systems SA
--
-- TALER is free software; you can redistribute it and/or modify it under the
-- terms of the GNU General Public License as published by the Free Software
@@ -124,7 +124,9 @@ IF out_pending THEN
ELSIF in_type IS NOT NULL THEN
UPDATE prepared_in
SET tx_in_id = out_tx_row_id
- WHERE (tx_in_id IS NULL AND account_pub = in_metadata) OR authorization_pub = local_authorization_pub;
+ WHERE (
+ tx_in_id IS NULL AND account_pub = in_metadata AND type='reserve'
+ ) OR authorization_pub = local_authorization_pub;
-- Insert new incoming talerable transaction
INSERT INTO taler_in (
tx_in_id,
diff --git a/common/taler-api/db/taler-api-procedures.sql b/common/taler-api/db/taler-api-procedures.sql
@@ -1,6 +1,6 @@
--
-- This file is part of TALER
--- Copyright (C) 2025, 2026 Taler Systems SA
+-- Copyright (C) 2025-2026 Taler Systems SA
--
-- TALER is free software; you can redistribute it and/or modify it under the
-- terms of the GNU General Public License as published by the Free Software
@@ -150,7 +150,7 @@ IF in_type = 'map' THEN
END IF;
-- Check conflict
-SELECT NOT local_pending AND in_type = 'reserve'::incoming_type AND EXISTS(SELECT FROM taler_in WHERE account_pub = in_account_pub AND type = 'reserve')
+SELECT NOT local_pending AND in_type = 'reserve' AND EXISTS(SELECT FROM taler_in WHERE account_pub = in_account_pub AND type = 'reserve')
INTO out_reserve_pub_reuse;
IF out_reserve_pub_reuse THEN
RETURN;
@@ -176,7 +176,9 @@ IF local_pending THEN
ELSE
UPDATE prepared_in
SET tx_in_id = out_tx_row_id
- WHERE (tx_in_id IS NULL AND account_pub = in_account_pub) OR authorization_pub = local_authorization_pub;
+ WHERE (
+ tx_in_id IS NULL AND account_pub = in_account_pub AND type='reserve'
+ ) OR authorization_pub = local_authorization_pub;
INSERT INTO taler_in (
tx_in_id,
type,
@@ -213,8 +215,8 @@ DECLARE
idempotent BOOLEAN;
BEGIN
--- Check idempotency
-SELECT type = in_type
+-- Check idempotency
+SELECT type = in_type
AND account_pub = in_account_pub
AND recurrent = in_recurrent
INTO idempotent
diff --git a/common/taler-test-utils/Cargo.toml b/common/taler-test-utils/Cargo.toml
@@ -29,6 +29,7 @@ url.workspace = true
aws-lc-rs.workspace = true
jiff.workspace = true
clap.workspace = true
+pretty_assertions = "1.4.1"
reedline = "0.49"
shlex = "2.0"
nu-ansi-term = "0.50"
\ No newline at end of file
diff --git a/common/taler-test-utils/src/routine.rs b/common/taler-test-utils/src/routine.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2024, 2025, 2026 Taler Systems SA
+ Copyright (C) 2024-2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -1044,7 +1044,7 @@ pub async fn registration_routine<F1: Future<Output = Vec<Status>>>(
pub use Status::*;
let mut check_in = async |state: &[Status]| {
let current = in_status().await;
- assert_eq!(state, current);
+ pretty_assertions::assert_eq!(state, current);
};
let currency = &get_currency(wire_gateway).await;
@@ -1469,6 +1469,21 @@ pub async fn registration_routine<F1: Future<Output = Vec<Status>>>(
)
.await
.assert_ok_json::<RegistrationResponse>();
+ let pair = Ed25519KeyPair::generate().unwrap();
+ prepared_transfer
+ .post("/registration")
+ .json(
+ RegistrationRequest {
+ r#type: TransferType::kyc,
+ account_pub: acc_pub5,
+ authorization_pub: EddsaPublicKey::try_from(pair.public_key().as_ref()).unwrap(),
+ recurrent: true,
+ ..req.clone()
+ }
+ .signed(&pair),
+ )
+ .await
+ .assert_ok_json::<RegistrationResponse>();
wire_gateway
.post("/admin/add-kycauth")
.json(json!({
@@ -1498,11 +1513,13 @@ pub async fn registration_routine<F1: Future<Output = Vec<Status>>>(
Reserve(acc_pub5),
Bounced,
Kyc(acc_pub5),
- Pending,
+ Kyc(acc_pub5),
Pending,
])
.await;
+ // Kyc without using mapping
+
/* ----- Unregistration ----- */
let un_req = Unregistration {
timestamp: TalerTimestamp::Timestamp(Timestamp::now()),
@@ -1534,7 +1551,7 @@ pub async fn registration_routine<F1: Future<Output = Vec<Status>>>(
Reserve(acc_pub5),
Bounced,
Kyc(acc_pub5),
- Bounced,
+ Kyc(acc_pub5),
Bounced,
])
.await;
@@ -1609,7 +1626,7 @@ pub async fn registration_routine<F1: Future<Output = Vec<Status>>>(
(acc_pub, auth_pub)
})
.collect();
- assert_eq!(
+ pretty_assertions::assert_eq!(
history,
[
(acc_pub1, Some(auth_pub1)),
@@ -1621,6 +1638,7 @@ pub async fn registration_routine<F1: Future<Output = Vec<Status>>>(
(auth_pub2, Some(auth_pub2)),
(acc_pub5, None),
(acc_pub5, None),
+ (acc_pub5, Some(auth_pub2)),
]
)
}