summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_get_instance.c
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-22 03:20:54 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-22 03:20:54 -0400
commitda6a10eed07b409718eaf069d0d413a4aac82c0a (patch)
tree297cf795ad364baa7f5d200929a2c7cab18fe23e /src/testing/testing_api_cmd_get_instance.c
parentd4f400ec85410671cf0890d0f7388d9c91a4e414 (diff)
downloadmerchant-da6a10eed07b409718eaf069d0d413a4aac82c0a.tar.gz
merchant-da6a10eed07b409718eaf069d0d413a4aac82c0a.tar.bz2
merchant-da6a10eed07b409718eaf069d0d413a4aac82c0a.zip
deeper checks for GET /private/instances/
Diffstat (limited to 'src/testing/testing_api_cmd_get_instance.c')
-rw-r--r--src/testing/testing_api_cmd_get_instance.c143
1 files changed, 140 insertions, 3 deletions
diff --git a/src/testing/testing_api_cmd_get_instance.c b/src/testing/testing_api_cmd_get_instance.c
index 5dc1d3d0..a5896659 100644
--- a/src/testing/testing_api_cmd_get_instance.c
+++ b/src/testing/testing_api_cmd_get_instance.c
@@ -79,8 +79,13 @@ get_instance_cb (void *cls,
const struct TALER_MERCHANT_Account accounts[],
const struct TALER_MERCHANT_InstanceDetails *details)
{
- /* FIXME, deeper checks should be implemented here. */
+ /* FIXME, deeper checks should be implemented here (for accounts). */
struct GetInstanceState *gis = cls;
+ const struct TALER_TESTING_Command *instance_cmd;
+
+ instance_cmd = TALER_TESTING_interpreter_lookup_command (
+ gis->is,
+ gis->instance_reference);
gis->igh = NULL;
if (gis->http_status != hr->http_status)
@@ -96,8 +101,140 @@ get_instance_cb (void *cls,
switch (hr->http_status)
{
case MHD_HTTP_OK:
- // FIXME: use gis->instance_reference here to
- // check if the data returned matches that from the POST / PATCH
+ {
+ const char *name;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_string (instance_cmd,
+ 0,
+ &name))
+ TALER_TESTING_interpreter_fail (gis->is);
+ if (0 != strcmp (details->name,
+ name))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance name does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ }
+ {
+ const struct json_t *address;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_merchant_address (instance_cmd,
+ 0,
+ &address))
+ TALER_TESTING_interpreter_fail (gis->is);
+ if (1 != json_equal (details->address,
+ address))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance address does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ }
+ {
+ const struct json_t *jurisdiction;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_merchant_jurisdiction (instance_cmd,
+ 0,
+ &jurisdiction))
+ TALER_TESTING_interpreter_fail (gis->is);
+ if (1 != json_equal (details->jurisdiction,
+ jurisdiction))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance jurisdiction does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ }
+ {
+ const struct TALER_Amount *default_max_wire_fee;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_amount_obj (instance_cmd,
+ 0,
+ &default_max_wire_fee))
+ TALER_TESTING_interpreter_fail (gis->is);
+ if ((GNUNET_OK != TALER_amount_cmp_currency (
+ details->default_max_wire_fee,
+ default_max_wire_fee)) ||
+ (0 != TALER_amount_cmp (details->default_max_wire_fee,
+ default_max_wire_fee)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance default max wire fee does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ }
+ {
+ const uint32_t *default_wire_fee_amortization;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_uint32 (instance_cmd,
+ 0,
+ &default_wire_fee_amortization))
+ TALER_TESTING_interpreter_fail (gis->is);
+ if (details->default_wire_fee_amortization !=
+ *default_wire_fee_amortization)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance default wire fee amortization does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ }
+ {
+ const struct TALER_Amount *default_max_deposit_fee;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_amount_obj (instance_cmd,
+ 0,
+ &default_max_deposit_fee))
+ TALER_TESTING_interpreter_fail (gis->is);
+ if ((GNUNET_OK != TALER_amount_cmp_currency (
+ details->default_max_deposit_fee,
+ default_max_deposit_fee)) ||
+ (0 != TALER_amount_cmp (details->default_max_deposit_fee,
+ default_max_deposit_fee)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance default max deposit fee does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ }
+ {
+ const struct GNUNET_TIME_Relative *default_wire_transfer_delay;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_relative_time (instance_cmd,
+ 0,
+ &default_wire_transfer_delay))
+ TALER_TESTING_interpreter_fail (gis->is);
+ if (details->default_wire_transfer_delay.rel_value_us !=
+ default_wire_transfer_delay->rel_value_us)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance default wire transfer delay does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ }
+ {
+ const struct GNUNET_TIME_Relative *default_pay_delay;
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_relative_time (instance_cmd,
+ 1,
+ &default_pay_delay))
+ TALER_TESTING_interpreter_fail (gis->is);
+ if (details->default_pay_delay.rel_value_us !=
+ default_pay_delay->rel_value_us)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Instance default pay delay does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ }
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,