gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: add -i option to taler-exchange-


From: gnunet
Subject: [taler-exchange] branch master updated: add -i option to taler-exchange-keycheck
Date: Wed, 18 Mar 2020 13:58:44 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new bab24a45 add -i option to taler-exchange-keycheck
bab24a45 is described below

commit bab24a451a2c582951e636c388bd31e47abddecb
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Mar 18 13:58:40 2020 +0100

    add -i option to taler-exchange-keycheck
---
 src/exchange-tools/Makefile.am                     |  18 ++-
 src/exchange-tools/taler-exchange-keycheck.c       |  35 ++++++
 src/exchange-tools/test_taler_exchange_httpd.conf  | 130 +++++++++++++++++++++
 .../.config/taler/test.json                        |   8 ++
 .../share/taler/exchange/offline-keys/master.priv  |   1 +
 src/exchange-tools/test_taler_exchange_keyup.sh    |  85 ++++++++++++++
 6 files changed, 275 insertions(+), 2 deletions(-)

diff --git a/src/exchange-tools/Makefile.am b/src/exchange-tools/Makefile.am
index 9509e20d..5103e3ae 100644
--- a/src/exchange-tools/Makefile.am
+++ b/src/exchange-tools/Makefile.am
@@ -67,6 +67,20 @@ taler_exchange_dbinit_CPPFLAGS = \
   $(POSTGRESQL_CPPFLAGS)
 
 
+# Testcases
+
+AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export 
PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
+
+check_SCRIPTS = \
+  test_taler_exchange_keyup.sh
+
+TESTS = \
+  $(check_SCRIPTS)
+
+# Distribution
+
 EXTRA_DIST = \
-  $(pkgcfg_DATA) \
-  key-helper.c
+  
test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv
 \
+  test_taler_exchange_httpd.conf \
+  $(check_SCRIPTS) \
+  $(pkgcfg_DATA)
diff --git a/src/exchange-tools/taler-exchange-keycheck.c 
b/src/exchange-tools/taler-exchange-keycheck.c
index 7c078580..6b6ce9eb 100644
--- a/src/exchange-tools/taler-exchange-keycheck.c
+++ b/src/exchange-tools/taler-exchange-keycheck.c
@@ -41,6 +41,12 @@ static const struct GNUNET_CONFIGURATION_Handle *kcfg;
  */
 static int global_ret;
 
+/**
+ * Option -i used to print full denomination key hashes for
+ * denominations of certain amounts.
+ */
+static struct TALER_Amount print_dk_amount;
+
 
 /**
  * Function called on each signing key.
@@ -136,6 +142,7 @@ denomkeys_iter (void *cls,
                 TALER_EXCHANGEDB_DenominationKey *dki)
 {
   struct GNUNET_HashCode hc;
+  struct TALER_Amount value;
 
   (void) cls;
   if (ntohl (dki->issue.properties.purpose.size) !=
@@ -187,6 +194,29 @@ denomkeys_iter (void *cls,
               "Denomination key `%s' (%s) is valid\n",
               alias,
               GNUNET_h2s (&hc));
+  TALER_amount_ntoh (&value,
+                     &dki->issue.properties.value);
+  if ( (GNUNET_OK ==
+        TALER_amount_cmp_currency (&print_dk_amount,
+                                   &value)) &&
+       (0 ==
+        TALER_amount_cmp (&print_dk_amount,
+                          &value)) )
+  {
+    char *dh;
+    struct GNUNET_TIME_Absolute start;
+
+    start = GNUNET_TIME_absolute_ntoh (dki->issue.properties.start);
+    dh = GNUNET_STRINGS_data_to_string_alloc 
(&dki->issue.properties.denom_hash,
+                                              sizeof (struct GNUNET_HashCode));
+    /* output start time first for easy numeric sorting, then
+       the denomination hash, and finally the human-readable start time */
+    printf ("%020llu %s %s\n",
+            (unsigned long long) start.abs_value_us,
+            dh,
+            GNUNET_STRINGS_absolute_time_to_string (start));
+    GNUNET_free (dh);
+  }
   return GNUNET_OK;
 }
 
