summaryrefslogtreecommitdiff
path: root/src/exchange-lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange-lib')
-rw-r--r--src/exchange-lib/testing_api_cmd_deposit.c34
-rw-r--r--src/exchange-lib/testing_api_cmd_refund.c12
-rw-r--r--src/exchange-lib/testing_api_cmd_track.c11
-rw-r--r--src/exchange-lib/testing_api_trait_string.c4
4 files changed, 25 insertions, 36 deletions
diff --git a/src/exchange-lib/testing_api_cmd_deposit.c b/src/exchange-lib/testing_api_cmd_deposit.c
index c6c3c4330..18d409e23 100644
--- a/src/exchange-lib/testing_api_cmd_deposit.c
+++ b/src/exchange-lib/testing_api_cmd_deposit.c
@@ -63,7 +63,7 @@ struct DepositState
/**
* JSON string describing what a proposal is about.
*/
- const char *contract_terms;
+ json_t *contract_terms;
/**
* Relative time (to add to 'now') to compute the refund
@@ -257,7 +257,6 @@ deposit_run (void *cls,
struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
struct TALER_MerchantPublicKeyP merchant_pub;
struct GNUNET_HashCode h_contract_terms;
- json_t *contract_terms;
struct TALER_Amount amount;
ds->is = is;
@@ -302,21 +301,11 @@ deposit_run (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
- contract_terms = json_loads (ds->contract_terms,
- JSON_REJECT_DUPLICATES,
- NULL);
- if (NULL == contract_terms)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to parse proposal data `%s' at %u/%s\n",
- ds->contract_terms, is->ip, this_cmd->label);
- TALER_TESTING_interpreter_fail (is);
- return;
- }
+
GNUNET_assert (GNUNET_OK ==
- TALER_JSON_hash (contract_terms,
+ TALER_JSON_hash (ds->contract_terms,
&h_contract_terms));
- json_decref (contract_terms);
+
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
&coin_pub.eddsa_pub);
@@ -427,6 +416,7 @@ deposit_cleanup (void *cls,
ds->retry_task = NULL;
}
json_decref (ds->wire_details);
+ json_decref (ds->contract_terms);
GNUNET_free (ds);
}
@@ -545,7 +535,19 @@ TALER_TESTING_cmd_deposit
ds->coin_reference = coin_reference;
ds->coin_index = coin_index;
ds->wire_details = wire_details;
- ds->contract_terms = contract_terms;
+ ds->contract_terms = json_loads (contract_terms,
+ JSON_REJECT_DUPLICATES,
+ NULL);
+ if (NULL == ds->contract_terms)
+ {
+ GNUNET_log
+ (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to parse contract terms `%s' for CMD `%s'\n",
+ contract_terms,
+ label);
+ GNUNET_assert (0);
+ }
+
ds->refund_deadline = refund_deadline;
ds->amount = amount;
ds->expected_response_code = expected_response_code;
diff --git a/src/exchange-lib/testing_api_cmd_refund.c b/src/exchange-lib/testing_api_cmd_refund.c
index de70da27b..3298d6ab0 100644
--- a/src/exchange-lib/testing_api_cmd_refund.c
+++ b/src/exchange-lib/testing_api_cmd_refund.c
@@ -145,9 +145,8 @@ refund_run (void *cls,
struct RefundState *rs = cls;
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
struct TALER_CoinSpendPublicKeyP coin;
- const char *contract_terms;
+ const json_t *contract_terms;
struct GNUNET_HashCode h_contract_terms;
- json_t *j_contract_terms;
struct TALER_Amount refund_fee;
struct TALER_Amount refund_amount;
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
@@ -199,17 +198,10 @@ refund_run (void *cls,
return;
}
- j_contract_terms = json_loads
- (contract_terms, JSON_REJECT_DUPLICATES, NULL);
-
- /* Very unlikely to fail */
- GNUNET_assert (NULL != j_contract_terms);
GNUNET_assert (GNUNET_OK ==
- TALER_JSON_hash (j_contract_terms,
+ TALER_JSON_hash (contract_terms,
&h_contract_terms));
- json_decref (j_contract_terms);
-
/* Hunting for a coin .. */
if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
(coin_cmd, 0, &coin_priv))
diff --git a/src/exchange-lib/testing_api_cmd_track.c b/src/exchange-lib/testing_api_cmd_track.c
index 6c9d9fd55..535d5e55e 100644
--- a/src/exchange-lib/testing_api_cmd_track.c
+++ b/src/exchange-lib/testing_api_cmd_track.c
@@ -269,9 +269,8 @@ track_transaction_run (void *cls,
const struct TALER_TESTING_Command *transaction_cmd;
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
struct TALER_CoinSpendPublicKeyP coin_pub;
- const char *contract_terms;
+ const json_t *contract_terms;
const json_t *wire_details;
- json_t *j_contract_terms;
struct GNUNET_HashCode h_wire_details;
struct GNUNET_HashCode h_contract_terms;
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
@@ -315,11 +314,7 @@ track_transaction_run (void *cls,
return;
}
- /* Parse them.. */
- j_contract_terms = json_loads
- (contract_terms, JSON_REJECT_DUPLICATES, NULL);
-
- if ((NULL == wire_details) || (NULL == j_contract_terms))
+ if ((NULL == wire_details) || (NULL == contract_terms))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (tts->is);
@@ -332,7 +327,7 @@ track_transaction_run (void *cls,
TALER_JSON_merchant_wire_signature_hash (wire_details,
&h_wire_details)) &&
(GNUNET_OK ==
- TALER_JSON_hash (j_contract_terms,
+ TALER_JSON_hash (contract_terms,
&h_contract_terms)) );
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key
diff --git a/src/exchange-lib/testing_api_trait_string.c b/src/exchange-lib/testing_api_trait_string.c
index d26f2e046..8b8f511a7 100644
--- a/src/exchange-lib/testing_api_trait_string.c
+++ b/src/exchange-lib/testing_api_trait_string.c
@@ -49,7 +49,7 @@ int
TALER_TESTING_get_trait_contract_terms
(const struct TALER_TESTING_Command *cmd,
unsigned int index,
- const char **contract_terms)
+ const json_t **contract_terms)
{
return cmd->traits (cmd->cls,
(const void **) contract_terms,
@@ -67,7 +67,7 @@ TALER_TESTING_get_trait_contract_terms
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_contract_terms
(unsigned int index,
- const char *contract_terms)
+ const json_t *contract_terms)
{
struct TALER_TESTING_Trait ret = {
.index = index,