summaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-06-25 13:59:47 +0200
committerChristian Grothoff <grothoff@gnunet.org>2023-06-25 13:59:47 +0200
commit75733ee00efc6d5342ed8b4fccd637efaebdce06 (patch)
tree68d2c58ed44001ad4ae297ebf0795c54ae56a2dc /src/testing
parente2f44ea7b3b745ae349a69ac45b3217dc44dd43a (diff)
downloadexchange-75733ee00efc6d5342ed8b4fccd637efaebdce06.tar.gz
exchange-75733ee00efc6d5342ed8b4fccd637efaebdce06.tar.bz2
exchange-75733ee00efc6d5342ed8b4fccd637efaebdce06.zip
more work on atomizing exchange API: deposit
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_exchange_api.conf2
-rw-r--r--src/testing/test_exchange_api_home/taler/auditor/offline-keys/auditor.priv1
-rw-r--r--src/testing/testing_api_cmd_batch_deposit.c26
-rw-r--r--src/testing/testing_api_cmd_deposit.c34
-rw-r--r--src/testing/testing_api_cmd_get_exchange.c3
-rw-r--r--src/testing/testing_api_traits.c28
6 files changed, 69 insertions, 25 deletions
diff --git a/src/testing/test_exchange_api.conf b/src/testing/test_exchange_api.conf
index 9ed12412e..b7f8c5c60 100644
--- a/src/testing/test_exchange_api.conf
+++ b/src/testing/test_exchange_api.conf
@@ -11,7 +11,7 @@ CURRENCY_ROUND_UNIT = EUR:0.01
[auditor]
BASE_URL = "http://localhost:8083/"
PORT = 8083
-PUBLIC_KEY = SA7JVMCW3MMN7SYAWJ9AB0BGJDX6MP3PNN2JWQ3T8233MDSQC7Z0
+PUBLIC_KEY = T0XJ9QZ59YDN7QG3RE40SB2HY7W0ASR1EKF4WZDGZ1G159RSQC80
TINY_AMOUNT = EUR:0.01
[auditordb-postgres]
diff --git a/src/testing/test_exchange_api_home/taler/auditor/offline-keys/auditor.priv b/src/testing/test_exchange_api_home/taler/auditor/offline-keys/auditor.priv
new file mode 100644
index 000000000..7e712e483
--- /dev/null
+++ b/src/testing/test_exchange_api_home/taler/auditor/offline-keys/auditor.priv
@@ -0,0 +1 @@
+G,U{~#r-H  \ No newline at end of file
diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c
index 6a05071af..0a4fbd251 100644
--- a/src/testing/testing_api_cmd_batch_deposit.c
+++ b/src/testing/testing_api_cmd_batch_deposit.c
@@ -251,12 +251,15 @@ batch_deposit_run (void *cls,
&wire_salt),
GNUNET_JSON_spec_end ()
};
- struct TALER_EXCHANGE_Handle *exchange
- = TALER_TESTING_get_exchange (is);
+ const char *exchange_url
+ = TALER_TESTING_get_exchange_url (is);
(void) cmd;
- if (NULL == exchange)
+ if (NULL == exchange_url)
+ {
+ GNUNET_break (0);
return;
+ }
memset (cdds,
0,
sizeof (cdds));
@@ -383,13 +386,16 @@ batch_deposit_run (void *cls,
.refund_deadline = ds->refund_deadline
};
- ds->dh = TALER_EXCHANGE_batch_deposit (exchange,
- &dcd,
- ds->num_coins,
- cdds,
- &batch_deposit_cb,
- ds,
- &ec);
+ ds->dh = TALER_EXCHANGE_batch_deposit (
+ TALER_TESTING_interpreter_get_context (is),
+ exchange_url,
+ TALER_TESTING_get_keys (is),
+ &dcd,
+ ds->num_coins,
+ cdds,
+ &batch_deposit_cb,
+ ds,
+ &ec);
}
if (NULL == ds->dh)
{
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c
index 3d5c00abd..f2a3a2698 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -98,7 +98,7 @@ struct DepositState
/**
* Deposit handle while operation is running.
*/
- struct TALER_EXCHANGE_DepositHandle *dh;
+ struct TALER_EXCHANGE_BatchDepositHandle *dh;
/**
* Timestamp of the /deposit operation in the wallet (contract signing time).
@@ -215,7 +215,7 @@ do_retry (void *cls)
*/
static void
deposit_cb (void *cls,
- const struct TALER_EXCHANGE_DepositResult *dr)
+ const struct TALER_EXCHANGE_BatchDepositResult *dr)
{
struct DepositState *ds = cls;
@@ -254,10 +254,11 @@ deposit_cb (void *cls,
}
if (MHD_HTTP_OK == dr->hr.http_status)
{
+ GNUNET_assert (1 == dr->details.ok.num_signatures);
ds->deposit_succeeded = GNUNET_YES;
ds->exchange_timestamp = dr->details.ok.deposit_timestamp;
ds->exchange_pub = *dr->details.ok.exchange_pub;
- ds->exchange_sig = *dr->details.ok.exchange_sig;
+ ds->exchange_sig = dr->details.ok.exchange_sigs[0];
}
TALER_TESTING_interpreter_next (ds->is);
}
@@ -296,12 +297,15 @@ deposit_run (void *cls,
&wire_salt),
GNUNET_JSON_spec_end ()
};
- struct TALER_EXCHANGE_Handle *exchange
- = TALER_TESTING_get_exchange (is);
+ const char *exchange_url
+ = TALER_TESTING_get_exchange_url (is);
(void) cmd;
- if (NULL == exchange)
+ if (NULL == exchange_url)
+ {
+ GNUNET_break (0);
return;
+ }
ds->is = is;
if (NULL != ds->deposit_reference)
{
@@ -469,12 +473,16 @@ deposit_run (void *cls,
.refund_deadline = ds->refund_deadline
};
- ds->dh = TALER_EXCHANGE_deposit (exchange,
- &dcd,
- &cdd,
- &deposit_cb,
- ds,
- &ec);
+ ds->dh = TALER_EXCHANGE_batch_deposit (
+ TALER_TESTING_interpreter_get_context (is),
+ exchange_url,
+ TALER_TESTING_get_keys (is),
+ &dcd,
+ 1,
+ &cdd,
+ &deposit_cb,
+ ds,
+ &ec);
}
if (NULL == ds->dh)
{
@@ -505,7 +513,7 @@ deposit_cleanup (void *cls,
{
TALER_TESTING_command_incomplete (ds->is,
cmd->label);
- TALER_EXCHANGE_deposit_cancel (ds->dh);
+ TALER_EXCHANGE_batch_deposit_cancel (ds->dh);
ds->dh = NULL;
}
if (NULL != ds->retry_task)
diff --git a/src/testing/testing_api_cmd_get_exchange.c b/src/testing/testing_api_cmd_get_exchange.c
index 2fc8ba77e..2822616c0 100644
--- a/src/testing/testing_api_cmd_get_exchange.c
+++ b/src/testing/testing_api_cmd_get_exchange.c
@@ -189,7 +189,7 @@ get_exchange_traits (void *cls,
{
struct GetExchangeState *ges = cls;
unsigned int off = (NULL == ges->master_priv_file) ? 1 : 0;
- const struct TALER_EXCHANGE_Keys *keys
+ struct TALER_EXCHANGE_Keys *keys
= TALER_EXCHANGE_get_keys (ges->exchange);
if (NULL != keys)
@@ -198,6 +198,7 @@ get_exchange_traits (void *cls,
TALER_TESTING_make_trait_master_priv (&ges->master_priv),
TALER_TESTING_make_trait_master_pub (&keys->master_pub),
TALER_TESTING_make_trait_exchange (ges->exchange),
+ TALER_TESTING_make_trait_keys (keys),
TALER_TESTING_make_trait_exchange_url (ges->exchange_url),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_traits.c b/src/testing/testing_api_traits.c
index 27eef5a5b..d00a8d8ca 100644
--- a/src/testing/testing_api_traits.c
+++ b/src/testing/testing_api_traits.c
@@ -129,4 +129,32 @@ TALER_TESTING_get_exchange_url (struct TALER_TESTING_Interpreter *is)
}
+struct TALER_EXCHANGE_Keys *
+TALER_TESTING_get_keys (
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct TALER_EXCHANGE_Keys *keys;
+ const struct TALER_TESTING_Command *exchange_cmd;
+
+ exchange_cmd
+ = TALER_TESTING_interpreter_get_command (is,
+ "exchange");
+ if (NULL == exchange_cmd)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return NULL;
+ }
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_keys (exchange_cmd,
+ &keys))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return NULL;
+ }
+ return keys;
+}
+
+
/* end of testing_api_traits.c */