aboutsummaryrefslogtreecommitdiff
path: root/src/backenddb/test_merchantdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backenddb/test_merchantdb.c')
-rw-r--r--src/backenddb/test_merchantdb.c468
1 files changed, 234 insertions, 234 deletions
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index 1db21539..1ff6a7cf 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -2046,7 +2046,7 @@ run_test_orders (struct TestOrders_Closure *cls)
return 1;
}
}
- /* Test lookups on multiple orders */
+ /* Test lookups on mulrewardle orders */
TEST_RET_ON_FAIL (test_insert_order (&cls->instance,
&cls->orders[1],
GNUNET_DB_STATUS_SUCCESS_ONE_RESULT));
@@ -3193,7 +3193,7 @@ run_test_deposits (struct TestDeposits_Closure *cls)
&cls->deposits[0].coin_pub,
1,
cls->deposits));
- /* Test multiple deposits */
+ /* Test mulrewardle deposits */
TEST_RET_ON_FAIL (test_insert_deposit (&cls->instance,
&cls->signkey,
&cls->deposits[1],
@@ -4407,7 +4407,7 @@ test_transfers (void)
}
-/* Reserves and tips */
+/* Reserves and rewards */
struct ReserveData
@@ -4482,14 +4482,14 @@ struct TestLookupReserve_Closure
const struct ReserveData *reserve_to_cmp;
/**
- * The length of @e tips.
+ * The length of @e rewards.
*/
- unsigned int tips_length;
+ unsigned int rewards_length;
/**
- * The tips that have been authorized from the reserve.
+ * The rewards that have been authorized from the reserve.
*/
- const struct TALER_MERCHANTDB_TipDetails *tips;
+ const struct TALER_MERCHANTDB_RewardDetails *rewards;
/**
* 1 if the result matches, 0 otherwise.
@@ -4506,14 +4506,14 @@ struct TestLookupReserve_Closure
* @param merchant_initial_amount initial amount that the merchant claims to have filled the
* reserve with
* @param exchange_initial_amount initial amount that the exchange claims to have received
- * @param picked_up_amount total of tips that were picked up from this reserve
- * @param committed_amount total of tips that the merchant committed to, but that were not
+ * @param picked_up_amount total of rewards that were picked up from this reserve
+ * @param committed_amount total of rewards that the merchant committed to, but that were not
* picked up yet
* @param active true if the reserve is still active (we have the private key)
* @param exchange_url base URL of the exchange hosting the reserve, NULL if not @a active
* @param payto_uri URI to use to fund the reserve, NULL if not @a active
- * @param tips_length length of the @a tips array
- * @param tips information about the tips created by this reserve
+ * @param rewards_length length of the @a rewards array
+ * @param rewards information about the rewards created by this reserve
*
* @return 0 on success, 1 otherwise.
*/
@@ -4528,11 +4528,11 @@ lookup_reserve_cb (void *cls,
bool active,
const struct TALER_MasterPublicKeyP *master_pub,
const char *exchange_url,
- unsigned int tips_length,
- const struct TALER_MERCHANTDB_TipDetails *tips)
+ unsigned int rewards_length,
+ const struct TALER_MERCHANTDB_RewardDetails *rewards)
{
struct TestLookupReserve_Closure *cmp = cls;
- unsigned int tip_cmp_results[GNUNET_NZL (tips_length)];
+ unsigned int reward_cmp_results[GNUNET_NZL (rewards_length)];
if (NULL == cmp)
return;
@@ -4545,7 +4545,7 @@ lookup_reserve_cb (void *cls,
merchant_initial_amount)) ||
(0 != TALER_amount_cmp (&cmp->reserve_to_cmp->initial_amount,
merchant_initial_amount)) ||
- (cmp->tips_length != tips_length))
+ (cmp->rewards_length != rewards_length))
{
cmp->result_matches = 1;
return;
@@ -4564,27 +4564,27 @@ lookup_reserve_cb (void *cls,
cmp->result_matches = 0;
return;
}
- memset (tip_cmp_results,
+ memset (reward_cmp_results,
0,
- sizeof (tip_cmp_results));
- for (unsigned int i = 0; tips_length > i; ++i)
+ sizeof (reward_cmp_results));
+ for (unsigned int i = 0; rewards_length > i; ++i)
{
- for (unsigned int j = 0; tips_length > j; ++j)
+ for (unsigned int j = 0; rewards_length > j; ++j)
{
- if ((GNUNET_OK == TALER_amount_cmp_currency (&cmp->tips[i].total_amount,
- &tips[j].total_amount)) &&
- (0 == TALER_amount_cmp (&cmp->tips[i].total_amount,
- &tips[j].total_amount)) &&
- (0 == strcmp (cmp->tips[i].reason,
- tips[j].reason)))
+ 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,
+ rewards[j].reason)))
{
- tip_cmp_results[i] += 1;
+ reward_cmp_results[i] += 1;
}
}
}
- for (unsigned int i = 0; tips_length > i; ++i)
+ for (unsigned int i = 0; rewards_length > i; ++i)
{
- if (1 != tip_cmp_results[i])
+ if (1 != reward_cmp_results[i])
{
cmp->result_matches = 1;
return;
@@ -4609,8 +4609,8 @@ test_lookup_reserve (const struct InstanceData *instance,
{
struct TestLookupReserve_Closure cmp = {
.reserve_to_cmp = reserve,
- .tips_length = 0,
- .tips = NULL,
+ .rewards_length = 0,
+ .rewards = NULL,
.result_matches = 0
};
if (1 != plugin->lookup_reserve (plugin->cls,
@@ -4635,7 +4635,7 @@ test_lookup_reserve (const struct InstanceData *instance,
/**
- * Container for looking up multiple reserves.
+ * Container for looking up mulrewardle reserves.
*/
struct TestLookupReserves_Closure
{
@@ -4670,8 +4670,8 @@ struct TestLookupReserves_Closure
* @param merchant_initial_amount initial amount that the merchant claims to have filled the
* reserve with
* @param exchange_initial_amount initial amount that the exchange claims to have received
- * @param pickup_amount total of tips that were picked up from this reserve
- * @param committed_amount total of tips that the merchant committed to, but that were not
+ * @param pickup_amount total of rewards that were picked up from this reserve
+ * @param committed_amount total of rewards that the merchant committed to, but that were not
* picked up yet
* @param active true if the reserve is still active (we have the private key)
*/
@@ -4847,14 +4847,14 @@ test_lookup_pending_reserves (unsigned int reserves_length,
/**
- * Container for all tip data relevant to the database.
+ * Container for all reward data relevant to the database.
*/
-struct TipData
+struct RewardData
{
/**
- * The details of the tip.
+ * The details of the reward.
*/
- struct TALER_MERCHANTDB_TipDetails details;
+ struct TALER_MERCHANTDB_RewardDetails details;
/**
* Where the user should be redirected.
@@ -4862,68 +4862,68 @@ struct TipData
const char *next_url;
/**
- * When the tip expires.
+ * When the reward expires.
*/
struct GNUNET_TIME_Timestamp expiration;
};
/**
- * Creates a tip for testing.
- * @param tip the tip to fill with data.
+ * Creates a reward for testing.
+ * @param reward the reward to fill with data.
*/
static void
-make_tip (struct TipData *tip)
+make_reward (struct RewardData *reward)
{
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount ("EUR:0.99",
- &tip->details.total_amount));
- tip->details.reason = "because";
- tip->next_url = "https://taler.net";
+ &reward->details.total_amount));
+ reward->details.reason = "because";
+ reward->next_url = "https://taler.net";
}
/**
- * Tests authorizing a tip.
- * @param instance the instance authorizing the tip.
- * @param reserve where the tip is coming from.
- * @param tip the tip to authorize.
+ * Tests authorizing a reward.
+ * @param instance the instance authorizing the reward.
+ * @param reserve where the reward is coming from.
+ * @param reward the reward to authorize.
*
* @return 0 on success, 1 otherwise.
*/
static int
-test_authorize_tip (const struct InstanceData *instance,
+test_authorize_reward (const struct InstanceData *instance,
const struct ReserveData *reserve,
- struct TipData *tip)
+ struct RewardData *reward)
{
TEST_COND_RET_ON_FAIL (TALER_EC_NONE ==
- plugin->authorize_tip (plugin->cls,
+ plugin->authorize_reward (plugin->cls,
instance->instance.id,
&reserve->reserve_pub,
- &tip->details.total_amount,
- tip->details.reason,
- tip->next_url,
- &tip->details.tip_id,
- &tip->expiration),
- "Authorize tip failed\n");
+ &reward->details.total_amount,
+ reward->details.reason,
+ reward->next_url,
+ &reward->details.reward_id,
+ &reward->expiration),
+ "Authorize reward failed\n");
return 0;
}
/**
- * Tests looking up a tip from the database.
- * @param instance the instance to look up tips from.
- * @param reserve the reserve to look up tips from.
- * @param tip the tip we expect to find (uses @e tip_id to perform lookup).
- * @param expected_total_picked_up how much of the tip should have been
+ * Tests looking up a reward from the database.
+ * @param instance the instance to look up rewards from.
+ * @param reserve the reserve to look up rewards from.
+ * @param reward the reward we expect to find (uses @e reward_id to perform lookup).
+ * @param expected_total_picked_up how much of the reward should have been
* picked up.
*
* @return 0 on success, 1 otherwise.
*/
static int
-test_lookup_tip (const struct InstanceData *instance,
+test_lookup_reward (const struct InstanceData *instance,
const struct ReserveData *reserve,
- const struct TipData *tip,
+ const struct RewardData *reward,
const struct TALER_Amount *expected_total_picked_up)
{
struct TALER_Amount total_authorized;
@@ -4933,9 +4933,9 @@ test_lookup_tip (const struct InstanceData *instance,
char *next_url = NULL;
struct TALER_ReservePrivateKeyP reserve_priv;
- if (1 != plugin->lookup_tip (plugin->cls,
+ if (1 != plugin->lookup_reward (plugin->cls,
instance->instance.id,
- &tip->details.tip_id,
+ &reward->details.reward_id,
&total_authorized,
&total_picked_up,
&expiration,
@@ -4944,21 +4944,21 @@ test_lookup_tip (const struct InstanceData *instance,
&reserve_priv))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup tip failed\n");
+ "Lookup reward failed\n");
GNUNET_free (exchange_url);
return 1;
}
if ((GNUNET_OK !=
- TALER_amount_cmp_currency (&tip->details.total_amount,
+ TALER_amount_cmp_currency (&reward->details.total_amount,
&total_authorized)) ||
- (0 != TALER_amount_cmp (&tip->details.total_amount,
+ (0 != TALER_amount_cmp (&reward->details.total_amount,
&total_authorized)) ||
(GNUNET_OK !=
TALER_amount_cmp_currency (expected_total_picked_up,
&total_picked_up)) ||
(0 != TALER_amount_cmp (expected_total_picked_up,
&total_picked_up)) ||
- (GNUNET_TIME_timestamp_cmp (tip->expiration,
+ (GNUNET_TIME_timestamp_cmp (reward->expiration,
!=,
expiration)) ||
(0 != strcmp (reserve->exchange_url,
@@ -4967,7 +4967,7 @@ test_lookup_tip (const struct InstanceData *instance,
&reserve_priv)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup tip failed: mismatched data\n");
+ "Lookup reward failed: mismatched data\n");
GNUNET_free (exchange_url);
GNUNET_free (next_url);
return 1;
@@ -4979,23 +4979,23 @@ test_lookup_tip (const struct InstanceData *instance,
/**
- * Tests looking up the details of a tip from the database.
+ * Tests looking up the details of a reward from the database.
*
- * @param instance the instance the tip is in.
- * @param reserve the reserve the tip was authorized from.
- * @param tip the tip we expect to find (uses @e tip_id to perform lookup).
- * @param expected_total_picked_up how much of the tip should have been
+ * @param instance the instance the reward is in.
+ * @param reserve the reserve the reward was authorized from.
+ * @param reward the reward we expect to find (uses @e reward_id to perform lookup).
+ * @param expected_total_picked_up how much of the reward should have been
* picked up.
* @param expected_pickups_length the length of @e expected_pickups.
* @param expected_pickups the pickups that we expect to be associated with
- * the tip.
+ * the reward.
* @return 0 on success, 1 otherwise.
*/
static int
-test_lookup_tip_details (
+test_lookup_reward_details (
const struct InstanceData *instance,
const struct ReserveData *reserve,
- const struct TipData *tip,
+ const struct RewardData *reward,
const struct TALER_Amount *expected_total_picked_up,
unsigned int expected_pickups_length,
const struct TALER_MERCHANTDB_PickupDetails *expected_pickups)
@@ -5010,9 +5010,9 @@ test_lookup_tip_details (
unsigned int results_matching[GNUNET_NZL (expected_pickups_length)];
if (0 >
- plugin->lookup_tip_details (plugin->cls,
+ plugin->lookup_reward_details (plugin->cls,
instance->instance.id,
- &tip->details.tip_id,
+ &reward->details.reward_id,
true,
&total_authorized,
&total_picked_up,
@@ -5023,24 +5023,24 @@ test_lookup_tip_details (
&pickups))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup tip details failed\n");
+ "Lookup reward details failed\n");
GNUNET_free (justification);
GNUNET_free (pickups);
return 1;
}
if ( (GNUNET_OK !=
- TALER_amount_cmp_currency (&tip->details.total_amount,
+ TALER_amount_cmp_currency (&reward->details.total_amount,
&total_authorized)) ||
- (0 != TALER_amount_cmp (&tip->details.total_amount,
+ (0 != TALER_amount_cmp (&reward->details.total_amount,
&total_authorized)) ||
(GNUNET_OK !=
TALER_amount_cmp_currency (expected_total_picked_up,
&total_picked_up)) ||
(0 != TALER_amount_cmp (expected_total_picked_up,
&total_picked_up)) ||
- (0 != strcmp (tip->details.reason,
+ (0 != strcmp (reward->details.reason,
justification)) ||
- (GNUNET_TIME_timestamp_cmp (tip->expiration,
+ (GNUNET_TIME_timestamp_cmp (reward->expiration,
!=,
expiration)) ||
(0 != GNUNET_memcmp (&reserve->reserve_pub,
@@ -5048,7 +5048,7 @@ test_lookup_tip_details (
(expected_pickups_length != pickups_length) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup tip details failed: mismatched data\n");
+ "Lookup reward details failed: mismatched data\n");
GNUNET_free (justification);
GNUNET_free (pickups);
return 1;
@@ -5079,7 +5079,7 @@ test_lookup_tip_details (
if (1 != results_matching[i])
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup tip details failed: mismatched data\n");
+ "Lookup reward details failed: mismatched data\n");
GNUNET_free (justification);
GNUNET_free (pickups);
return 1;
@@ -5104,9 +5104,9 @@ free_signature_array (unsigned int sigs_length,
/**
- * Tests looking up a tip pickup.
+ * Tests looking up a reward pickup.
* @param instance the instance to look up from.
- * @param tip the tip the pickup was made for.
+ * @param reward the reward the pickup was made for.
* @param pickup_id id of the pickup to look up.
* @param expected_exchange_url exchange url for the pickup.
* @param expected_reserve_priv reserve private key for the pickup.
@@ -5118,7 +5118,7 @@ free_signature_array (unsigned int sigs_length,
static int
test_lookup_pickup (
const struct InstanceData *instance,
- const struct TipData *tip,
+ const struct RewardData *reward,
const struct TALER_PickupIdentifierP *pickup_id,
const char *expected_exchange_url,
const struct TALER_ReservePrivateKeyP *expected_reserve_priv,
@@ -5136,7 +5136,7 @@ test_lookup_pickup (
sizeof (sigs));
if (0 > plugin->lookup_pickup (plugin->cls,
instance->instance.id,
- &tip->details.tip_id,
+ &reward->details.reward_id,
pickup_id,
&exchange_url,
&reserve_priv,
@@ -5195,19 +5195,19 @@ test_lookup_pickup (
/**
- * Closure for testing lookup_tips.
+ * Closure for testing lookup_rewards.
*/
-struct TestLookupTips_Closure
+struct TestLookupRewards_Closure
{
/**
- * The length of @e tips_to_cmp.
+ * The length of @e rewards_to_cmp.
*/
- unsigned int tips_to_cmp_length;
+ unsigned int rewards_to_cmp_length;
/**
- * The tips that we are expecting to find.
+ * The rewards that we are expecting to find.
*/
- const struct TipData *tips_to_cmp;
+ const struct RewardData *rewards_to_cmp;
/**
* The number of results found from the lookup.
@@ -5215,38 +5215,38 @@ struct TestLookupTips_Closure
unsigned int results_length;
/**
- * Whether each result matches with the corresponding tip in @tips_to_cmp.
+ * Whether each result matches with the corresponding reward in @rewards_to_cmp.
*/
bool *results_match;
};
/**
- * Called after test_lookup_tips.
- * @param cls pointer to a TestLookupTips_Closure.
- * @param row_id the row id of the tip.
- * @param tip_id the id of the tip.
- * @param amount the amount of the tip.
+ * Called after test_lookup_rewards.
+ * @param cls pointer to a TestLookupRewards_Closure.
+ * @param row_id the row id of the reward.
+ * @param reward_id the id of the reward.
+ * @param amount the amount of the reward.
*/
static void
-lookup_tips_cb (void *cls,
+lookup_rewards_cb (void *cls,
uint64_t row_id,
- struct TALER_TipIdentifierP tip_id,
+ struct TALER_RewardIdentifierP reward_id,
struct TALER_Amount amount)
{
- struct TestLookupTips_Closure *cmp = cls;
+ struct TestLookupRewards_Closure *cmp = cls;
if (NULL == cmp)
return;
unsigned int i = cmp->results_length;
cmp->results_length += 1;
- if (cmp->tips_to_cmp_length > i)
+ if (cmp->rewards_to_cmp_length > i)
{
- if ((0 == GNUNET_memcmp (&cmp->tips_to_cmp[i].details.tip_id,
- &tip_id)) &&
+ if ((0 == GNUNET_memcmp (&cmp->rewards_to_cmp[i].details.reward_id,
+ &reward_id)) &&
(GNUNET_OK == TALER_amount_cmp_currency (
- &cmp->tips_to_cmp[i].details.total_amount,
+ &cmp->rewards_to_cmp[i].details.total_amount,
&amount)) &&
- (0 == TALER_amount_cmp (&cmp->tips_to_cmp[i].details.total_amount,
+ (0 == TALER_amount_cmp (&cmp->rewards_to_cmp[i].details.total_amount,
&amount)))
cmp->results_match[i] = true;
else
@@ -5256,59 +5256,59 @@ lookup_tips_cb (void *cls,
/**
- * Tests looking up the tips from the database.
- * @param instance the instance to look up tips from.
- * @param expired how to filter expired tips.
- * @param offset where to start retrieving tips.
- * @param tips_length length of @e tips.
- * @param tips the tips that we expect to find.
+ * Tests looking up the rewards from the database.
+ * @param instance the instance to look up rewards from.
+ * @param expired how to filter expired rewards.
+ * @param offset where to start retrieving rewards.
+ * @param rewards_length length of @e rewards.
+ * @param rewards the rewards that we expect to find.
*
* @return 0 on success, 1 otherwise.
*/
static int
-test_lookup_tips (const struct InstanceData *instance,
+test_lookup_rewards (const struct InstanceData *instance,
enum TALER_EXCHANGE_YesNoAll expired,
int64_t limit,
uint64_t offset,
- unsigned int tips_length,
- const struct TipData *tips)
+ unsigned int rewards_length,
+ const struct RewardData *rewards)
{
- bool results_match[tips_length];
- struct TestLookupTips_Closure cmp = {
- .tips_to_cmp_length = tips_length,
- .tips_to_cmp = tips,
+ bool results_match[rewards_length];
+ struct TestLookupRewards_Closure cmp = {
+ .rewards_to_cmp_length = rewards_length,
+ .rewards_to_cmp = rewards,
.results_length = 0,
.results_match = results_match
};
memset (results_match,
0,
- sizeof (bool) * tips_length);
- if (0 > plugin->lookup_tips (plugin->cls,
+ sizeof (bool) * rewards_length);
+ if (0 > plugin->lookup_rewards (plugin->cls,
instance->instance.id,
expired,
limit,
offset,
- &lookup_tips_cb,
+ &lookup_rewards_cb,
&cmp))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup tips failed\n");
+ "Lookup rewards failed\n");
return 1;
}
- if (tips_length != cmp.results_length)
+ if (rewards_length != cmp.results_length)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup tips failed: incorrect number of results (%d)\n",
+ "Lookup rewards failed: incorrect number of results (%d)\n",
cmp.results_length);
return 1;
}
- for (unsigned int i = 0; i < tips_length; ++i)
+ for (unsigned int i = 0; i < rewards_length; ++i)
{
if (true != cmp.results_match[i])
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Lookup tips failed: mismatched data\n");
+ "Lookup rewards failed: mismatched data\n");
return 1;
}
}
@@ -5317,26 +5317,26 @@ test_lookup_tips (const struct InstanceData *instance,
/**
- * Convenience function for testing lookup tips with filters
- * @param tips_length length of @e tips.
- * @param tips the array of tips to reverse.
+ * Convenience function for testing lookup rewards with filters
+ * @param rewards_length length of @e rewards.
+ * @param rewards the array of rewards to reverse.
*/
static void
-reverse_tip_data_array (unsigned int tips_length,
- struct TipData *tips)
+reverse_reward_data_array (unsigned int rewards_length,
+ struct RewardData *rewards)
{
- struct TipData tmp[tips_length];
- for (unsigned int i = 0; i < tips_length; ++i)
- tmp[i] = tips[tips_length - 1 - i];
- for (unsigned int i = 0; i < tips_length; ++i)
- tips[i] = tmp[i];
+ struct RewardData tmp[rewards_length];
+ for (unsigned int i = 0; i < rewards_length; ++i)
+ tmp[i] = rewards[rewards_length - 1 - i];
+ for (unsigned int i = 0; i < rewards_length; ++i)
+ rewards[i] = tmp[i];
}
/**
- * Container for data for testing tips.
+ * Container for data for testing rewards.
*/
-struct TestTips_Closure
+struct TestRewards_Closure
{
/**
* The instance.
@@ -5344,7 +5344,7 @@ struct TestTips_Closure
struct InstanceData instance;
/**
- * The tip reserve data.
+ * The reward reserve data.
*/
struct ReserveData reserve;
@@ -5354,19 +5354,19 @@ struct TestTips_Closure
struct ReserveData expired_reserve;
/**
- * A normal tip.
+ * A normal reward.
*/
- struct TipData tip;
+ struct RewardData reward;
/**
- * A tip that is too large to authorize.
+ * A reward that is too large to authorize.
*/
- struct TipData bigtip;
+ struct RewardData bigreward;
/**
- * Array of tips for testing lookups.
+ * Array of rewards for testing lookups.
*/
- struct TipData tips[5];
+ struct RewardData rewards[5];
/**
* Id of a pickup.
@@ -5386,14 +5386,14 @@ struct TestTips_Closure
/**
- * Prepares for testing tips functionality.
+ * Prepares for testing rewards functionality.
* @param cls the data to prepare.
*/
static void
-pre_test_tips (struct TestTips_Closure *cls)
+pre_test_rewards (struct TestRewards_Closure *cls)
{
/* Instance */
- make_instance ("test_inst_tips",
+ make_instance ("test_inst_rewards",
&cls->instance);
/* Reserve */
@@ -5425,23 +5425,23 @@ pre_test_tips (struct TestTips_Closure *cls)
sizeof (cls->expired_reserve.master_pub));
cls->expired_reserve.expiration = GNUNET_TIME_UNIT_ZERO_TS;
- /* Tip/pickup */
- make_tip (&cls->tip);
- make_tip (&cls->bigtip);
+ /* Reward/pickup */
+ make_reward (&cls->reward);
+ make_reward (&cls->bigreward);
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount ("EUR:99.90",
- &cls->bigtip.details.total_amount));
+ &cls->bigreward.details.total_amount));
for (unsigned int i = 0; i < 5; ++i)
{
char amount[16];
- make_tip (&cls->tips[i]);
+ make_reward (&cls->rewards[i]);
GNUNET_snprintf (amount,
16,
"EUR:0.%u0",
i + 1);
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (amount,
- &cls->tips[i].details.total_amount));
+ &cls->rewards[i].details.total_amount));
}
cls->pickup_priv = GNUNET_CRYPTO_rsa_private_key_create (2048);
@@ -5453,11 +5453,11 @@ pre_test_tips (struct TestTips_Closure *cls)
/**
- * Cleans up after testing tips.
+ * Cleans up after testing rewards.
* @param cls the data to clean up.
*/
static void
-post_test_tips (struct TestTips_Closure *cls)
+post_test_rewards (struct TestRewards_Closure *cls)
{
free_instance_data (&cls->instance);
GNUNET_CRYPTO_rsa_private_key_free (cls->pickup_priv);
@@ -5466,13 +5466,13 @@ post_test_tips (struct TestTips_Closure *cls)
/**
- * Runs tests for tips.
+ * Runs tests for rewards.
* @param cls container of test data.
*
* @return 0 on success, 1 on failure.
*/
static int
-run_test_tips (struct TestTips_Closure *cls)
+run_test_rewards (struct TestRewards_Closure *cls)
{
struct TALER_Amount zero;
@@ -5501,19 +5501,19 @@ run_test_tips (struct TestTips_Closure *cls)
"Activate reserve failed\n");
TEST_RET_ON_FAIL (test_lookup_pending_reserves (0,
NULL));
- /* Test inserting a tip */
- TEST_RET_ON_FAIL (test_authorize_tip (&cls->instance,
+ /* Test inserting a reward */
+ TEST_RET_ON_FAIL (test_authorize_reward (&cls->instance,
&cls->reserve,
- &cls->tip));
- /* Test lookup tip */
- TEST_RET_ON_FAIL (test_lookup_tip (&cls->instance,
+ &cls->reward));
+ /* Test lookup reward */
+ TEST_RET_ON_FAIL (test_lookup_reward (&cls->instance,
&cls->reserve,
- &cls->tip,
+ &cls->reward,
&zero));
- /* Test lookup tip details */
- TEST_RET_ON_FAIL (test_lookup_tip_details (&cls->instance,
+ /* Test lookup reward details */
+ TEST_RET_ON_FAIL (test_lookup_reward_details (&cls->instance,
&cls->reserve,
- &cls->tip,
+ &cls->reward,
&zero,
0,
NULL));
@@ -5521,14 +5521,14 @@ run_test_tips (struct TestTips_Closure *cls)
TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
plugin->insert_pickup (plugin->cls,
cls->instance.instance.id,
- &cls->tip.details.tip_id,
- &cls->tip.details.total_amount,
+ &cls->reward.details.reward_id,
+ &cls->reward.details.total_amount,
&cls->pickup_id,
- &cls->tip.details.total_amount),
+ &cls->reward.details.total_amount),
"Insert pickup failed\n");
/* Test lookup pickup */
TEST_RET_ON_FAIL (test_lookup_pickup (&cls->instance,
- &cls->tip,
+ &cls->reward,
&cls->pickup_id,
cls->reserve.exchange_url,
&cls->reserve.reserve_priv,
@@ -5543,31 +5543,31 @@ run_test_tips (struct TestTips_Closure *cls)
"Insert pickup blind signature failed\n");
/* Test that overdrawing the reserve fails */
TEST_COND_RET_ON_FAIL (TALER_EC_NONE !=
- plugin->authorize_tip (plugin->cls,
+ plugin->authorize_reward (plugin->cls,
cls->instance.instance.id,
&cls->reserve.reserve_pub,
- &cls->bigtip.details.
+ &cls->bigreward.details.
total_amount,
- cls->bigtip.details.reason,
- cls->bigtip.next_url,
- &cls->bigtip.details.tip_id,
+ cls->bigreward.details.reason,
+ cls->bigreward.next_url,
+ &cls->bigreward.details.reward_id,
&cls->reserve.expiration),
- "Authorize tip failed\n");
- /* Test lookup tips */
- TEST_RET_ON_FAIL (test_lookup_tips (&cls->instance,
+ "Authorize reward failed\n");
+ /* Test lookup rewards */
+ TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance,
TALER_EXCHANGE_YNA_ALL,
1,
0,
1,
- &cls->tip));
+ &cls->reward));
/* Test lookup reserves */
TEST_RET_ON_FAIL (test_lookup_reserves (&cls->instance,
1,
&cls->reserve));
{
- /* Test lookup tips & friends */
- struct TipData expected_tips[6];
- expected_tips[0] = cls->tip;
+ /* Test lookup rewards & friends */
+ struct RewardData expected_rewards[6];
+ expected_rewards[0] = cls->reward;
TEST_RET_ON_FAIL (test_insert_reserve (&cls->instance,
&cls->expired_reserve,
TALER_EC_NONE));
@@ -5583,74 +5583,74 @@ run_test_tips (struct TestTips_Closure *cls)
{
if (i % 2 == 0)
{
- TEST_RET_ON_FAIL (test_authorize_tip (&cls->instance,
+ TEST_RET_ON_FAIL (test_authorize_reward (&cls->instance,
&cls->expired_reserve,
- &cls->tips[i]));
+ &cls->rewards[i]));
}
else
{
- TEST_RET_ON_FAIL (test_authorize_tip (&cls->instance,
+ TEST_RET_ON_FAIL (test_authorize_reward (&cls->instance,
&cls->reserve,
- &cls->tips[i]));
+ &cls->rewards[i]));
}
}
- GNUNET_memcpy (&expected_tips[1],
- cls->tips,
- sizeof (struct TipData) * 5);
- /* Test lookup tips inc */
- TEST_RET_ON_FAIL (test_lookup_tips (&cls->instance,
+ GNUNET_memcpy (&expected_rewards[1],
+ cls->rewards,
+ 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_tips));
- reverse_tip_data_array (6,
- expected_tips);
- /* Test lookup tips dec */
- TEST_RET_ON_FAIL (test_lookup_tips (&cls->instance,
+ expected_rewards));
+ reverse_reward_data_array (6,
+ expected_rewards);
+ /* Test lookup rewards dec */
+ TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance,
TALER_EXCHANGE_YNA_ALL,
-6,
10,
6,
- expected_tips));
- /* Test lookup tips expired inc */
- expected_tips[0] = cls->tips[0];
- expected_tips[1] = cls->tips[2];
- expected_tips[2] = cls->tips[4];
- TEST_RET_ON_FAIL (test_lookup_tips (&cls->instance,
+ 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_tips));
- /* Test lookup tips expired dec */
- reverse_tip_data_array (3,
- expected_tips);
- TEST_RET_ON_FAIL (test_lookup_tips (&cls->instance,
+ expected_rewards));
+ /* Test lookup rewards expired dec */
+ reverse_reward_data_array (3,
+ expected_rewards);
+ TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance,
TALER_EXCHANGE_YNA_YES,
-6,
10,
3,
- expected_tips));
- /* Test lookup tips unexpired inc */
- expected_tips[0] = cls->tip;
- expected_tips[1] = cls->tips[1];
- expected_tips[2] = cls->tips[3];
- TEST_RET_ON_FAIL (test_lookup_tips (&cls->instance,
+ 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_tips));
- /* Test lookup tips unexpired dec */
- reverse_tip_data_array (3,
- expected_tips);
- TEST_RET_ON_FAIL (test_lookup_tips (&cls->instance,
+ expected_rewards));
+ /* Test lookup rewards unexpired dec */
+ reverse_reward_data_array (3,
+ expected_rewards);
+ TEST_RET_ON_FAIL (test_lookup_rewards (&cls->instance,
TALER_EXCHANGE_YNA_NO,
-6,
10,
3,
- expected_tips));
+ expected_rewards));
}
/* Test delete reserve private key */
TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
@@ -5680,17 +5680,17 @@ run_test_tips (struct TestTips_Closure *cls)
/**
- * Handles all logic for testing tips in the database.
+ * Handles all logic for testing rewards in the database.
*
* @return 0 on success, 1 on failure.
*/
static int
-test_tips (void)
+test_rewards (void)
{
- struct TestTips_Closure test_cls;
- pre_test_tips (&test_cls);
- int test_result = run_test_tips (&test_cls);
- post_test_tips (&test_cls);
+ struct TestRewards_Closure test_cls;
+ pre_test_rewards (&test_cls);
+ int test_result = run_test_rewards (&test_cls);
+ post_test_rewards (&test_cls);
return test_result;
}
@@ -8385,7 +8385,7 @@ run_tests (void)
TEST_RET_ON_FAIL (test_orders ());
TEST_RET_ON_FAIL (test_deposits ());
TEST_RET_ON_FAIL (test_transfers ());
- TEST_RET_ON_FAIL (test_tips ());
+ TEST_RET_ON_FAIL (test_rewards ());
TEST_RET_ON_FAIL (test_refunds ());
TEST_RET_ON_FAIL (test_lookup_orders_all_filters ());
TEST_RET_ON_FAIL (test_kyc ());