aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_purse_create_deposit.c
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-04-06 13:54:08 +0200
committerChristian Grothoff <grothoff@gnunet.org>2022-04-06 13:54:08 +0200
commit89431a41b795cfbd14d6ce08dc33272e4a9ab9e6 (patch)
tree76fa0ff047d923e9a73c68201ac4d40ab8819c44 /src/testing/testing_api_cmd_purse_create_deposit.c
parent22cfc59d904c02b752547459d599e2e1cdce75a9 (diff)
downloadexchange-89431a41b795cfbd14d6ce08dc33272e4a9ab9e6.tar.xz
-complete va coin parser of purse_create_deposit CMD
Diffstat (limited to 'src/testing/testing_api_cmd_purse_create_deposit.c')
-rw-r--r--src/testing/testing_api_cmd_purse_create_deposit.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/testing/testing_api_cmd_purse_create_deposit.c b/src/testing/testing_api_cmd_purse_create_deposit.c
index 8aeab744f..af7ed3f5d 100644
--- a/src/testing/testing_api_cmd_purse_create_deposit.c
+++ b/src/testing/testing_api_cmd_purse_create_deposit.c
@@ -36,7 +36,7 @@ struct Coin
/**
* Reference to the respective command.
*/
- const char *command_ref;
+ char *command_ref;
/**
* index of the specific coin in the traits of @e command_ref.
@@ -308,6 +308,8 @@ deposit_cleanup (void *cls,
TALER_EXCHANGE_purse_create_with_deposit_cancel (ds->dh);
ds->dh = NULL;
}
+ for (unsigned int i = 0; i<ds->num_coin_references; i++)
+ GNUNET_free (ds->coin_references[i].command_ref);
json_decref (ds->contract_terms);
GNUNET_free (ds->coin_references);
GNUNET_free (ds);
@@ -376,7 +378,38 @@ TALER_TESTING_cmd_purse_create_with_deposit (
label);
GNUNET_assert (0);
}
- // FIXME: parse varargs!
+ {
+ va_list ap;
+ unsigned int i;
+ const char *ref;
+ const char *val;
+
+ va_start (ap, purse_expiration);
+ while (NULL != (va_arg (ap, const char *)))
+ ds->num_coin_references++;
+ va_end (ap);
+ GNUNET_assert (0 == (ds->num_coin_references % 2));
+ ds->num_coin_references /= 2;
+ ds->coin_references = GNUNET_new_array (ds->num_coin_references,
+ struct Coin);
+ i = 0;
+ va_start (ap, purse_expiration);
+ while (NULL != (ref = va_arg (ap, const char *)))
+ {
+ struct Coin *c = &ds->coin_references[i++];
+
+ GNUNET_assert (NULL != (val = va_arg (ap, const char *)));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_parse_coin_reference (
+ ref,
+ &c->command_ref,
+ &c->coin_index));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (val,
+ &c->deposit_with_fee));
+ }
+ va_end (ap);
+ }
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (target_amount,
&ds->target_amount));