aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-29 23:55:11 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-29 23:55:19 +0100
commitbe451502ec5856f0a6da3a3eba49b1297f5cb452 (patch)
tree55ae193e82b14ae68470b270ee33ddf915f72b46
parent5d060aaf8b8a2cee7ad8fb764c5ab61165e34fff (diff)
add traits to proposal lookup
-rw-r--r--src/lib/testing_api_cmd_proposal_lookup.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/src/lib/testing_api_cmd_proposal_lookup.c b/src/lib/testing_api_cmd_proposal_lookup.c
index 2ab5d9e1..609e2b7b 100644
--- a/src/lib/testing_api_cmd_proposal_lookup.c
+++ b/src/lib/testing_api_cmd_proposal_lookup.c
@@ -45,6 +45,16 @@ struct ProposalLookupState
const char *merchant_url;
/**
+ * Contract terms we downloaded. Only set if we got #MHD_HTTP_OK.
+ */
+ json_t *contract_terms;
+
+ /**
+ * Hash over the contract terms.
+ */
+ struct GNUNET_HashCode contract_terms_hash;
+
+ /**
* Expected status code.
*/
unsigned int http_status;
@@ -87,6 +97,12 @@ proposal_lookup_cleanup (void *cls,
"Command '%s' did not complete\n",
cmd->label);
TALER_MERCHANT_proposal_lookup_cancel (pls->plo);
+ pls->plo = NULL;
+ }
+ if (NULL != pls->contract_terms)
+ {
+ json_decref (pls->contract_terms);
+ pls->contract_terms = NULL;
}
GNUNET_free (pls);
}
@@ -118,7 +134,12 @@ proposal_lookup_cb (void *cls,
pls->plo = NULL;
if (pls->http_status != http_status)
TALER_TESTING_FAIL (pls->is);
-
+ if (MHD_HTTP_OK == http_status)
+ {
+ pls->contract_terms = (json_t*) json;
+ json_incref (pls->contract_terms);
+ pls->contract_terms_hash = *hash;
+ }
TALER_TESTING_interpreter_next (pls->is);
}
@@ -165,7 +186,7 @@ proposal_lookup_run (void *cls,
if (GNUNET_OK != GET_TRAIT_NONCE (proposal_cmd,
&nonce))
- TALER_TESTING_FAIL (is);
+ nonce = &dummy_nonce;
if (GNUNET_OK != TALER_TESTING_get_trait_order_id
(proposal_cmd, 0, &order_id))
@@ -182,6 +203,37 @@ proposal_lookup_run (void *cls,
/**
+ * Offer internal data to other commands.
+ *
+ * @param cls closure
+ * @param ret[out] result (could be anything)
+ * @param trait name of the trait
+ * @param index index number of the object to extract.
+ * @return #GNUNET_OK on success
+ */
+static int
+proposal_lookup_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ struct ProposalLookupState *pls = cls;
+ struct TALER_TESTING_Trait traits[] = {
+ TALER_TESTING_make_trait_contract_terms (0,
+ pls->contract_terms),
+ TALER_TESTING_make_trait_h_contract_terms (0,
+ &pls->contract_terms_hash),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+
+/**
* Make a "proposal lookup" command.
*
* @param label command label.
@@ -213,7 +265,8 @@ TALER_TESTING_cmd_proposal_lookup
.cls = pls,
.label = label,
.run = &proposal_lookup_run,
- .cleanup = &proposal_lookup_cleanup
+ .cleanup = &proposal_lookup_cleanup,
+ .traits = &proposal_lookup_traits
};
return cmd;