diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-02-27 14:17:49 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-27 14:17:49 +0100 |
commit | d79df04ba7ea596c308d8d0803d6b5948d7e1252 (patch) | |
tree | ae63ee7e3ac491adc1658dce105eda7ec3430fd1 /src | |
parent | 393d657198c650f2b256457a4b26b8431806b4d2 (diff) | |
download | anastasis-d79df04ba7ea596c308d8d0803d6b5948d7e1252.tar.gz anastasis-d79df04ba7ea596c308d8d0803d6b5948d7e1252.tar.bz2 anastasis-d79df04ba7ea596c308d8d0803d6b5948d7e1252.zip |
-fix tests, clean up code
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/anastasis-httpd_truth_upload.c | 129 | ||||
-rwxr-xr-x | src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh | 10 | ||||
-rwxr-xr-x | src/cli/test_anastasis_reducer_enter_secret.sh | 1 | ||||
-rwxr-xr-x | src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh | 1 | ||||
-rw-r--r-- | src/cli/test_reducer_free.conf | 8 | ||||
-rw-r--r-- | src/reducer/anastasis_api_backup_redux.c | 3 |
6 files changed, 72 insertions, 80 deletions
diff --git a/src/backend/anastasis-httpd_truth_upload.c b/src/backend/anastasis-httpd_truth_upload.c index ddf645c..fd14663 100644 --- a/src/backend/anastasis-httpd_truth_upload.c +++ b/src/backend/anastasis-httpd_truth_upload.c @@ -526,7 +526,8 @@ AH_handler_truth_post ( const char *type; enum GNUNET_DB_QueryStatus qs; uint32_t storage_years; - struct GNUNET_TIME_Timestamp paid_until; + struct GNUNET_TIME_Timestamp paid_until + = GNUNET_TIME_UNIT_ZERO_TS; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("key_share_data", &key_share_data), @@ -695,79 +696,71 @@ AH_handler_truth_post ( if (0 == storage_years) storage_years = 1; + if (! TALER_amount_is_zero (&AH_truth_upload_fee)) { - struct TALER_Amount zero_amount; - - TALER_amount_set_zero (AH_currency, - &zero_amount); - if (0 != TALER_amount_cmp (&AH_truth_upload_fee, - &zero_amount)) + struct GNUNET_TIME_Timestamp desired_until; + enum GNUNET_DB_QueryStatus qs; + + desired_until + = GNUNET_TIME_relative_to_timestamp ( + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, + storage_years)); + qs = db->check_truth_upload_paid (db->cls, + truth_uuid, + &paid_until); + if (qs < 0) + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + NULL); + if ( (0 == qs) || + (GNUNET_TIME_timestamp_cmp (paid_until, + <, + desired_until) ) ) { - struct GNUNET_TIME_Timestamp desired_until; - enum GNUNET_DB_QueryStatus qs; - - desired_until - = GNUNET_TIME_relative_to_timestamp ( - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, - storage_years)); - qs = db->check_truth_upload_paid (db->cls, - truth_uuid, - &paid_until); - if (qs < 0) + struct GNUNET_TIME_Relative rem; + + if (GNUNET_TIME_absolute_is_past (paid_until.abs_time)) + paid_until = GNUNET_TIME_timestamp_get (); + rem = GNUNET_TIME_absolute_get_difference (paid_until.abs_time, + desired_until.abs_time); + tuc->years_to_pay = rem.rel_value_us + / GNUNET_TIME_UNIT_YEARS.rel_value_us; + if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) + tuc->years_to_pay++; + if (0 > + TALER_amount_multiply (&tuc->upload_fee, + &AH_truth_upload_fee, + tuc->years_to_pay)) + { + GNUNET_break_op (0); return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - NULL); - if ( (0 == qs) || - (GNUNET_TIME_timestamp_cmp (paid_until, - <, - desired_until) ) ) + MHD_HTTP_BAD_REQUEST, + TALER_EC_GENERIC_PARAMETER_MALFORMED, + "storage_duration_years"); + } + if (! TALER_amount_is_zero (&tuc->upload_fee)) { - struct GNUNET_TIME_Relative rem; - - if (GNUNET_TIME_absolute_is_past (paid_until.abs_time)) - paid_until = GNUNET_TIME_timestamp_get (); - rem = GNUNET_TIME_absolute_get_difference (paid_until.abs_time, - desired_until.abs_time); - tuc->years_to_pay = rem.rel_value_us - / GNUNET_TIME_UNIT_YEARS.rel_value_us; - if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) - tuc->years_to_pay++; - if (0 > - TALER_amount_multiply (&tuc->upload_fee, - &AH_truth_upload_fee, - tuc->years_to_pay)) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - "storage_duration_years"); - } - if ( (0 != tuc->upload_fee.fraction) || - (0 != tuc->upload_fee.value) ) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Truth upload payment required (%d)!\n", - qs); - return begin_payment (tuc); - } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Truth upload payment required (%d)!\n", + qs); + return begin_payment (tuc); } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "TRUTH paid until %s (%d)!\n", - GNUNET_TIME_relative2s ( - GNUNET_TIME_absolute_get_remaining ( - paid_until.abs_time), - GNUNET_YES), - qs); - } - else - { - paid_until - = GNUNET_TIME_relative_to_timestamp ( - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, - ANASTASIS_MAX_YEARS_STORAGE)); } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "TRUTH paid until %s (%d)!\n", + GNUNET_TIME_relative2s ( + GNUNET_TIME_absolute_get_remaining ( + paid_until.abs_time), + GNUNET_YES), + qs); + } + else + { + paid_until + = GNUNET_TIME_relative_to_timestamp ( + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, + ANASTASIS_MAX_YEARS_STORAGE)); } diff --git a/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh b/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh index b8662e8..8a04b0a 100755 --- a/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh +++ b/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh @@ -126,16 +126,6 @@ fi echo "OK" -echo -n "Test user attributes collection in a recovery state ..." -anastasis-reducer -a \ - '{"identity_attributes": { - "full_name": "Max Musterman", - "sq_number": "4", - "birthdate": "2000-01-01"}}' \ - enter_user_attributes resources/02-recovery.json $TFILE 2> /dev/null && exit_fail "Expected recovery to fail due to lacking policy data" - -echo "OK" - rm -f $TFILE exit 0 diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh b/src/cli/test_anastasis_reducer_enter_secret.sh index 8fb8b60..fd244e2 100755 --- a/src/cli/test_anastasis_reducer_enter_secret.sh +++ b/src/cli/test_anastasis_reducer_enter_secret.sh @@ -152,6 +152,7 @@ echo -n "Launching taler services ..." taler-bank-manage-testing $CONF postgres:///$TALER_DB serve > taler-bank.log 2> taler-bank.err & taler-exchange-secmod-eddsa -c $CONF 2> taler-exchange-secmod-eddsa.log & taler-exchange-secmod-rsa -c $CONF 2> taler-exchange-secmod-rsa.log & +taler-exchange-secmod-cs -c $CONF 2> taler-exchange-secmod-cs.log & taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log & taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log & taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log & diff --git a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh index 43c6a4e..41099bc 100755 --- a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh +++ b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh @@ -149,6 +149,7 @@ echo -n "Launching taler services ..." taler-bank-manage-testing $CONF postgres:///$TALER_DB serve > taler-bank.log 2> taler-bank.err & taler-exchange-secmod-eddsa -c $CONF 2> taler-exchange-secmod-eddsa.log & taler-exchange-secmod-rsa -c $CONF 2> taler-exchange-secmod-rsa.log & +taler-exchange-secmod-cs -c $CONF 2> taler-exchange-secmod-cs.log & taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log & taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log & taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log & diff --git a/src/cli/test_reducer_free.conf b/src/cli/test_reducer_free.conf index be4fbb6..1c7da88 100644 --- a/src/cli/test_reducer_free.conf +++ b/src/cli/test_reducer_free.conf @@ -123,6 +123,7 @@ fee_deposit = TESTKUDOS:0.01 fee_refresh = TESTKUDOS:0.01 fee_refund = TESTKUDOS:0.01 rsa_keysize = 1024 +CIPHER = RSA [coin_kudos_ct_10] value = TESTKUDOS:0.10 @@ -134,6 +135,7 @@ fee_deposit = TESTKUDOS:0.01 fee_refresh = TESTKUDOS:0.03 fee_refund = TESTKUDOS:0.01 rsa_keysize = 1024 +CIPHER = RSA [coin_kudos_1] value = TESTKUDOS:1 @@ -145,6 +147,7 @@ fee_deposit = TESTKUDOS:0.02 fee_refresh = TESTKUDOS:0.03 fee_refund = TESTKUDOS:0.01 rsa_keysize = 1024 +CIPHER = RSA [coin_kudos_2] value = TESTKUDOS:2 @@ -156,6 +159,7 @@ fee_deposit = TESTKUDOS:0.03 fee_refresh = TESTKUDOS:0.04 fee_refund = TESTKUDOS:0.02 rsa_keysize = 1024 +CIPHER = RSA [coin_kudos_4] value = TESTKUDOS:4 @@ -167,6 +171,7 @@ fee_deposit = TESTKUDOS:0.03 fee_refresh = TESTKUDOS:0.04 fee_refund = TESTKUDOS:0.02 rsa_keysize = 1024 +CIPHER = RSA [coin_kudos_5] value = TESTKUDOS:5 @@ -178,6 +183,7 @@ fee_deposit = TESTKUDOS:0.01 fee_refresh = TESTKUDOS:0.03 fee_refund = TESTKUDOS:0.01 rsa_keysize = 1024 +CIPHER = RSA [coin_kudos_8] value = TESTKUDOS:8 @@ -189,6 +195,7 @@ fee_deposit = TESTKUDOS:0.02 fee_refresh = TESTKUDOS:0.03 fee_refund = TESTKUDOS:0.04 rsa_keysize = 1024 +CIPHER = RSA [coin_kudos_10] value = TESTKUDOS:10 @@ -200,3 +207,4 @@ fee_deposit = TESTKUDOS:0.01 fee_refresh = TESTKUDOS:0.03 fee_refund = TESTKUDOS:0.01 rsa_keysize = 1024 +CIPHER = RSA diff --git a/src/reducer/anastasis_api_backup_redux.c b/src/reducer/anastasis_api_backup_redux.c index e366ec1..b3ee9dd 100644 --- a/src/reducer/anastasis_api_backup_redux.c +++ b/src/reducer/anastasis_api_backup_redux.c @@ -2609,8 +2609,7 @@ update_expiration_cost (json_t *state, { struct Costs *nxt = costs->next; - if ( (0 != costs->cost.value) || - (0 != costs->cost.fraction) ) + if (! TALER_amount_is_zero (&costs->cost)) { json_t *ao; |