diff options
Diffstat (limited to 'src/backenddb/test_merchantdb.c')
-rw-r--r-- | src/backenddb/test_merchantdb.c | 222 |
1 files changed, 113 insertions, 109 deletions
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 1ff6a7cf..b471f805 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -4571,8 +4571,9 @@ lookup_reserve_cb (void *cls, { for (unsigned int j = 0; rewards_length > j; ++j) { - if ((GNUNET_OK == TALER_amount_cmp_currency (&cmp->rewards[i].total_amount, - &rewards[j].total_amount)) && + if ((GNUNET_OK == TALER_amount_cmp_currency ( + &cmp->rewards[i].total_amount, + &rewards[j].total_amount)) && (0 == TALER_amount_cmp (&cmp->rewards[i].total_amount, &rewards[j].total_amount)) && (0 == strcmp (cmp->rewards[i].reason, @@ -4893,18 +4894,18 @@ make_reward (struct RewardData *reward) */ static int test_authorize_reward (const struct InstanceData *instance, - const struct ReserveData *reserve, - struct RewardData *reward) + const struct ReserveData *reserve, + struct RewardData *reward) { TEST_COND_RET_ON_FAIL (TALER_EC_NONE == plugin->authorize_reward (plugin->cls, - instance->instance.id, - &reserve->reserve_pub, - &reward->details.total_amount, - reward->details.reason, - reward->next_url, - &reward->details.reward_id, - &reward->expiration), + instance->instance.id, + &reserve->reserve_pub, + &reward->details.total_amount, + reward->details.reason, + reward->next_url, + &reward->details.reward_id, + &reward->expiration), "Authorize reward failed\n"); return 0; } @@ -4922,9 +4923,9 @@ test_authorize_reward (const struct InstanceData *instance, */ static int test_lookup_reward (const struct InstanceData *instance, - const struct ReserveData *reserve, - const struct RewardData *reward, - const struct TALER_Amount *expected_total_picked_up) + const struct ReserveData *reserve, + const struct RewardData *reward, + const struct TALER_Amount *expected_total_picked_up) { struct TALER_Amount total_authorized; struct TALER_Amount total_picked_up; @@ -4934,14 +4935,14 @@ test_lookup_reward (const struct InstanceData *instance, struct TALER_ReservePrivateKeyP reserve_priv; if (1 != plugin->lookup_reward (plugin->cls, - instance->instance.id, - &reward->details.reward_id, - &total_authorized, - &total_picked_up, - &expiration, - &exchange_url, - &next_url, - &reserve_priv)) + instance->instance.id, + &reward->details.reward_id, + &total_authorized, + &total_picked_up, + &expiration, + &exchange_url, + &next_url, + &reserve_priv)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup reward failed\n"); @@ -5011,16 +5012,16 @@ test_lookup_reward_details ( if (0 > plugin->lookup_reward_details (plugin->cls, - instance->instance.id, - &reward->details.reward_id, - true, - &total_authorized, - &total_picked_up, - &justification, - &expiration, - &reserve_pub, - &pickups_length, - &pickups)) + instance->instance.id, + &reward->details.reward_id, + true, + &total_authorized, + &total_picked_up, + &justification, + &expiration, + &reserve_pub, + &pickups_length, + &pickups)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup reward details failed\n"); @@ -5230,9 +5231,9 @@ struct TestLookupRewards_Closure */ static void lookup_rewards_cb (void *cls, - uint64_t row_id, - struct TALER_RewardIdentifierP reward_id, - struct TALER_Amount amount) + uint64_t row_id, + struct TALER_RewardIdentifierP reward_id, + struct TALER_Amount amount) { struct TestLookupRewards_Closure *cmp = cls; if (NULL == cmp) @@ -5267,11 +5268,11 @@ lookup_rewards_cb (void *cls, */ static int test_lookup_rewards (const struct InstanceData *instance, - enum TALER_EXCHANGE_YesNoAll expired, - int64_t limit, - uint64_t offset, - unsigned int rewards_length, - const struct RewardData *rewards) + enum TALER_EXCHANGE_YesNoAll expired, + int64_t limit, + uint64_t offset, + unsigned int rewards_length, + const struct RewardData *rewards) { bool results_match[rewards_length]; struct TestLookupRewards_Closure cmp = { @@ -5285,12 +5286,12 @@ test_lookup_rewards (const struct InstanceData *instance, 0, sizeof (bool) * rewards_length); if (0 > plugin->lookup_rewards (plugin->cls, - instance->instance.id, - expired, - limit, - offset, - &lookup_rewards_cb, - &cmp)) + instance->instance.id, + expired, + limit, + offset, + &lookup_rewards_cb, + &cmp)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup rewards failed\n"); @@ -5323,7 +5324,7 @@ test_lookup_rewards (const struct InstanceData *instance, */ static void reverse_reward_data_array (unsigned int rewards_length, - struct RewardData *rewards) + struct RewardData *rewards) { struct RewardData tmp[rewards_length]; for (unsigned int i = 0; i < rewards_length; ++i) @@ -5503,28 +5504,30 @@ run_test_rewards (struct TestRewards_Closure *cls) NULL)); /* Test inserting a reward */ TEST_RET_ON_FAIL (test_authorize_reward (&cls->instance, - &cls->reserve, - &cls->reward)); + &cls->reserve, + &cls->reward)); /* Test lookup reward */ TEST_RET_ON_FAIL (test_lookup_reward (&cls->instance, - &cls->reserve, - &cls->reward, - &zero)); + &cls->reserve, + &cls->reward, + &zero)); /* Test lookup reward details */ TEST_RET_ON_FAIL (test_lookup_reward_details (&cls->instance, - &cls->reserve, - &cls->reward, - &zero, - 0, - NULL)); + &cls->reserve, + &cls->reward, + &zero, + 0, + NULL)); /* Test insert pickup */ TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == plugin->insert_pickup (plugin->cls, cls->instance.instance.id, &cls->reward.details.reward_id, - &cls->reward.details.total_amount, + &cls->reward.details. + total_amount, &cls->pickup_id, - &cls->reward.details.total_amount), + &cls->reward.details. + total_amount), "Insert pickup failed\n"); /* Test lookup pickup */ TEST_RET_ON_FAIL (test_lookup_pickup (&cls->instance, @@ -5544,22 +5547,23 @@ run_test_rewards (struct TestRewards_Closure *cls) /* Test that overdrawing the reserve fails */ TEST_COND_RET_ON_FAIL (TALER_EC_NONE != plugin->authorize_reward (plugin->cls, - cls->instance.instance.id, - &cls->reserve.reserve_pub, - &cls->bigreward.details. - total_amount, - cls->bigreward.details.reason, - cls->bigreward.next_url, - &cls->bigreward.details.reward_id, - &cls->reserve.expiration), + cls->instance.instance.id, + &cls->reserve.reserve_pub, + &cls->bigreward.details. + total_amount, + cls->bigreward.details.reason, + cls->bigreward.next_url, + &cls->bigreward.details. + reward_id, + &cls->reserve.expiration), "Authorize reward failed\n"); /* Test lookup rewards */ TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance, - TALER_EXCHANGE_YNA_ALL, - 1, - 0, - 1, - &cls->reward)); + TALER_EXCHANGE_YNA_ALL, + 1, + 0, + 1, + &cls->reward)); /* Test lookup reserves */ TEST_RET_ON_FAIL (test_lookup_reserves (&cls->instance, 1, @@ -5584,14 +5588,14 @@ run_test_rewards (struct TestRewards_Closure *cls) if (i % 2 == 0) { TEST_RET_ON_FAIL (test_authorize_reward (&cls->instance, - &cls->expired_reserve, - &cls->rewards[i])); + &cls->expired_reserve, + &cls->rewards[i])); } else { TEST_RET_ON_FAIL (test_authorize_reward (&cls->instance, - &cls->reserve, - &cls->rewards[i])); + &cls->reserve, + &cls->rewards[i])); } } GNUNET_memcpy (&expected_rewards[1], @@ -5599,58 +5603,58 @@ run_test_rewards (struct TestRewards_Closure *cls) sizeof (struct RewardData) * 5); /* Test lookup rewards inc */ TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance, - TALER_EXCHANGE_YNA_ALL, - 6, - 0, - 6, - expected_rewards)); + TALER_EXCHANGE_YNA_ALL, + 6, + 0, + 6, + expected_rewards)); reverse_reward_data_array (6, - expected_rewards); + expected_rewards); /* Test lookup rewards dec */ TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance, - TALER_EXCHANGE_YNA_ALL, - -6, - 10, - 6, - expected_rewards)); + TALER_EXCHANGE_YNA_ALL, + -6, + 10, + 6, + expected_rewards)); /* Test lookup rewards expired inc */ expected_rewards[0] = cls->rewards[0]; expected_rewards[1] = cls->rewards[2]; expected_rewards[2] = cls->rewards[4]; TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance, - TALER_EXCHANGE_YNA_YES, - 6, - 0, - 3, - expected_rewards)); + TALER_EXCHANGE_YNA_YES, + 6, + 0, + 3, + expected_rewards)); /* Test lookup rewards expired dec */ reverse_reward_data_array (3, - expected_rewards); + expected_rewards); TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance, - TALER_EXCHANGE_YNA_YES, - -6, - 10, - 3, - expected_rewards)); + TALER_EXCHANGE_YNA_YES, + -6, + 10, + 3, + expected_rewards)); /* Test lookup rewards unexpired inc */ expected_rewards[0] = cls->reward; expected_rewards[1] = cls->rewards[1]; expected_rewards[2] = cls->rewards[3]; TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance, - TALER_EXCHANGE_YNA_NO, - 6, - 0, - 3, - expected_rewards)); + TALER_EXCHANGE_YNA_NO, + 6, + 0, + 3, + expected_rewards)); /* Test lookup rewards unexpired dec */ reverse_reward_data_array (3, - expected_rewards); + expected_rewards); TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance, - TALER_EXCHANGE_YNA_NO, - -6, - 10, - 3, - expected_rewards)); + TALER_EXCHANGE_YNA_NO, + -6, + 10, + 3, + expected_rewards)); } /* Test delete reserve private key */ TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == |