gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 02/06: redux - test continent selection


From: gnunet
Subject: [taler-anastasis] 02/06: redux - test continent selection
Date: Tue, 10 Nov 2020 13:44:49 +0100

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

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit ef668597504ee251277e11388cd8ff95cbfd747e
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Tue Nov 10 11:16:46 2020 +0100

    redux - test continent selection
---
 src/cli/.gitignore                                 |   1 +
 src/cli/Makefile.am                                |   7 +-
 src/cli/test_anastasis_reducer.conf                | 301 +++++++++++++++++++++
 src/cli/test_anastasis_reducer_initialize_state.sh | 106 ++++++++
 src/cli/test_anastasis_reducer_select_continent.sh | 132 +++++++++
 5 files changed, 545 insertions(+), 2 deletions(-)

diff --git a/src/cli/.gitignore b/src/cli/.gitignore
index 8850532..469eb87 100644
--- a/src/cli/.gitignore
+++ b/src/cli/.gitignore
@@ -1,3 +1,4 @@
 *.log
 anastasis-reducer
 test_reducer_home
+*.trs
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index ea04a09..fb6ef9c 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -10,7 +10,9 @@ if USE_COVERAGE
 endif
 
 check_SCRIPTS = \
-  test_reducer.sh
+  test_reducer.sh \
+  test_anastasis_reducer_initialize_state.sh \
+  test_anastasis_reducer_select_continent.sh
 
 
 AM_TESTS_ENVIRONMENT=export 
