diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-01-04 01:03:34 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-01-04 01:03:34 +0100 |
commit | d2d2d773cb2cc23f198d07392bab463beb2e2e04 (patch) | |
tree | 4f8eb381f1f64d47cc3668b40889416ea35fc31f /src/backenddb/test_merchantdb.c | |
parent | 881381503f7f51b294c2740e9fcf7f28ef43f973 (diff) | |
download | merchant-d2d2d773cb2cc23f198d07392bab463beb2e2e04.tar.gz merchant-d2d2d773cb2cc23f198d07392bab463beb2e2e04.tar.bz2 merchant-d2d2d773cb2cc23f198d07392bab463beb2e2e04.zip |
remove unnecessary DB interaction in GET private/orders/ID
Diffstat (limited to 'src/backenddb/test_merchantdb.c')
-rw-r--r-- | src/backenddb/test_merchantdb.c | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 3cbe0467..d85bccd3 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -1665,7 +1665,6 @@ test_lookup_contract_terms (const struct InstanceData *instance, { json_t *contract = NULL; uint64_t order_serial; - bool paid; if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->lookup_contract_terms (plugin->cls, @@ -1673,7 +1672,6 @@ test_lookup_contract_terms (const struct InstanceData *instance, order->id, &contract, &order_serial, - &paid, NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1843,22 +1841,36 @@ test_lookup_order_by_fulfillment (const struct InstanceData *instance, * @return 0 on success, 1 otherwise. */ static int -test_lookup_payment_status (uint64_t order_id, +test_lookup_payment_status (const char *instance_id, + const char *order_id, const char *session_id, bool expected_paid, bool expected_wired) { bool paid; bool wired; + bool matches; + uint64_t os; + TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == - plugin->lookup_payment_status (plugin->cls, - order_id, - session_id, - &paid, - &wired), + plugin->lookup_contract_terms3 (plugin->cls, + instance_id, + order_id, + session_id, + NULL, + &os, + &paid, + &wired, + &matches, + NULL), "Lookup payment status failed\n"); - if ((expected_paid != paid) || - (expected_wired != wired)) + if ( (NULL != session_id) && (! matches) ) + { + paid = false; + wired = false; + } + if ( (expected_paid != paid) || + (expected_wired != wired) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup payment status failed\n"); @@ -2051,7 +2063,6 @@ run_test_orders (struct TestOrders_Closure *cls) { json_t *lookup_contract = NULL; uint64_t lookup_order_serial; - bool paid; if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->lookup_contract_terms (plugin->cls, @@ -2059,7 +2070,6 @@ run_test_orders (struct TestOrders_Closure *cls) cls->orders[1].id, &lookup_contract, &lookup_order_serial, - &paid, NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -2098,21 +2108,11 @@ run_test_orders (struct TestOrders_Closure *cls) } } /* Test lookup payment status */ - TEST_RET_ON_FAIL (test_lookup_payment_status (serial, + TEST_RET_ON_FAIL (test_lookup_payment_status (cls->instance.instance.id, + cls->orders[0].id, NULL, false, false)); - { - bool paid; - bool wired; - TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == - plugin->lookup_payment_status (plugin->cls, - 256, - NULL, - &paid, - &wired), - "Lookup payment status failed\n"); - } /* Test lookup order status fails for nonexistent order */ { struct TALER_PrivateContractHashP h_contract_terms; @@ -2134,25 +2134,21 @@ run_test_orders (struct TestOrders_Closure *cls) TEST_RET_ON_FAIL (test_mark_contract_paid (&cls->instance, &cls->orders[0], GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); - TEST_RET_ON_FAIL (test_lookup_payment_status (serial, + TEST_RET_ON_FAIL (test_lookup_payment_status (cls->instance.instance.id, + cls->orders[0].id, NULL, true, false)); - TEST_RET_ON_FAIL (test_lookup_payment_status (serial, + TEST_RET_ON_FAIL (test_lookup_payment_status (cls->instance.instance.id, + cls->orders[0].id, "test_orders_session", true, false)); - { - bool paid; - bool wired; - TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == - plugin->lookup_payment_status (plugin->cls, - serial, - "bad_session", - &paid, - &wired), - "Lookup payment status failed\n"); - } + TEST_RET_ON_FAIL (test_lookup_payment_status (cls->instance.instance.id, + cls->orders[0].id, + "bad_session", + false, + false)); /* Test lookup order by fulfillment */ TEST_RET_ON_FAIL (test_lookup_order_by_fulfillment (&cls->instance, &cls->orders[0], @@ -2187,7 +2183,8 @@ run_test_orders (struct TestOrders_Closure *cls) /* Test marking orders as wired */ TEST_RET_ON_FAIL (test_mark_order_wired (serial, GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); - TEST_RET_ON_FAIL (test_lookup_payment_status (serial, + TEST_RET_ON_FAIL (test_lookup_payment_status (cls->instance.instance.id, + cls->orders[0].id, NULL, true, true)); @@ -4281,7 +4278,8 @@ run_test_transfers (struct TestTransfers_Closure *cls) &cls->account, &cls->transfers[0], GNUNET_DB_STATUS_SUCCESS_ONE_RESULT)); - TEST_RET_ON_FAIL (test_lookup_payment_status (order_serial, + TEST_RET_ON_FAIL (test_lookup_payment_status (cls->instance.instance.id, + cls->order.id, NULL, false, true)); |