merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit f20bc8bd00efaa270be937432afccf9fae1403ff
parent 85eac867361e3f517896b4bb676e2463138ca59d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed,  5 Aug 2026 22:15:12 +0200

fix test to work with fixed insert_product logic

Diffstat:
Msrc/backenddb/test_merchantdb.c | 31++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c @@ -1358,7 +1358,15 @@ run_test_products (struct TestProducts_Closure *cls) false, false, -1)); - /* Test that conflicting insert fails */ + /* Test that an insert naming a category that does not exist is + reported via 'no_cat'. + + NOTE: the category existence check in insert_product.sql runs + *before* any modification of the database (so that a rejected + request leaves no trace), and therefore also before the + idempotency/conflict check. An unknown category consequently takes + precedence over a conflict: 'no_cat' is the 1-based index into the + supplied category array and 'conflict' stays false. */ { uint64_t cat = 42; @@ -1367,6 +1375,27 @@ run_test_products (struct TestProducts_Closure *cls) 1, &cat, GNUNET_DB_STATUS_SUCCESS_ONE_RESULT, + false, + false, + 1)); + } + /* Test that a genuinely conflicting insert -- same product_id, but + different product data -- is reported via 'conflict'. + + This case supplies no categories at all, so it cannot be masked by + the category pre-check. The previous version of this test relied on + a non-existent category to provoke the conflict, which stopped + exercising the conflict path once that check was hoisted above the + insert. */ + { + struct ProductData conflicting = cls->products[1]; + + conflicting.id = cls->products[0].id; + TEST_RET_ON_FAIL (test_insert_product (&cls->instance, + &conflicting, + 0, + NULL, + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT, true, false, -1));