summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_post_reserves.c
diff options
context:
space:
mode:
authorJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-18 20:27:04 -0400
committerJonathan Buchanan <jonathan.russ.buchanan@gmail.com>2020-06-18 20:27:04 -0400
commit566408fa02acf56bbf6063c6d17d739e491e27f2 (patch)
tree35fe5a5be349e908f4fccd1d036d718f15abd221 /src/testing/testing_api_cmd_post_reserves.c
parent6624576c0cdd81072256d8abbfe6dd1343f956c6 (diff)
downloadmerchant-566408fa02acf56bbf6063c6d17d739e491e27f2.tar.gz
merchant-566408fa02acf56bbf6063c6d17d739e491e27f2.tar.bz2
merchant-566408fa02acf56bbf6063c6d17d739e491e27f2.zip
stricter tests for tips/reserves
Diffstat (limited to 'src/testing/testing_api_cmd_post_reserves.c')
-rw-r--r--src/testing/testing_api_cmd_post_reserves.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/testing/testing_api_cmd_post_reserves.c b/src/testing/testing_api_cmd_post_reserves.c
index 3d62d2f6..f25005c8 100644
--- a/src/testing/testing_api_cmd_post_reserves.c
+++ b/src/testing/testing_api_cmd_post_reserves.c
@@ -180,6 +180,34 @@ post_reserves_run (void *cls,
/**
+ * Run the fake "POST /reserves" CMD.
+ *
+ * @param cls closure.
+ * @param cmd command being run now.
+ * @param is interpreter state.
+ */
+static void
+post_reserves_fake_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct PostReservesState *prs = cls;
+ struct TALER_ReservePrivateKeyP reserve_priv;
+
+ prs->is = is;
+ prs->reserve_pub = GNUNET_new (struct TALER_ReservePublicKeyP);
+
+ GNUNET_CRYPTO_eddsa_key_create (&reserve_priv.eddsa_priv);
+ GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv.eddsa_priv,
+ &prs->reserve_pub->eddsa_pub);
+
+ GNUNET_assert (GNUNET_OK == TALER_string_to_amount ("EUR:100.00",
+ &prs->initial_balance));
+ TALER_TESTING_interpreter_next (prs->is);
+}
+
+
+/**
* Free the state of a "POST /reserves" CMD, and possibly
* cancel a pending operation thereof.
*
@@ -244,3 +272,30 @@ TALER_TESTING_cmd_merchant_post_reserves (const char *label,
return cmd;
}
}
+
+
+/**
+ * This commands does not query the backend at all,
+ * but just makes up a fake reserve.
+ *
+ * @param label command label.
+ * @return the command.
+ */
+struct TALER_TESTING_Command
+TALER_TESTING_cmd_merchant_post_reserves_fake (const char *label)
+{
+ struct PostReservesState *prs;
+
+ prs = GNUNET_new (struct PostReservesState);
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = prs,
+ .label = label,
+ .run = &post_reserves_fake_run,
+ .cleanup = &post_reserves_cleanup,
+ .traits = &post_reserves_traits
+ };
+
+ return cmd;
+ }
+}