diff options
Diffstat (limited to 'src/backenddb/test_merchantdb.c')
-rw-r--r-- | src/backenddb/test_merchantdb.c | 163 |
1 files changed, 88 insertions, 75 deletions
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index aabc431a..237bd18e 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -2568,26 +2568,34 @@ lookup_deposits_cb (void *cls, cmp->results_length += 1; for (unsigned int i = 0; cmp->deposits_to_cmp_length > i; ++i) { - if ((GNUNET_OK == TALER_amount_cmp_currency ( + if ((GNUNET_OK == + TALER_amount_cmp_currency ( &cmp->deposits_to_cmp[i].amount_with_fee, amount_with_fee)) && - (0 == TALER_amount_cmp (&cmp->deposits_to_cmp[i].amount_with_fee, - amount_with_fee)) && - (GNUNET_OK == TALER_amount_cmp_currency ( + (0 == + TALER_amount_cmp (&cmp->deposits_to_cmp[i].amount_with_fee, + amount_with_fee)) && + (GNUNET_OK == + TALER_amount_cmp_currency ( &cmp->deposits_to_cmp[i].deposit_fee, deposit_fee)) && - (0 == TALER_amount_cmp (&cmp->deposits_to_cmp[i].deposit_fee, - deposit_fee)) && - (GNUNET_OK == TALER_amount_cmp_currency ( + (0 == + TALER_amount_cmp (&cmp->deposits_to_cmp[i].deposit_fee, + deposit_fee)) && + (GNUNET_OK == + TALER_amount_cmp_currency ( &cmp->deposits_to_cmp[i].refund_fee, refund_fee)) && - (0 == TALER_amount_cmp (&cmp->deposits_to_cmp[i].refund_fee, - refund_fee)) && - (GNUNET_OK == TALER_amount_cmp_currency ( + (0 == + TALER_amount_cmp (&cmp->deposits_to_cmp[i].refund_fee, + refund_fee)) && + (GNUNET_OK == + TALER_amount_cmp_currency ( &cmp->deposits_to_cmp[i].wire_fee, wire_fee)) && - (0 == TALER_amount_cmp (&cmp->deposits_to_cmp[i].wire_fee, - wire_fee))) + (0 == + TALER_amount_cmp (&cmp->deposits_to_cmp[i].wire_fee, + wire_fee))) { cmp->results_matching[i] += 1; } @@ -2664,21 +2672,21 @@ test_lookup_deposits (const struct InstanceData *instance, * @param exchange_pub public key of the exchange. */ static void -lookup_deposits_contract_coin_cb (void *cls, - const char *exchange_url, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *deposit_fee, - const struct TALER_Amount *refund_fee, - const struct TALER_Amount *wire_fee, - const struct GNUNET_HashCode *h_wire, - struct GNUNET_TIME_Absolute deposit_timestamp, - struct GNUNET_TIME_Absolute refund_deadline, - const struct - TALER_ExchangeSignatureP *exchange_sig, - const struct - TALER_ExchangePublicKeyP *exchange_pub) +lookup_deposits_contract_coin_cb ( + void *cls, + const char *exchange_url, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *deposit_fee, + const struct TALER_Amount *refund_fee, + const struct TALER_Amount *wire_fee, + const struct GNUNET_HashCode *h_wire, + struct GNUNET_TIME_Absolute deposit_timestamp, + struct GNUNET_TIME_Absolute refund_deadline, + const struct TALER_ExchangeSignatureP *exchange_sig, + const struct TALER_ExchangePublicKeyP *exchange_pub) { struct TestLookupDeposits_Closure *cmp = cls; + if (NULL == cmp) return; cmp->results_length += 1; @@ -2730,13 +2738,12 @@ lookup_deposits_contract_coin_cb (void *cls, * @return 0 on success, 1 otherwise. */ static int -test_lookup_deposits_contract_and_coin (const struct InstanceData *instance, - const struct - GNUNET_HashCode *h_contract, - const struct - TALER_CoinSpendPublicKeyP *coin_pub, - unsigned int deposits_length, - const struct DepositData *deposits) +test_lookup_deposits_contract_and_coin ( + const struct InstanceData *instance, + const struct GNUNET_HashCode *h_contract, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + unsigned int deposits_length, + const struct DepositData *deposits) { unsigned int results_matching[deposits_length]; struct TestLookupDeposits_Closure cmp = { @@ -2748,17 +2755,16 @@ test_lookup_deposits_contract_and_coin (const struct InstanceData *instance, memset (results_matching, 0, sizeof (unsigned int) * deposits_length); - TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == - plugin->lookup_deposits_by_contract_and_coin ( - plugin->cls, - instance - ->instance.id, - h_contract, - coin_pub, - & - lookup_deposits_contract_coin_cb, - &cmp), - "Lookup deposits by contract and coin failed\n"); + TEST_COND_RET_ON_FAIL ( + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == + plugin->lookup_deposits_by_contract_and_coin ( + plugin->cls, + instance->instance.id, + h_contract, + coin_pub, + &lookup_deposits_contract_coin_cb, + &cmp), + "Lookup deposits by contract and coin failed\n"); if (deposits_length != cmp.results_length) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -3273,7 +3279,6 @@ struct TransferData */ struct TALER_WireTransferIdentifierRawP wtid; - /** * The main data for the transfer. */ @@ -3370,14 +3375,18 @@ make_transfer (const struct ExchangeSignkeyData *signkey, * @return 1 on success, 0 otherwise. */ static int -test_lookup_transfer (const struct TransferData *transfer) +test_lookup_transfer ( + const struct InstanceData *instance, + const struct TransferData *transfer) { struct TALER_Amount total_with_fee; struct TALER_Amount total; struct TALER_Amount fee; struct GNUNET_TIME_Absolute time; bool verified; + if (1 != plugin->lookup_transfer (plugin->cls, + instance->instance.id, transfer->exchange_url, &transfer->wtid, &total, @@ -3482,12 +3491,12 @@ lookup_transfer_summary_cb (void *cls, * @return 1 on success, 0 otherwise. */ static int -test_lookup_transfer_summary (const char *exchange_url, - const struct - TALER_WireTransferIdentifierRawP *wtid, - const char *expected_order_id, - const struct TALER_Amount *expected_deposit_value, - const struct TALER_Amount *expected_deposit_fee) +test_lookup_transfer_summary ( + const char *exchange_url, + const struct TALER_WireTransferIdentifierRawP *wtid, + const char *expected_order_id, + const struct TALER_Amount *expected_deposit_value, + const struct TALER_Amount *expected_deposit_fee) { struct TestLookupTransferSummary_Closure cmp = { .order_id = expected_order_id, @@ -3591,11 +3600,11 @@ lookup_transfer_details_cb (void *cls, * @return 1 on success, 0 otherwise. */ static int -test_lookup_transfer_details (const char *exchange_url, - const struct - TALER_WireTransferIdentifierRawP *wtid, - unsigned int details_length, - const struct TALER_TrackTransferDetails *details) +test_lookup_transfer_details ( + const char *exchange_url, + const struct TALER_WireTransferIdentifierRawP *wtid, + unsigned int details_length, + const struct TALER_TrackTransferDetails *details) { unsigned int results_matching[details_length]; struct TestLookupTransferDetails_Closure cmp = { @@ -3676,14 +3685,14 @@ struct TestLookupTransferDetailsByOrder_Closure * @param transfer_confirmed whether the transfer was confirmed. */ static void -lookup_transfer_details_order_cb (void *cls, - const struct - TALER_WireTransferIdentifierRawP *wtid, - const char *exchange_url, - struct GNUNET_TIME_Absolute execution_time, - const struct TALER_Amount *deposit_value, - const struct TALER_Amount *deposit_fee, - bool transfer_confirmed) +lookup_transfer_details_order_cb ( + void *cls, + const struct TALER_WireTransferIdentifierRawP *wtid, + const char *exchange_url, + struct GNUNET_TIME_Absolute execution_time, + const struct TALER_Amount *deposit_value, + const struct TALER_Amount *deposit_fee, + bool transfer_confirmed) { struct TestLookupTransferDetailsByOrder_Closure *cmp = cls; if (NULL == cmp) @@ -3724,10 +3733,10 @@ lookup_transfer_details_order_cb (void *cls, * @return 0 on success, 1 otherwise. */ static int -test_lookup_transfer_details_by_order (uint64_t order_serial, - unsigned int transfers_length, - const struct - TransferData *transfers) +test_lookup_transfer_details_by_order ( + uint64_t order_serial, + unsigned int transfers_length, + const struct TransferData *transfers) { unsigned int results_matching[transfers_length]; struct TestLookupTransferDetailsByOrder_Closure cmp = { @@ -4051,6 +4060,7 @@ test_insert_deposit_to_transfer (const struct InstanceData *instance, uint64_t deposit_serial = get_deposit_serial (instance, order, deposit); + TEST_COND_RET_ON_FAIL (expected_result == plugin->insert_deposit_to_transfer (plugin->cls, deposit_serial, @@ -4070,11 +4080,11 @@ test_insert_deposit_to_transfer (const struct InstanceData *instance, * @return 0 on success, 1 otherwise. */ static int -test_insert_transfer_details (const struct InstanceData *instance, - const struct - TALER_MERCHANTDB_AccountDetails *account, - const struct TransferData *transfer, - enum GNUNET_DB_QueryStatus expected_result) +test_insert_transfer_details ( + const struct InstanceData *instance, + const struct TALER_MERCHANTDB_AccountDetails *account, + const struct TransferData *transfer, + enum GNUNET_DB_QueryStatus expected_result) { TEST_COND_RET_ON_FAIL (expected_result == plugin->insert_transfer_details (plugin->cls, @@ -4285,7 +4295,8 @@ run_test_transfers (struct TestTransfers_Closure *cls) NULL, false, true)); - TEST_RET_ON_FAIL (test_lookup_transfer (&cls->transfers[0])); + TEST_RET_ON_FAIL (test_lookup_transfer (&cls->instance, + &cls->transfers[0])); TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == plugin->set_transfer_status_to_verified (plugin->cls, cls->deposit. @@ -4295,7 +4306,8 @@ run_test_transfers (struct TestTransfers_Closure *cls) wtid), "Set transfer status to verified failed\n"); cls->transfers[0].verified = true; - TEST_RET_ON_FAIL (test_lookup_transfer (&cls->transfers[0])); + TEST_RET_ON_FAIL (test_lookup_transfer (&cls->instance, + &cls->transfers[0])); TEST_RET_ON_FAIL (test_lookup_transfer_summary (cls->deposit.exchange_url, &cls->transfers[0].wtid, cls->order.id, @@ -4331,6 +4343,7 @@ static int test_transfers (void) { struct TestTransfers_Closure test_cls; + pre_test_transfers (&test_cls); int test_result = run_test_transfers (&test_cls); post_test_transfers (&test_cls); |