@@ -275,6 +305,11 @@ main (int argc,
       char *const *argv)
 {
   const struct GNUNET_GETOPT_CommandLineOption options[] = {
+    TALER_getopt_get_amount ('i',
+                             "denomination-info-hash",
+                             "AMOUNT",
+                             "print full denomination hashes of all 
denominations with the given AMOUNT value",
+                             &print_dk_amount),
     GNUNET_GETOPT_OPTION_END
   };
 
diff --git a/src/exchange-tools/test_taler_exchange_httpd.conf 
b/src/exchange-tools/test_taler_exchange_httpd.conf
new file mode 100644
index 00000000..63b59f90
--- /dev/null
+++ b/src/exchange-tools/test_taler_exchange_httpd.conf
@@ -0,0 +1,130 @@
+[PATHS]
+# Persistant data storage for the testcase
+TALER_TEST_HOME = test_taler_exchange_httpd_home/
+
+[taler]
+# Currency supported by the exchange (can only be one)
+CURRENCY = EUR
+CURRENCY_ROUND_UNIT = EUR:0.01
+
+[exchange]
+
+# Directory with our terms of service.
+TERMS_DIR = ../../contrib/tos
+
+# Etag / filename for the terms of service.
+TERMS_ETAG = 0
+
+
+# Directory with our privacy policy.
+PRIVACY_DIR = ../../contrib/pp
+
+# Etag / filename for the privacy policy.
+PRIVACY_ETAG = 0
+
+# MAX_REQUESTS = 2
+# how long is one signkey valid?
+SIGNKEY_DURATION = 4 weeks
+
+# how long are the signatures with the signkey valid?
+LEGAL_DURATION = 2 years
+
+# how long do we generate denomination and signing keys
+# ahead of time?
+LOOKAHEAD_SIGN = 32 weeks 1 day
+
+# how long do we provide to clients denomination and signing keys
+# ahead of time?
+LOOKAHEAD_PROVIDE = 4 weeks 1 day
+
+# HTTP port the exchange listens to
+PORT = 8081
+
+# Master public key used to sign the exchange's various keys
+MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
+
+# How to access our database
+DB = postgres
+
+
+[exchangedb]
+# After how long do we close idle reserves?  The exchange
+# and the auditor must agree on this value.  We currently
+# expect it to be globally defined for the whole system,
+# as there is no way for wallets to query this value.  Thus,
+# it is only configurable for testing, and should be treated
+# as constant in production.
+IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
+
+
+[exchangedb-postgres]
+CONFIG = "postgres:///talercheck"
+
+[exchange-account-1]
+PAYTO_URI = "payto://x-taler-bank/localhost:8082/3"
+WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
+TALER_BANK_AUTH_METHOD = NONE
+
+
+# Wire fees are specified by wire method
+[fees-x-taler-bank]
+# Fees for the forseeable future...
+# If you see this after 2018, update to match the next 10 years...
+WIRE-FEE-2018 = EUR:0.01
+WIRE-FEE-2019 = EUR:0.01
+WIRE-FEE-2020 = EUR:0.01
+WIRE-FEE-2021 = EUR:0.01
+WIRE-FEE-2022 = EUR:0.01
+WIRE-FEE-2023 = EUR:0.01
+WIRE-FEE-2024 = EUR:0.01
+WIRE-FEE-2025 = EUR:0.01
+WIRE-FEE-2026 = EUR:0.01
+WIRE-FEE-2027 = EUR:0.01
+
+CLOSING-FEE-2018 = EUR:0.01
+CLOSING-FEE-2019 = EUR:0.01
+CLOSING-FEE-2020 = EUR:0.01
+CLOSING-FEE-2021 = EUR:0.01
+CLOSING-FEE-2022 = EUR:0.01
+CLOSING-FEE-2023 = EUR:0.01
+CLOSING-FEE-2024 = EUR:0.01
+CLOSING-FEE-2025 = EUR:0.01
+CLOSING-FEE-2026 = EUR:0.01
+CLOSING-FEE-2027 = EUR:0.01
+
+
+# Coins for the tests.
+[coin_eur_ct_1]
+value = EUR:0.01
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = EUR:0.00
+fee_deposit = EUR:0.00
+fee_refresh = EUR:0.01
+fee_refund = EUR:0.01
+rsa_keysize = 1024
+
+[coin_eur_ct_10]
+value = EUR:0.10
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = EUR:0.01
+fee_deposit = EUR:0.01
+fee_refresh = EUR:0.03
+fee_refund = EUR:0.01
+rsa_keysize = 1024
+
+[coin_eur_1]
+value = EUR:1
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = EUR:0.01
+fee_deposit = EUR:0.01
+fee_refresh = EUR:0.03
+fee_refund = EUR:0.01
+rsa_keysize = 1024
diff --git 
a/src/exchange-tools/test_taler_exchange_httpd_home/.config/taler/test.json 
b/src/exchange-tools/test_taler_exchange_httpd_home/.config/taler/test.json
new file mode 100644
index 00000000..eca39424
--- /dev/null
+++ b/src/exchange-tools/test_taler_exchange_httpd_home/.config/taler/test.json
@@ -0,0 +1,8 @@
+{
+  "salt": 
"AZPRFVJ58NM6M7J5CZQPJAH3EW5DYM52AEZ9Y1C1ER3W94QV8D8TQKF6CK8MYQRA9QMSKDQTGZ306ZS9GQ0M6R01CJ20KPP49WFDZK8",
+  "name": "The exchange",
+  "account_number": 3,
+  "bank_url": "http://localhost:8082/";,
+  "type": "test",
+  "sig": 
"RPQXP9S4P8PQP7HEZQNRSZCT0ATNEP8GW0P5TPM34V5RX86FCD670V44R9NETSYDDKB8SZV7TKY9PAJYTY51D3VDWY9XXQ5BPFRXR28"
+}
diff --git 
a/src/exchange-tools/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv
 
b/src/exchange-tools/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv
new file mode 100644
index 00000000..39492693
--- /dev/null
+++ 
b/src/exchange-tools/test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv
@@ -0,0 +1 @@
+p�^�-�33��XX�!�\0q�����mU�_��
\ No newline at end of file
diff --git a/src/exchange-tools/test_taler_exchange_keyup.sh 
b/src/exchange-tools/test_taler_exchange_keyup.sh
new file mode 100755
index 00000000..4cf0ea1f
--- /dev/null
+++ b/src/exchange-tools/test_taler_exchange_keyup.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+#
+# This file is part of TALER
+# Copyright (C) 2015-2020 Taler Systems SA
+#
+#  TALER is free software; you can redistribute it and/or modify it under the
+#  terms of the GNU Affero General Public License as published by the Free 
Software
+#  Foundation; either version 3, or (at your option) any later version.
+#
+#  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+#  A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more 
details.
+#
+#  You should have received a copy of the GNU Affero General Public License 
along with
+#  TALER; see the file COPYING.  If not, If not, see 
<http://www.gnu.org/licenses/>
+#
+#
+# This script uses 'curl' to POST various ill-formed requests to the
+# taler-exchange-httpd.  Basically, the goal is to make sure that the
+# HTTP server survives (and produces the 'correct' error code).
+#
+#
+# Clear environment from variables that override config.
+unset XDG_DATA_HOME
+unset XDG_CONFIG_HOME
+#
+
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+    echo $1
+    exit 77
+}
+
+# test required commands exist
+echo "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+
+echo -n "Launching exchange ..."
+PREFIX=
+# Uncomment this line to run with valgrind...
+# PREFIX="valgrind --leak-check=yes --track-fds=yes --error-exitcode=1 
--log-file=valgrind.%p"
+
+# Setup database
+taler-exchange-dbinit -c test_taler_exchange_httpd.conf &> /dev/null
+# Setup keys.
+taler-exchange-keyup -c test_taler_exchange_httpd.conf || exit 1
+# Setup wire accounts.
+taler-exchange-wire -c test_taler_exchange_httpd.conf > /dev/null || exit 1
+# Run Exchange HTTPD (in background)
+$PREFIX taler-exchange-httpd -c test_taler_exchange_httpd.conf 2> 
test-exchange.log &
+
+# Give HTTP time to start
+
+for n in `seq 1 100`
+do
+    echo -n "."
+    sleep 0.1
+    OK=1
+    wget http://localhost:8081/ -o /dev/null -O /dev/null >/dev/null && break
+    OK=0
+done
+if [ 1 != $OK ]
+then
+    echo "Failed to launch exchange"
+    kill -TERM $!
+    wait $!
+    echo Process status: $?
+    exit 77
+fi
+echo " DONE"
+
+# Finally run test...
+echo -n "Running tests ..."
+
+# Revoke active denomination key
+
+
+
+echo " DONE"
+# $! is the last backgrounded process, hence the exchange
+kill -TERM $!
+wait $!
+# Return status code from exchange for this script
+exit $?

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]