taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit a0099119dc8c6cb95324f2b3b0283bd1ffc8fea5
parent bd5726298887d7242c47a01cbcfa4f171ac1b7a5
Author: Antoine A <>
Date:   Thu, 22 Oct 2026 11:25:19 +0200

common: set max connections for test db pool

Diffstat:
MCargo.lock | 48++++++++++++++++++++++++------------------------
Mcommon/taler-common/src/api.rs | 2+-
Mcommon/taler-common/src/db.rs | 10+++++++++-
Mcommon/taler-test-utils/src/db.rs | 17++++++++++++-----
4 files changed, 46 insertions(+), 31 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -1257,9 +1257,9 @@ dependencies = [ [[package]] name = "icu_collections" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" dependencies = [ "displaydoc", "potential_utf", @@ -1271,9 +1271,9 @@ dependencies = [ [[package]] name = "icu_locale_core" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" dependencies = [ "displaydoc", "litemap", @@ -1284,9 +1284,9 @@ dependencies = [ [[package]] name = "icu_normalizer" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" dependencies = [ "icu_collections", "icu_normalizer_data", @@ -1298,15 +1298,15 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" [[package]] name = "icu_properties" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" dependencies = [ "displaydoc", "icu_collections", @@ -1319,15 +1319,15 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" [[package]] name = "icu_provider" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" dependencies = [ "displaydoc", "icu_locale_core", @@ -2913,9 +2913,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" dependencies = [ "displaydoc", "zerovec", @@ -2939,9 +2939,9 @@ checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" [[package]] name = "tokio" -version = "1.54.0" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c168a474b95bfecfe908a65d4bdffc523144b649a74c09c286afb35d53e0bc" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" dependencies = [ "bytes", "libc", @@ -3531,9 +3531,9 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "yoke" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -3612,9 +3612,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" dependencies = [ "yoke", "zerofrom", @@ -3623,9 +3623,9 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.6" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" dependencies = [ "proc-macro2", "quote", diff --git a/common/taler-common/src/api.rs b/common/taler-common/src/api.rs @@ -244,6 +244,6 @@ impl<'q> sqlx::Encode<'q, sqlx::Postgres> for EddsaPublicKey { impl<'r> sqlx::Decode<'r, sqlx::Postgres> for EddsaPublicKey { fn decode(value: sqlx::postgres::PgValueRef<'r>) -> Result<Self, sqlx::error::BoxDynError> { let raw = <Base32<32>>::decode(value)?; - Ok(Self(raw)) + Ok(Self::try_from(raw)?) } } diff --git a/common/taler-common/src/db.rs b/common/taler-common/src/db.rs @@ -40,10 +40,18 @@ pub enum IncomingType { /* ----- Pool ----- */ pub async fn pool(cfg: PgConnectOptions, schema: &str) -> sqlx::Result<PgPool> { + pool_with_options(cfg, schema, PgPoolOptions::new()).await +} + +pub async fn pool_with_options( + cfg: PgConnectOptions, + schema: &str, + options: PgPoolOptions, +) -> sqlx::Result<PgPool> { let init_sql = Arc::new(format!( "SET search_path TO {schema};SET default_transaction_isolation = 'serializable';" )); - let pool = PgPoolOptions::new() + let pool = options .after_connect(move |conn, _meta| { let init_sql = init_sql.clone(); Box::pin(async move { diff --git a/common/taler-test-utils/src/db.rs b/common/taler-test-utils/src/db.rs @@ -16,11 +16,14 @@ use std::{path::Path, str::FromStr as _}; -use sqlx::{Connection, PgConnection, PgPool, postgres::PgConnectOptions}; +use sqlx::{ + Connection, PgConnection, PgPool, + postgres::{PgConnectOptions, PgPoolOptions}, +}; use taler_api::config::DbCfg; use taler_common::{ config::{Config, parser::ConfigSource}, - db::{dbinit, pool}, + db::{dbinit, pool_with_options}, }; use tracing::info; @@ -53,9 +56,13 @@ impl TestDb { /// Reset the component schema using an explicit SQL directory. pub async fn setup_manual(&self, sql_dir: &Path, component_name: &str) -> PgPool { - let pool = pool(self.connect_options(), &component_name.replace('-', "_")) - .await - .unwrap(); + let pool = pool_with_options( + self.connect_options(), + &component_name.replace('-', "_"), + PgPoolOptions::new().max_connections(3), + ) + .await + .unwrap(); let mut conn = pool.acquire().await.unwrap(); dbinit(&mut conn, sql_dir, component_name, true) .await