improve reporting, also use auditor fee calculation when computing reserve balance updates in case of disagreement on coin value/fee
This commit is contained in:
parent
1ef9735115
commit
581a39b5b5
@ -45,6 +45,10 @@ TARGET_DB=taler-auditor-basedb
|
|||||||
|
|
||||||
WALLET_DB=${BASEDB:-"wallet"}.wdb
|
WALLET_DB=${BASEDB:-"wallet"}.wdb
|
||||||
|
|
||||||
|
# delete existing wallet database
|
||||||
|
rm -f $WALLET_DB
|
||||||
|
|
||||||
|
|
||||||
# Configuration file will be edited, so we create one
|
# Configuration file will be edited, so we create one
|
||||||
# from the template.
|
# from the template.
|
||||||
CONF=generate-auditor-basedb-prod.conf
|
CONF=generate-auditor-basedb-prod.conf
|
||||||
@ -69,6 +73,7 @@ rm -rf $DATA_DIR || true
|
|||||||
dropdb $TARGET_DB >/dev/null 2>/dev/null || true
|
dropdb $TARGET_DB >/dev/null 2>/dev/null || true
|
||||||
createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
|
createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
|
||||||
|
|
||||||
|
|
||||||
# obtain key configuration data
|
# obtain key configuration data
|
||||||
MASTER_PRIV_FILE=`taler-config -f -c $CONF -s EXCHANGE -o MASTER_PRIV_FILE`
|
MASTER_PRIV_FILE=`taler-config -f -c $CONF -s EXCHANGE -o MASTER_PRIV_FILE`
|
||||||
MASTER_PRIV_DIR=`dirname $MASTER_PRIV_FILE`
|
MASTER_PRIV_DIR=`dirname $MASTER_PRIV_FILE`
|
||||||
@ -141,7 +146,7 @@ fi
|
|||||||
|
|
||||||
# Setup merchant
|
# Setup merchant
|
||||||
|
|
||||||
curl -H "Content-Type: application/json" -X POST -d '{"payto_uris":["payto://x-taler-bank/localhost:8082/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/private/instances
|
curl -H "Content-Type: application/json" -X POST -d '{"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/private/instances
|
||||||
|
|
||||||
|
|
||||||
echo " DONE"
|
echo " DONE"
|
||||||
@ -149,6 +154,7 @@ echo " DONE"
|
|||||||
# run wallet CLI
|
# run wallet CLI
|
||||||
echo "Running wallet"
|
echo "Running wallet"
|
||||||
|
|
||||||
|
|
||||||
taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'runIntegrationTest' \
|
taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'runIntegrationTest' \
|
||||||
"$(jq -n '
|
"$(jq -n '
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ echo " DONE"
|
|||||||
|
|
||||||
# Setup merchant
|
# Setup merchant
|
||||||
|
|
||||||
curl -H "Content-Type: application/json" -X POST -d '{"payto_uris":["payto://x-taler-bank/localhost:8082/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/private/instances
|
curl -H "Content-Type: application/json" -X POST -d '{"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/private/instances
|
||||||
|
|
||||||
|
|
||||||
# run wallet CLI
|
# run wallet CLI
|
||||||
|
@ -491,6 +491,8 @@ handle_reserve_out (void *cls,
|
|||||||
struct ReserveSummary *rs;
|
struct ReserveSummary *rs;
|
||||||
const struct TALER_DenominationKeyValidityPS *issue;
|
const struct TALER_DenominationKeyValidityPS *issue;
|
||||||
struct TALER_Amount withdraw_fee;
|
struct TALER_Amount withdraw_fee;
|
||||||
|
struct TALER_Amount auditor_value;
|
||||||
|
struct TALER_Amount auditor_amount_with_fee;
|
||||||
struct GNUNET_TIME_Absolute valid_start;
|
struct GNUNET_TIME_Absolute valid_start;
|
||||||
struct GNUNET_TIME_Absolute expire_withdraw;
|
struct GNUNET_TIME_Absolute expire_withdraw;
|
||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
@ -578,6 +580,23 @@ handle_reserve_out (void *cls,
|
|||||||
return GNUNET_OK; /* exit function here, we cannot add this to the legitimate withdrawals */
|
return GNUNET_OK; /* exit function here, we cannot add this to the legitimate withdrawals */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TALER_amount_ntoh (&withdraw_fee,
|
||||||
|
&issue->fee_withdraw);
|
||||||
|
TALER_amount_ntoh (&auditor_value,
|
||||||
|
&issue->value);
|
||||||
|
TALER_ARL_amount_add (&auditor_amount_with_fee,
|
||||||
|
&auditor_value,
|
||||||
|
&withdraw_fee);
|
||||||
|
if (0 !=
|
||||||
|
TALER_amount_cmp (&auditor_amount_with_fee,
|
||||||
|
amount_with_fee))
|
||||||
|
{
|
||||||
|
report_row_inconsistency ("withdraw",
|
||||||
|
rowid,
|
||||||
|
"amount with fee from exchange does not match denomination value plus fee");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GNUNET_CRYPTO_hash (reserve_pub,
|
GNUNET_CRYPTO_hash (reserve_pub,
|
||||||
sizeof (*reserve_pub),
|
sizeof (*reserve_pub),
|
||||||
&key);
|
&key);
|
||||||
@ -587,7 +606,7 @@ handle_reserve_out (void *cls,
|
|||||||
{
|
{
|
||||||
rs = GNUNET_new (struct ReserveSummary);
|
rs = GNUNET_new (struct ReserveSummary);
|
||||||
rs->reserve_pub = *reserve_pub;
|
rs->reserve_pub = *reserve_pub;
|
||||||
rs->total_out = *amount_with_fee;
|
rs->total_out = auditor_amount_with_fee;
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_amount_get_zero (amount_with_fee->currency,
|
TALER_amount_get_zero (amount_with_fee->currency,
|
||||||
&rs->total_in));
|
&rs->total_in));
|
||||||
@ -612,14 +631,12 @@ handle_reserve_out (void *cls,
|
|||||||
{
|
{
|
||||||
TALER_ARL_amount_add (&rs->total_out,
|
TALER_ARL_amount_add (&rs->total_out,
|
||||||
&rs->total_out,
|
&rs->total_out,
|
||||||
amount_with_fee);
|
&auditor_amount_with_fee);
|
||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"Reserve `%s' reduced by %s from withdraw\n",
|
"Reserve `%s' reduced by %s from withdraw\n",
|
||||||
TALER_B2S (reserve_pub),
|
TALER_B2S (reserve_pub),
|
||||||
TALER_amount2s (amount_with_fee));
|
TALER_amount2s (&auditor_amount_with_fee));
|
||||||
TALER_amount_ntoh (&withdraw_fee,
|
|
||||||
&issue->fee_withdraw);
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Increasing withdraw profits by fee %s\n",
|
"Increasing withdraw profits by fee %s\n",
|
||||||
TALER_amount2s (&withdraw_fee));
|
TALER_amount2s (&withdraw_fee));
|
||||||
|
@ -1017,7 +1017,7 @@ wire_out_cb (void *cls,
|
|||||||
we should count the wire transfer as entirely spurious, and
|
we should count the wire transfer as entirely spurious, and
|
||||||
additionally consider the justified wire transfer as missing. */
|
additionally consider the justified wire transfer as missing. */
|
||||||
TALER_ARL_report (report_wire_out_inconsistencies,
|
TALER_ARL_report (report_wire_out_inconsistencies,
|
||||||
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s}",
|
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s, s:s}",
|
||||||
"row", (json_int_t) rowid,
|
"row", (json_int_t) rowid,
|
||||||
"amount_wired", TALER_JSON_from_amount (
|
"amount_wired", TALER_JSON_from_amount (
|
||||||
&roi->details.amount),
|
&roi->details.amount),
|
||||||
@ -1027,12 +1027,13 @@ wire_out_cb (void *cls,
|
|||||||
"timestamp", TALER_ARL_json_from_time_abs (
|
"timestamp", TALER_ARL_json_from_time_abs (
|
||||||
date),
|
date),
|
||||||
"diagnostic", "receiver account mismatch",
|
"diagnostic", "receiver account mismatch",
|
||||||
|
"target", payto_uri,
|
||||||
"account_section", wa->section_name));
|
"account_section", wa->section_name));
|
||||||
TALER_ARL_amount_add (&total_bad_amount_out_plus,
|
TALER_ARL_amount_add (&total_bad_amount_out_plus,
|
||||||
&total_bad_amount_out_plus,
|
&total_bad_amount_out_plus,
|
||||||
&roi->details.amount);
|
&roi->details.amount);
|
||||||
TALER_ARL_report (report_wire_out_inconsistencies,
|
TALER_ARL_report (report_wire_out_inconsistencies,
|
||||||
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s}",
|
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s, s:s}",
|
||||||
"row", (json_int_t) rowid,
|
"row", (json_int_t) rowid,
|
||||||
"amount_wired", TALER_JSON_from_amount (
|
"amount_wired", TALER_JSON_from_amount (
|
||||||
&zero),
|
&zero),
|
||||||
@ -1042,6 +1043,7 @@ wire_out_cb (void *cls,
|
|||||||
"timestamp", TALER_ARL_json_from_time_abs (
|
"timestamp", TALER_ARL_json_from_time_abs (
|
||||||
date),
|
date),
|
||||||
"diagnostic", "receiver account mismatch",
|
"diagnostic", "receiver account mismatch",
|
||||||
|
"target", roi->details.credit_account_url,
|
||||||
"account_section", wa->section_name));
|
"account_section", wa->section_name));
|
||||||
TALER_ARL_amount_add (&total_bad_amount_out_minus,
|
TALER_ARL_amount_add (&total_bad_amount_out_minus,
|
||||||
&total_bad_amount_out_minus,
|
&total_bad_amount_out_minus,
|
||||||
|
@ -1655,7 +1655,7 @@ echo "UPDATE auditor_denominations SET fee_withdraw_frac=5000000 WHERE coin_val=
|
|||||||
run_audit
|
run_audit
|
||||||
|
|
||||||
echo -n "Testing inconsistency detection... "
|
echo -n "Testing inconsistency detection... "
|
||||||
AMOUNT=`jq -r .total_balance_summary_delta_plus < test-audit-reserves.json`
|
AMOUNT=`jq -r .total_balance_summary_delta_minus < test-audit-reserves.json`
|
||||||
if test "x$AMOUNT" == "xTESTKUDOS:0"
|
if test "x$AMOUNT" == "xTESTKUDOS:0"
|
||||||
then
|
then
|
||||||
exit_fail "Reported total amount wrong: $AMOUNT"
|
exit_fail "Reported total amount wrong: $AMOUNT"
|
||||||
@ -1826,7 +1826,7 @@ check_with_database()
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "Cleanup (disabled, leaving database $DB behind)"
|
echo "Cleanup (disabled, leaving database $DB behind)"
|
||||||
dropdb $DB
|
# dropdb $DB
|
||||||
rm -r $WIRE_FEE_DIR
|
rm -r $WIRE_FEE_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user