ANASTASIS_PREFIX=$${ANASTASIS_PREFIX:-@libdir@};export 
PATH=$${ANASTASIS_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset 
XDG_CONFIG_HOME;
@@ -20,7 +22,8 @@ TESTS = \
 
 EXTRA_DIST = \
   $(check_SCRIPTS) \
-  test_reducer.conf
+  test_reducer.conf \
+  test_anastasis_reducer.conf
 
 anastasis_reducer_SOURCES = \
   anastasis-cli-redux.c
diff --git a/src/cli/test_anastasis_reducer.conf 
b/src/cli/test_anastasis_reducer.conf
new file mode 100644
index 0000000..ca7a6e9
--- /dev/null
+++ b/src/cli/test_anastasis_reducer.conf
@@ -0,0 +1,301 @@
+# This file is in the public domain.
+#
+[PATHS]
+# Persistent data storage for the testcase
+TALER_TEST_HOME = test_anastasis_api_home/
+
+# Persistent data storage
+TALER_DATA_HOME = $TALER_TEST_HOME/.local/share/taler/
+
+# Configuration files
+TALER_CONFIG_HOME = $TALER_TEST_HOME/.config/taler/
+
+# Cached data, no big deal if lost
+TALER_CACHE_HOME = $TALER_TEST_HOME/.cache/taler/
+
+[taler]
+# What currency do we use?
+#currency = EUR
+currency = TESTKUDOS
+#CURRENCY_ROUND_UNIT = EUR:0.01
+#CURRENCY_ROUND_UNIT = TESTKUDOS:0.01
+
+[bank]
+HTTP_PORT = 8082
+#BASE_URL = https://bank.test.taler.net/
+
+##########################################
+# Configuration for Anastasis #
+##########################################
+
+[anastasis]
+PORT = 8086
+
+DB = postgres
+
+# Base URL of anastasis.
+# BASE_URL = http://localhost:8086/
+
+# Where does our payment backend run?  Must match PORT under [merchant]
+PAYMENT_BACKEND_URL = http://localhost:8080/
+
+# Annual fee we charge.
+#ANNUAL_FEE = EUR:4.99
+ANNUAL_FEE = TESTKUDOS:4.99
+#ANNUAL_FEE = EUR:0
+
+# Cost of authentication by question
+#QUESTION_COST = EUR:0
+QUESTION_COST = TESTKUDOS:0
+
+# Upload limit
+UPLOAD_LIMIT_MB = 1
+
+SUPPORTED_METHODS = question
+
+# Insurance
+INSURANCE = TESTKUDOS:1.0
+
+# This specifies which database the postgres backend uses.
+[anastasisdb-postgres]
+CONFIG = postgres:///anastasischeck
+
+##########################################
+# Configuration for the merchant backend #
+##########################################
+
+[test]
+INSTANCES = default tor
+
+[merchant]
+
+# Which port do we run the backend on? (HTTP server)
+PORT = 8080
+
+# How quickly do we want the exchange to send us our money?
+# Used only if the frontend does not specify a value.
+WIRE_TRANSFER_DELAY = 0 s
+
+# Which plugin (backend) do we use for the DB.
+DB = postgres
+
+# Default choice for maximum wire fee.
+DEFAULT_MAX_WIRE_FEE = TESTKUDOS:0.10
+
+# Default choice for maximum deposit fee.
+DEFAULT_MAX_DEPOSIT_FEE = TESTKUDOS:0.10
+
+
+# This specifies which database the postgres backend uses.
+[merchantdb-postgres]
+CONFIG = postgres:///talercheck
+
+# Different instances operated by this merchant:
+[instance-default]
+KEYFILE = ${TALER_CONFIG_HOME}/merchant/default.priv
+NAME = Kudos Inc.
+
+# Account of the MERCHANT
+[merchant-account-merchant]
+# What is the merchant's bank account?
+PAYTO_URI = "payto://x-taler-bank/localhost:8082/3"
+
+# This is the *salted* response we give out for /contract requests.
+# File is generated on first use, no need for merchants to generate
+# the salt!
+WIRE_RESPONSE = ${TALER_CONFIG_HOME}/merchant/account-3.json
+
+# Accept payments to this account in instance-default
+HONOR_default = YES
+
+# Advertise in new contracts of instance-default
+ACTIVE_default = YES
+
+# Sections starting with "exchange-" specify trusted exchanges
+# (by the merchant)
+[merchant-exchange-default]
+#MASTER_KEY = T1VVFQZZARQ1CMF4BN58EE7SKTW5AV2BS18S87ZEGYS4S29J6DNG
+#EXCHANGE_BASE_URL = http://localhost:8081/
+MASTER_KEY = DY95EXAHQ2BKM2WK9YHZHYG1R7PPMMJPY14FNGP662DAKE35AKQG
+EXCHANGE_BASE_URL = https://exchange.test.taler.net/
+#CURRENCY = EUR
+CURRENCY = TESTKUDOS
+
+
+
+# only fixes skips.
+[auditor]
+BASE_URL = http://the.auditor/
+#BASE_URL = https://auditor.test.taler.net/
+#AUDITOR_KEY = DSDASDXAMDAARMNAD53ZA4AFAHA2QADAMAHHASWDAWXN84SDAA11
+# If currency does not match [TALER] section, the auditor
+# will be ignored!
+CURRENCY = TESTKUDOS
+
+# Auditors must be in sections "auditor-", the rest of the section
+# name could be anything.
+[auditor-ezb]
+# Informal name of the auditor. Just for the user.
+NAME = European Central Bank
+
+# URL of the auditor (especially for in the future, when the
+# auditor offers an automated issue reporting system).
+# Not really used today.
+URL = http://taler.ezb.eu/
+
+# This is the important bit: the signing key of the auditor.
+PUBLIC_KEY = 9QXF7XY7E9VPV47B5Z806NDFSX2VJ79SVHHD29QEQ3BG31ANHZ60
+
+# Which currency is this auditor trusted for?
+CURRENCY = TESTKUDOS
+
+
+###################################################
+# Configuration for the exchange for the testcase #
+###################################################
+
+[exchange_keys]
+
+# 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
+
+
+[exchange]
+# How to access our database
+DB = postgres
+
+# HTTP port the exchange listens to
+#PORT = 8081
+
+# Our public key
+MASTER_PUBLIC_KEY = T1VVFQZZARQ1CMF4BN58EE7SKTW5AV2BS18S87ZEGYS4S29J6DNG
+
+# Base URL of the exchange.
+BASE_URL = "http://localhost:8081/";
+#BASE_URL = https://exchange.test.taler.net/
+
+
+##############################################################
+## Added following lines because they were complaint in log ##
+# START
+
+# Where do we store the private keys the exchange needs at
+# runtime? (Denomination and signing keys are then stored
+# in respective subdirectories.)
+KEYDIR = ${TALER_DATA_HOME}/exchange/live-keys/
+
+# Directory where the exchange expects to find revocation
+# certificates (and where taler-exchange-keyup will write them).
+REVOCATION_DIR = ${TALER_DATA_HOME}/exchange/revocations/
+
+# Network configuration for the normal API/service HTTP server
+# serve via tcp socket (on PORT)
+SERVE = tcp
+
+# END
+##############################################################
+
+
+[exchangedb-postgres]
+CONFIG = "postgres:///talercheck"
+
+[auditordb-postgres]
+CONFIG = "postgres:///talercheck"
+
+# Account of the EXCHANGE
+[exchange-account-exchange]
+# What is the exchange's bank account (with the "Taler Bank" demo system)?
+PAYTO_URI = "payto://x-taler-bank/localhost:8082/2"
+
+# This is the response we give out for the /wire request.  It provides
+# wallets with the bank information for transfers to the exchange.
+WIRE_RESPONSE = ${TALER_CONFIG_HOME}/exchange/account-2.json
+
+WIRE_GATEWAY_URL = "http://localhost:8082/2/";
+WIRE_GATEWAY_AUTH_METHOD = NONE
+
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
+
+
+# wire fees
+[fees-x-taler-bank]
+
+# Fees for the foreseeable future...
+# If you see this after 2018, update to match the next 10 years...
+WIRE-FEE-2018 = TESTKUDOS:0.01
+WIRE-FEE-2019 = TESTKUDOS:0.01
+WIRE-FEE-2020 = TESTKUDOS:0.01
+WIRE-FEE-2021 = TESTKUDOS:0.01
+WIRE-FEE-2022 = TESTKUDOS:0.01
+WIRE-FEE-2023 = TESTKUDOS:0.01
+WIRE-FEE-2024 = TESTKUDOS:0.01
+WIRE-FEE-2025 = TESTKUDOS:0.01
+WIRE-FEE-2026 = TESTKUDOS:0.01
+WIRE-FEE-2027 = TESTKUDOS:0.01
+CLOSING-FEE-2018 = TESTKUDOS:0.01
+CLOSING-FEE-2019 = TESTKUDOS:0.01
+CLOSING-FEE-2020 = TESTKUDOS:0.01
+CLOSING-FEE-2021 = TESTKUDOS:0.01
+CLOSING-FEE-2022 = TESTKUDOS:0.01
+CLOSING-FEE-2023 = TESTKUDOS:0.01
+CLOSING-FEE-2024 = TESTKUDOS:0.01
+CLOSING-FEE-2025 = TESTKUDOS:0.01
+CLOSING-FEE-2026 = TESTKUDOS:0.01
+CLOSING-FEE-2027 = TESTKUDOS:0.01
+
+
+[coin_eur_ct_1]
+value = TESTKUDOS:0.01
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.00
+fee_deposit = TESTKUDOS:0.00
+fee_refresh = TESTKUDOS:0.01
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
+
+[coin_eur_ct_10]
+value = TESTKUDOS:0.10
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.01
+fee_deposit = TESTKUDOS:0.01
+fee_refresh = TESTKUDOS:0.03
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
+
+[coin_eur_1]
+value = TESTKUDOS:1
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.01
+fee_deposit = TESTKUDOS:0.01
+fee_refresh = TESTKUDOS:0.03
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
+
+[coin_eur_5]
+value = TESTKUDOS:5
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.01
+fee_deposit = TESTKUDOS:0.01
+fee_refresh = TESTKUDOS:0.03
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
diff --git a/src/cli/test_anastasis_reducer_initialize_state.sh 
b/src/cli/test_anastasis_reducer_initialize_state.sh
new file mode 100755
index 0000000..2a730e8
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_initialize_state.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+set -eu
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+    echo $1
+    exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+    echo $1
+    exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+    for n in `jobs -p`
+    do
+        kill $n 2> /dev/null || true
+    done
+    rm -f $SFILE $TFILE $CONF
+    wait
+}
+
+# Install cleanup handler (except for kill -9)
+CONF=`mktemp test_reducerXXXXXX.conf`
+SFILE=`mktemp test_reducer_stateXXXXXX`
+TFILE=`mktemp test_reducer_stateXXXXXX`
+
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+
+echo -n "Testing for anastasis-httpd"
+anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
+echo " FOUND"
+
+
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB=anastasischeck
+
+# Configuration file will be edited, so we create one
+# from the template.
+cp test_anastasis_reducer.conf $CONF
+
+# reset database
+dropdb $TARGET_DB >/dev/null 2>/dev/null || true
+createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
+
+# Launch services
+echo "Launching anastasis service"
+anastasis-httpd -c $CONF 2> anastasis-httpd.log &
+
+# Wait for anastasis service to be available
+for n in `seq 1 50`
+do
+    echo -n "."
+    sleep 0.1
+    OK=0
+    # anastasis
+    wget http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    OK=1
+    break
+done
+
+if [ 1 != $OK ]
+then
+    exit_skip "Failed to launch anastasis service"
+fi
+
+echo " ANASTASIS SETUP DONE"
+echo " "
+echo " "
+echo " "
+echo "Beginning with actual reducer test"
+
+
+echo " "
+echo "Test initialization of a backup state"
+./anastasis-reducer -b $SFILE
+
+STATE=`jq -r -e .backup_state < $SFILE`
+if test "$STATE" != "CONTINENT_SELECTING"
+then
+    exit_fail "Expected initial state to be CONTINENT_SELECTING, got $STATE"
+fi
+
+
+echo "Test initialization of a recovery state"
+./anastasis-reducer -r $TFILE
+
+STATE=`jq -r -e .recovery_state < $TFILE`
+if test "$STATE" != "CONTINENT_SELECTING"
+then
+    exit_fail "Expected initial state to be CONTINENT_SELECTING, got $STATE"
+fi
+
+exit 0
diff --git a/src/cli/test_anastasis_reducer_select_continent.sh 
b/src/cli/test_anastasis_reducer_select_continent.sh
new file mode 100755
index 0000000..cf0a437
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_select_continent.sh
@@ -0,0 +1,132 @@
+#!/bin/bash
+
+set -eu
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+    echo $1
+    exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+    echo $1
+    exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+    for n in `jobs -p`
+    do
+        kill $n 2> /dev/null || true
+    done
+    rm -f $SFILE $TFILE $CONF
+    wait
+}
+
+# Install cleanup handler (except for kill -9)
+CONF=`mktemp test_reducerXXXXXX.conf`
+SFILE=`mktemp test_reducer_stateXXXXXX`
+TFILE=`mktemp test_reducer_stateXXXXXX`
+
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+
+echo -n "Testing for anastasis-httpd"
+anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
+echo " FOUND"
+
+
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB=anastasischeck
+
+# Configuration file will be edited, so we create one
+# from the template.
+cp test_anastasis_reducer.conf $CONF
+
+# reset database
+dropdb $TARGET_DB >/dev/null 2>/dev/null || true
+createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
+
+# Launch services
+echo "Launching anastasis service"
+anastasis-httpd -c $CONF 2> anastasis-httpd.log &
+
+# Wait for anastasis service to be available
+for n in `seq 1 50`
+do
+    echo -n "."
+    sleep 0.1
+    OK=0
+    # anastasis
+    wget http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || 
continue
+    OK=1
+    break
+done
+
+if [ 1 != $OK ]
+then
+    exit_skip "Failed to launch anastasis service"
+fi
+
+echo " ANASTASIS SETUP DONE"
+echo " "
+echo " "
+echo " "
+echo "Beginning with actual reducer test"
+
+# Test continent selection in a backup state
+echo " "
+echo "Test continent selection in a backup state"
+./anastasis-reducer -b $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+
+STATE=`jq -r -e .backup_state < $TFILE`
+if test "$STATE" != "COUNTRY_SELECTING"
+then
+    exit_fail "Expected new state to be COUNTRY_SELECTING, got $STATE"
+fi
+
+SELECTED_CONTINENT=`jq -r -e .selected_continent < $TFILE`
+if test "$SELECTED_CONTINENT" != "Europe"
+then
+    exit_fail "Expected selected continent to be Europe, got 
$SELECTED_CONTINENT"
+fi
+
+COUNTRIES=`jq -r -e .countries < $TFILE`
+if test "$COUNTRIES" == NULL
+then
+    exit_fail "Expected country array (countries) not to be NULL"
+fi
+
+# Test continent selection in a recovery state
+echo "Test continent selection in a recovery state"
+./anastasis-reducer -r $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+
+STATE=`jq -r -e .recovery_state < $TFILE`
+if test "$STATE" != "COUNTRY_SELECTING"
+then
+    exit_fail "Expected new state to be COUNTRY_SELECTING, got $STATE"
+fi
+
+SELECTED_CONTINENT=`jq -r -e .selected_continent < $TFILE`
+if test "$SELECTED_CONTINENT" != "Europe"
+then
+    exit_fail "Expected selected continent to be Europe, got 
$SELECTED_CONTINENT"
+fi
+
+COUNTRIES=`jq -r -e .countries < $TFILE`
+if test "$COUNTRIES" == NULL
+then
+    exit_fail "Expected country array (countries) not to be NULL"
+fi
+
+exit 0

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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