summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_merchant_get_order.c
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-10 03:32:03 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-07-10 03:32:03 -0400
commita043ee5eed5eae2d1629fe7fd7546767b74bf586 (patch)
tree420d17e0e09baa016dd9c2591522e4997ba459d4 /src/testing/testing_api_cmd_merchant_get_order.c
parentb08d3066dc01123b71912aa708d3e35e7e4c257b (diff)
downloadmerchant-a043ee5eed5eae2d1629fe7fd7546767b74bf586.tar.gz
merchant-a043ee5eed5eae2d1629fe7fd7546767b74bf586.tar.bz2
merchant-a043ee5eed5eae2d1629fe7fd7546767b74bf586.zip
checks for refunds and transfers returned in merchant get order
Diffstat (limited to 'src/testing/testing_api_cmd_merchant_get_order.c')
-rw-r--r--src/testing/testing_api_cmd_merchant_get_order.c127
1 files changed, 121 insertions, 6 deletions
diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c
index cf0263ba..7364291b 100644
--- a/src/testing/testing_api_cmd_merchant_get_order.c
+++ b/src/testing/testing_api_cmd_merchant_get_order.c
@@ -169,7 +169,112 @@ merchant_get_order_cb (
return;
}
}
+ if (gos->wired != osr->details.paid.wired)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Order wired does not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ if (gos->transfers_length != osr->details.paid.wts_len)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Number of transfers found does not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ for (unsigned int i = 0; i < gos->transfers_length; ++i)
+ {
+ const struct TALER_TESTING_Command *transfer_cmd;
+
+ transfer_cmd = TALER_TESTING_interpreter_lookup_command (
+ gos->is,
+ gos->transfers[i]);
+ {
+ const struct TALER_WireTransferIdentifierRawP *wtid;
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_wtid (transfer_cmd,
+ 0,
+ &wtid))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch wire transfer id\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ if (0 != GNUNET_memcmp (wtid,
+ &osr->details.paid.wts[i].wtid))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Wire transfer id does not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ }
+ {
+ const char *exchange_url;
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_string (transfer_cmd,
+ 1,
+ &exchange_url))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch wire transfer exchange url\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ if (0 != strcmp (exchange_url,
+ osr->details.paid.wts[i].exchange_url))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Wire transfer exchange url does not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ }
+ {
+ struct TALER_Amount transfer_total;
+ const struct TALER_Amount *transfer_amount;
+ const struct TALER_Amount *transfer_fee;
+ if ((GNUNET_OK !=
+ TALER_TESTING_get_trait_amount_obj (transfer_cmd,
+ 0,
+ &transfer_amount)) ||
+ (GNUNET_OK !=
+ TALER_TESTING_get_trait_amount_obj (transfer_cmd,
+ 1,
+ &transfer_fee)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch wire transfer amount/fee\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ if (0 > TALER_amount_add (&transfer_total,
+ transfer_amount,
+ transfer_fee))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not total wire transfer\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ if ((GNUNET_OK != TALER_amount_cmp_currency (&transfer_total,
+ &osr->details.paid.wts[i]
+ .total_amount)) ||
+ (0 != TALER_amount_cmp (&transfer_total,
+ &osr->details.paid.wts[i].total_amount)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Wire transfer total does not match\n");
+ TALER_TESTING_interpreter_fail (gos->is);
+ return;
+ }
+ }
+ }
if (gos->refunded != osr->details.paid.refunded)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -326,6 +431,12 @@ merchant_get_order_cleanup (void *cls,
TALER_LOG_WARNING ("Get tip operation did not complete\n");
TALER_MERCHANT_merchant_order_get_cancel (gos->ogh);
}
+ GNUNET_array_grow (gos->transfers,
+ gos->transfers_length,
+ 0);
+ GNUNET_array_grow (gos->refunds,
+ gos->refunds_length,
+ 0);
GNUNET_free (gos);
}
@@ -429,24 +540,28 @@ TALER_TESTING_cmd_merchant_get_order2 (const char *label,
gos->wired = wired;
gos->refunded = refunded;
gos->http_status = http_status;
- /*if (paid)
+ gos->transfers = NULL;
+ gos->transfers_length = 0;
+ gos->refunds = NULL;
+ gos->refunds_length = 0;
+ if (wired)
{
- for (const char *clabel = transfers[0]; clabel != NULL; ++clabel)
+ for (const char **clabel = transfers; *clabel != NULL; ++clabel)
{
GNUNET_array_append (gos->transfers,
gos->transfers_length,
- clabel);
+ *clabel);
}
}
if (refunded)
{
- for (const char *clabel = refunds[0]; clabel != NULL; ++clabel)
+ for (const char **clabel = refunds; *clabel != NULL; ++clabel)
{
GNUNET_array_append (gos->refunds,
gos->refunds_length,
- clabel);
+ *clabel);
}
- }*/
+ }
{
struct TALER_TESTING_Command cmd = {
.cls = gos,