aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing_api_cmd_purse_deposit.c83
-rw-r--r--src/testing/testing_api_cmd_purse_merge.c2
-rw-r--r--src/testing/testing_api_cmd_reserve_purse.c10
3 files changed, 91 insertions, 4 deletions
diff --git a/src/testing/testing_api_cmd_purse_deposit.c b/src/testing/testing_api_cmd_purse_deposit.c
index ed4967776..b15ba97cf 100644
--- a/src/testing/testing_api_cmd_purse_deposit.c
+++ b/src/testing/testing_api_cmd_purse_deposit.c
@@ -88,6 +88,12 @@ struct PurseDepositState
const char *purse_ref;
/**
+ * Reserve history entry that corresponds to this operation.
+ * Will be of type #TALER_EXCHANGE_RTT_MERGE.
+ * Only valid if @e purse_complete is true.
+ */
+ struct TALER_EXCHANGE_ReserveHistoryEntry reserve_history;
+ /**
* Expected HTTP response code.
*/
unsigned int expected_response_code;
@@ -101,6 +107,11 @@ struct PurseDepositState
* Minimum age to apply to all deposits.
*/
uint8_t min_age;
+
+ /**
+ * Set to true if this deposit filled the purse.
+ */
+ bool purse_complete;
};
@@ -134,7 +145,71 @@ deposit_cb (void *cls,
}
if (MHD_HTTP_OK == dr->hr.http_status)
{
- // FIXME: any data to keep from reply?
+ if (-1 !=
+ TALER_amount_cmp (&dr->details.success.total_deposited,
+ &dr->details.success.purse_value_after_fees))
+ {
+ const struct TALER_TESTING_Command *purse_cmd;
+ const struct TALER_ReserveSignatureP *reserve_sig;
+ const struct GNUNET_TIME_Timestamp *merge_timestamp;
+
+ purse_cmd = TALER_TESTING_interpreter_lookup_command (ds->is,
+ ds->purse_ref);
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_reserve_sig (purse_cmd,
+ &reserve_sig))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ds->is);
+ return;
+ }
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_timestamp (purse_cmd,
+ 0,
+ &merge_timestamp))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ds->is);
+ return;
+ }
+
+ /* Deposits complete, create trait! */
+ ds->reserve_history.type = TALER_EXCHANGE_RTT_MERGE;
+ ds->reserve_history.amount
+ = dr->details.success.purse_value_after_fees;
+#if 0
+ {
+ const struct TALER_EXCHANGE_Keys *keys;
+ const struct TALER_EXCHANGE_GlobalFee *gf;
+
+ keys = TALER_EXCHANGE_get_keys (ds->is->exchange);
+ GNUNET_assert (NULL != keys);
+ gf = TALER_EXCHANGE_get_global_fee (keys,
+ *merge_timestamp);
+ GNUNET_assert (NULL != gf);
+ }
+#endif
+ /* Note: change when flags below changes! */
+ TALER_amount_set_zero (
+ ds->reserve_history.amount.currency,
+ &ds->reserve_history.details.merge_details.purse_fee);
+ ds->reserve_history.details.merge_details.h_contract_terms
+ = dr->details.success.h_contract_terms;
+ ds->reserve_history.details.merge_details.merge_pub
+ = dr->details.success.merge_pub;
+ ds->reserve_history.details.merge_details.reserve_sig
+ = *reserve_sig;
+ ds->reserve_history.details.merge_details.merge_timestamp
+ = *merge_timestamp;
+ ds->reserve_history.details.merge_details.purse_expiration
+ = dr->details.success.purse_expiration;
+ ds->reserve_history.details.merge_details.min_age
+ = ds->min_age;
+ ds->reserve_history.details.merge_details.flags
+ = TALER_WAMF_MODE_CREATE_FROM_PURSE_QUOTA;
+ ds->purse_complete = true;
+ }
}
TALER_TESTING_interpreter_next (ds->is);
}
@@ -293,11 +368,15 @@ deposit_traits (void *cls,
{
struct PurseDepositState *ds = cls;
struct TALER_TESTING_Trait traits[] = {
+ /* history entry MUST be first due to response code logic below! */
+ TALER_TESTING_make_trait_reserve_history (&ds->reserve_history),
TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
TALER_TESTING_trait_end ()
};
- return TALER_TESTING_get_trait (traits,
+ return TALER_TESTING_get_trait (ds->purse_complete
+ ? &traits[0] /* we have reserve history */
+ : &traits[1], /* skip reserve history */
ret,
trait,
index);
diff --git a/src/testing/testing_api_cmd_purse_merge.c b/src/testing/testing_api_cmd_purse_merge.c
index 28193b3e8..456ba66fc 100644
--- a/src/testing/testing_api_cmd_purse_merge.c
+++ b/src/testing/testing_api_cmd_purse_merge.c
@@ -140,7 +140,7 @@ merge_cb (void *cls,
gf = TALER_EXCHANGE_get_global_fee (keys,
ds->merge_timestamp);
GNUNET_assert (NULL != gf);
- ds->reserve_history.amount = gf->fees.purse;
+ ds->reserve_history.amount = ds->value_after_fees;
ds->reserve_history.details.merge_details.purse_fee = gf->fees.purse;
ds->reserve_history.details.merge_details.h_contract_terms
= ds->h_contract_terms;
diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c
index b923e1cc6..b57fff2bd 100644
--- a/src/testing/testing_api_cmd_reserve_purse.c
+++ b/src/testing/testing_api_cmd_reserve_purse.c
@@ -47,6 +47,12 @@ struct ReservePurseState
struct TALER_ReservePrivateKeyP reserve_priv;
/**
+ * Reserve signature generated for the request
+ * (client-side).
+ */
+ struct TALER_ReserveSignatureP reserve_sig;
+
+ /**
* Private key of the purse.
*/
struct TALER_PurseContractPrivateKeyP purse_priv;
@@ -118,6 +124,7 @@ purse_cb (void *cls,
struct ReservePurseState *ds = cls;
ds->dh = NULL;
+ ds->reserve_sig = *dr->reserve_sig;
if (ds->expected_response_code != dr->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -187,7 +194,7 @@ purse_run (void *cls,
&ds->contract_priv,
ds->contract_terms,
true /* upload contract */,
- false /* do not pay purse fee -- FIXME: make this a choice to test this case! */,
+ false /* do not pay purse fee -- FIXME: make this a choice to test this case; then update testing_api_cmd_purse_deposit flags logic to match! */,
ds->merge_timestamp,
&purse_cb,
ds);
@@ -254,6 +261,7 @@ purse_traits (void *cls,
TALER_TESTING_make_trait_merge_priv (&ds->merge_priv),
TALER_TESTING_make_trait_contract_priv (&ds->contract_priv),
TALER_TESTING_make_trait_reserve_priv (&ds->reserve_priv),
+ TALER_TESTING_make_trait_reserve_sig (&ds->reserve_sig),
TALER_TESTING_trait_end ()
};