From 64b2bc455845022001dd26923df0477eebdf3a86 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 5 Feb 2023 20:13:40 +0100 Subject: -fix FTBFS of exchange test --- src/exchangedb/Makefile.am | 2 +- .../exchange_do_batch_reserves_in_insert.sql | 2 +- src/exchangedb/pg_reserves_in_insert.c | 26 +++++----- src/exchangedb/test_exchangedb.c | 55 +++++++++++++++------- 4 files changed, 52 insertions(+), 33 deletions(-) (limited to 'src/exchangedb') diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index 49bc649b5..620e52352 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -300,7 +300,7 @@ noinst_PROGRAMS = \ AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; TESTS = \ - (check_PROGRAMS) + $(check_PROGRAMS) test_exchangedb_postgres_SOURCES = \ test_exchangedb.c test_exchangedb_postgres_LDADD = \ diff --git a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql index c95f75c3c..73947b4b9 100644 --- a/src/exchangedb/exchange_do_batch_reserves_in_insert.sql +++ b/src/exchangedb/exchange_do_batch_reserves_in_insert.sql @@ -80,7 +80,6 @@ transaction_duplicate= TRUE; END IF; CLOSE curs; - PERFORM pg_notify(in_notify, NULL); OPEN curs_trans FOR WITH reserve_transaction AS( INSERT INTO reserves_in @@ -109,6 +108,7 @@ transaction_duplicate= TRUE; THEN -- HAPPY PATH THERE IS NO DUPLICATE TRANS transaction_duplicate = FALSE; + PERFORM pg_notify(in_notify, NULL); END IF; END IF; CLOSE curs_trans; diff --git a/src/exchangedb/pg_reserves_in_insert.c b/src/exchangedb/pg_reserves_in_insert.c index 314e89d8b..2db7e4a47 100644 --- a/src/exchangedb/pg_reserves_in_insert.c +++ b/src/exchangedb/pg_reserves_in_insert.c @@ -67,7 +67,7 @@ insert1 (struct PostgresClosure *pg, uint64_t *reserve_uuid, enum GNUNET_DB_QueryStatus results[1]) { - enum GNUNET_DB_QueryStatus qs2; + enum GNUNET_DB_QueryStatus qs; PREPARE (pg, "batch1_reserve_create", "SELECT " @@ -91,7 +91,6 @@ insert1 (struct PostgresClosure *pg, GNUNET_PQ_query_param_string (notify_s[0]), GNUNET_PQ_query_param_end }; - struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_bool ("conflicted", &conflict[0]), @@ -102,24 +101,21 @@ insert1 (struct PostgresClosure *pg, GNUNET_PQ_result_spec_end }; - TALER_payto_hash (reserves[0].sender_account_details, &h_payto); - - qs2 = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "batch1_reserve_create", - params, - rs); - - if (qs2 < 0) + qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "batch1_reserve_create", + params, + rs); + if (qs < 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to create reserves 1(%d)\n", - qs2); - results[0] = qs2; - return qs2; + qs); + results[0] = qs; + return qs; } - GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs2); + GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs); if ((! conflict[0]) && transaction_duplicate[0]) { GNUNET_break (0); @@ -128,7 +124,7 @@ insert1 (struct PostgresClosure *pg, return GNUNET_DB_STATUS_HARD_ERROR; } results[0] = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; - return qs2; + return qs; } diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 68f94b6ea..0bb35df1a 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -1289,15 +1289,26 @@ run (void *cls) &amount_with_fee)); result = 4; now = GNUNET_TIME_timestamp_get (); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->reserves_in_insert (plugin->cls, - &reserve_pub, - &value, - now, - sndr, - "exchange-account-1", - 4)); + { + struct TALER_EXCHANGEDB_ReserveInInfo reserve = { + .reserve_pub = &reserve_pub, + .balance = &value, + .execution_time = now, + .sender_account_details = sndr, + .exchange_account_name = "exchange-account-1", + .wire_reference = 4 + }; + enum GNUNET_DB_QueryStatus qsr; + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->reserves_in_insert (plugin->cls, + &reserve, + 1, + 1, + &qsr)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + qsr); + } FAILIF (GNUNET_OK != check_reserve (&reserve_pub, value.value, @@ -1305,14 +1316,26 @@ run (void *cls) value.currency)); now = GNUNET_TIME_timestamp_get (); RND_BLK (&reserve_pub2); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->reserves_in_insert (plugin->cls, - &reserve_pub2, - &value, - now, - sndr, - "exchange-account-1", - 5)); + { + struct TALER_EXCHANGEDB_ReserveInInfo reserve = { + .reserve_pub = &reserve_pub2, + .balance = &value, + .execution_time = now, + .sender_account_details = sndr, + .exchange_account_name = "exchange-account-1", + .wire_reference = 5 + }; + enum GNUNET_DB_QueryStatus qsr; + + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + plugin->reserves_in_insert (plugin->cls, + &reserve, + 1, + 1, + &qsr)); + FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != + qsr); + } FAILIF (GNUNET_OK != check_reserve (&reserve_pub, value.value, -- cgit v1.2.3