summaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-08-05 15:50:03 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-08-05 15:50:03 -0400
commit36e616c4d63e1e945f75b3f0d80fd4d44b678f7e (patch)
treeef69b10f2c50e346e67ab02100c8db75161f46eb /src/backenddb
parentafc52d52a6abf0d56c6805fbcea359e0b7e4f1ac (diff)
downloadmerchant-36e616c4d63e1e945f75b3f0d80fd4d44b678f7e.tar.gz
merchant-36e616c4d63e1e945f75b3f0d80fd4d44b678f7e.tar.bz2
merchant-36e616c4d63e1e945f75b3f0d80fd4d44b678f7e.zip
fix/test legal expiration for deleting orders
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c2
-rw-r--r--src/backenddb/test_merchantdb.c11
2 files changed, 11 insertions, 2 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index dd8f00de..41e4ff38 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -7171,7 +7171,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" WHERE merchant_id=$1)"
" AND ( ( (pay_deadline < $4) AND"
" (NOT paid) ) OR"
- " (creation_time + $3 > $4) )",
+ " (creation_time + $3 < $4) )",
4),
/* for postgres_lookup_deposits() */
GNUNET_PQ_make_prepare ("lookup_deposits",
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index c3e8d71a..27d6212a 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -1709,19 +1709,21 @@ test_lookup_contract_terms (const struct InstanceData *instance,
*
* @param instance the instance to delete from.
* @param order the order whose contract terms we should delete.
+ * @param legal_expiration how long we must wait after creating an order to delete it
* @param expected_result the result we expect to receive.
* @return 0 on success, 1 otherwise.
*/
static int
test_delete_contract_terms (const struct InstanceData *instance,
const struct OrderData *order,
+ struct GNUNET_TIME_Relative legal_expiration,
enum GNUNET_DB_QueryStatus expected_result)
{
TEST_COND_RET_ON_FAIL (expected_result ==
plugin->delete_contract_terms (plugin->cls,
instance->instance.id,
order->id,
- GNUNET_TIME_UNIT_MONTHS),
+ legal_expiration),
"Delete contract terms failed\n");
return 0;
}
@@ -2193,13 +2195,20 @@ run_test_orders (struct TestOrders_Closure *cls)
TEST_RET_ON_FAIL (test_delete_order (&cls->instance,
&cls->orders[0],
GNUNET_DB_STATUS_SUCCESS_NO_RESULTS));
+ /* Test we can't delete before the legal expiration */
+ TEST_RET_ON_FAIL (test_delete_contract_terms (&cls->instance,
+ &cls->orders[0],
+ GNUNET_TIME_UNIT_MONTHS,
+ GNUNET_DB_STATUS_SUCCESS_NO_RESULTS));
/* Test deleting contract terms */
TEST_RET_ON_FAIL (test_delete_contract_terms (&cls->instance,
&cls->orders[0],
+ GNUNET_TIME_UNIT_ZERO,
GNUNET_DB_STATUS_SUCCESS_ONE_RESULT));
/* Test we can't delete something that doesn't exist */
TEST_RET_ON_FAIL (test_delete_contract_terms (&cls->instance,
&cls->orders[0],
+ GNUNET_TIME_UNIT_ZERO,
GNUNET_DB_STATUS_SUCCESS_NO_RESULTS));
/* Test delete order where we aren't past
the deadline, but the order is unclaimed. */