-more json_pack fixes

This commit is contained in:
Christian Grothoff 2021-07-31 21:48:36 +02:00
parent fde9dc80f6
commit 33a28efef7
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
8 changed files with 41 additions and 111 deletions

View File

@ -127,7 +127,7 @@ static int internal_checks;
* respect to calculations involving amounts. * respect to calculations involving amounts.
* *
* @param operation what operation had the inconsistency * @param operation what operation had the inconsistency
* @param rowid affected row, UINT64_MAX if row is missing * @param rowid affected row, 0 if row is missing
* @param exchange amount calculated by exchange * @param exchange amount calculated by exchange
* @param auditor amount calculated by auditor * @param auditor amount calculated by auditor
* @param profitable 1 if @a exchange being larger than @a auditor is * @param profitable 1 if @a exchange being larger than @a auditor is
@ -254,7 +254,7 @@ report_coin_arithmetic_inconsistency (
* Report a (serious) inconsistency in the exchange's database. * Report a (serious) inconsistency in the exchange's database.
* *
* @param table affected table * @param table affected table
* @param rowid affected row, UINT64_MAX if row is missing * @param rowid affected row, 0 if row is missing
* @param diagnostic message explaining the problem * @param diagnostic message explaining the problem
*/ */
static void static void
@ -499,7 +499,7 @@ check_transaction_history_for_deposit (
{ {
/* Disagreement in fee structure between auditor and exchange DB! */ /* Disagreement in fee structure between auditor and exchange DB! */
report_amount_arithmetic_inconsistency ("deposit fee", report_amount_arithmetic_inconsistency ("deposit fee",
UINT64_MAX, 0,
fee_claimed, fee_claimed,
&fee_expected, &fee_expected,
1); 1);
@ -524,7 +524,7 @@ check_transaction_history_for_deposit (
{ {
/* Disagreement in fee structure between exchange and auditor */ /* Disagreement in fee structure between exchange and auditor */
report_amount_arithmetic_inconsistency ("melt fee", report_amount_arithmetic_inconsistency ("melt fee",
UINT64_MAX, 0,
fee_claimed, fee_claimed,
&fee_expected, &fee_expected,
1); 1);
@ -568,7 +568,7 @@ check_transaction_history_for_deposit (
{ {
/* Disagreement in fee structure between exchange and auditor! */ /* Disagreement in fee structure between exchange and auditor! */
report_amount_arithmetic_inconsistency ("refund fee", report_amount_arithmetic_inconsistency ("refund fee",
UINT64_MAX, 0,
fee_claimed, fee_claimed,
&fee_expected, &fee_expected,
1); 1);

View File

@ -364,7 +364,7 @@ report_emergency_by_count (
* respect to calculations involving amounts. * respect to calculations involving amounts.
* *
* @param operation what operation had the inconsistency * @param operation what operation had the inconsistency
* @param rowid affected row, UINT64_MAX if row is missing * @param rowid affected row, 0 if row is missing
* @param exchange amount calculated by exchange * @param exchange amount calculated by exchange
* @param auditor amount calculated by auditor * @param auditor amount calculated by auditor
* @param profitable 1 if @a exchange being larger than @a auditor is * @param profitable 1 if @a exchange being larger than @a auditor is
@ -429,7 +429,7 @@ report_amount_arithmetic_inconsistency (
* Report a (serious) inconsistency in the exchange's database. * Report a (serious) inconsistency in the exchange's database.
* *
* @param table affected table * @param table affected table
* @param rowid affected row, UINT64_MAX if row is missing * @param rowid affected row, 0 if row is missing
* @param diagnostic message explaining the problem * @param diagnostic message explaining the problem
*/ */
static void static void

View File

@ -216,13 +216,13 @@ analyze_deposit_confirmations (void *cls)
dcc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; dcc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
dcc.missed_count = 0LLU; dcc.missed_count = 0LLU;
dcc.first_missed_coin_serial = UINT64_MAX; dcc.first_missed_coin_serial = UINT64_MAX;
qsx = TALER_ARL_adb->get_deposit_confirmations (TALER_ARL_adb->cls, qsx = TALER_ARL_adb->get_deposit_confirmations (
TALER_ARL_asession, TALER_ARL_adb->cls,
&TALER_ARL_master_pub, TALER_ARL_asession,
ppdc. &TALER_ARL_master_pub,
last_deposit_confirmation_serial_id, ppdc.last_deposit_confirmation_serial_id,
&test_dc, &test_dc,
&dcc); &dcc);
if (0 > qsx) if (0 > qsx)
{ {
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);

View File

@ -155,7 +155,7 @@ static int internal_checks;
* respect to calculations involving amounts. * respect to calculations involving amounts.
* *
* @param operation what operation had the inconsistency * @param operation what operation had the inconsistency
* @param rowid affected row, UINT64_MAX if row is missing * @param rowid affected row, 0 if row is missing
* @param exchange amount calculated by exchange * @param exchange amount calculated by exchange
* @param auditor amount calculated by auditor * @param auditor amount calculated by auditor
* @param profitable 1 if @a exchange being larger than @a auditor is * @param profitable 1 if @a exchange being larger than @a auditor is
@ -218,7 +218,7 @@ report_amount_arithmetic_inconsistency (
* Report a (serious) inconsistency in the exchange's database. * Report a (serious) inconsistency in the exchange's database.
* *
* @param table affected table * @param table affected table
* @param rowid affected row, UINT64_MAX if row is missing * @param rowid affected row, 0 if row is missing
* @param diagnostic message explaining the problem * @param diagnostic message explaining the problem
*/ */
static void static void
@ -1231,7 +1231,7 @@ verify_reserve_balance (void *cls,
to be withdrawn more than it was IN TOTAL ever given (exchange balance to be withdrawn more than it was IN TOTAL ever given (exchange balance
went negative!). Woopsie. Calculate how badly it went and log. */ went negative!). Woopsie. Calculate how badly it went and log. */
report_amount_arithmetic_inconsistency ("global escrow balance", report_amount_arithmetic_inconsistency ("global escrow balance",
UINT64_MAX, 0,
&total_escrow_balance, /* what we had */ &total_escrow_balance, /* what we had */
&rs->total_out, /* what we needed */ &rs->total_out, /* what we needed */
0 /* specific profit/loss does not apply to the total summary */); 0 /* specific profit/loss does not apply to the total summary */);

View File

@ -83,9 +83,10 @@ test_exchangedb_postgres_SOURCES = \
test_exchangedb_postgres_LDADD = \ test_exchangedb_postgres_LDADD = \
libtalerexchangedb.la \ libtalerexchangedb.la \
$(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/json/libtalerjson.la \
$(top_srcdir)/src/util/libtalerutil.la \ $(top_builddir)/src/util/libtalerutil.la \
$(top_srcdir)/src/pq/libtalerpq.la \ $(top_builddir)/src/pq/libtalerpq.la \
-ljansson \ -ljansson \
-lgnunetjson \
-lgnunetutil \ -lgnunetutil \
$(XLIB) $(XLIB)

View File

@ -1348,10 +1348,11 @@ test_wire_out (struct TALER_EXCHANGEDB_Session *session,
{ {
json_t *wire_out_account; json_t *wire_out_account;
wire_out_account = json_pack ("{s:s,s:s}", wire_out_account = GNUNET_JSON_PACK (
"payto_uri", GNUNET_JSON_pack_string ("payto_uri",
"payto://x-taler-bank/localhost:8080/1", "payto://x-taler-bank/localhost:8080/1"),
"salt", "this-is-my-salt"); GNUNET_JSON_pack_string ("salt",
"this-is-my-salt"));
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->store_wire_transfer_out (plugin->cls, plugin->store_wire_transfer_out (plugin->cls,
session, session,
@ -1567,9 +1568,11 @@ run (void *cls)
rh = NULL; rh = NULL;
session = NULL; session = NULL;
deposit.coin.denom_sig.rsa_signature = NULL; deposit.coin.denom_sig.rsa_signature = NULL;
wire = json_pack ("{s:s, s:s}", wire = GNUNET_JSON_PACK (
"payto_uri", "payto://sepa/DE67830654080004822650", GNUNET_JSON_pack_string ("payto_uri",
"salt", "this-is-a-salt-value"); "payto://sepa/DE67830654080004822650"),
GNUNET_JSON_pack_string ("salt",
"this-is-a-salt-value"));
ZR_BLK (&cbc); ZR_BLK (&cbc);
ZR_BLK (&cbc2); ZR_BLK (&cbc2);
if (NULL == if (NULL ==

View File

@ -189,9 +189,11 @@ insert_deposit_run (void *cls,
"payto://x-taler-bank/localhost/%s", "payto://x-taler-bank/localhost/%s",
ids->merchant_account); ids->merchant_account);
deposit.receiver_wire_account deposit.receiver_wire_account
= json_pack ("{s:s, s:s}", = GNUNET_JSON_PACK (
"salt", "this-is-a-salt-value", GNUNET_JSON_pack_string ("salt",
"payto_uri", str); "this-is-a-salt-value"),
GNUNET_JSON_pack_string ("payto_uri",
str));
GNUNET_free (str); GNUNET_free (str);
} }

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER This file is part of TALER
Copyright (C) 2018-2020 Taler Systems SA Copyright (C) 2018-2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as it under the terms of the GNU General Public License as
@ -31,15 +31,6 @@
do {GNUNET_break (0); return NULL; } while (0) do {GNUNET_break (0); return NULL; } while (0)
/**
* Runs the Fakebank by guessing / extracting the portnumber
* from the base URL.
*
* @param bank_url bank's base URL.
* @param currency currency the bank uses
* @return the fakebank process handle, or NULL if any
* error occurs.
*/
struct TALER_FAKEBANK_Handle * struct TALER_FAKEBANK_Handle *
TALER_TESTING_run_fakebank (const char *bank_url, TALER_TESTING_run_fakebank (const char *bank_url,
const char *currency) const char *currency)
@ -69,13 +60,6 @@ TALER_TESTING_run_fakebank (const char *bank_url,
} }
/**
* Look for substring in a programs' name.
*
* @param prog program's name to look into
* @param marker chunk to find in @a prog
* @return #GNUNET_YES if @a marker is present, otherwise #GNUNET_NO
*/
int int
TALER_TESTING_has_in_name (const char *prog, TALER_TESTING_has_in_name (const char *prog,
const char *marker) const char *marker)
@ -100,16 +84,6 @@ TALER_TESTING_has_in_name (const char *prog,
} }
/**
* Start the (nexus) bank process. Assume the port
* is available and the database is clean. Use the "prepare
* bank" function to do such tasks. This function is also
* responsible to create the exchange user at Nexus.
*
* @param bc bank configuration of the bank
* @return the pair of both service handles. In case of
* errors, each element of the pair will be set to NULL.
*/
struct TALER_TESTING_LibeufinServices struct TALER_TESTING_LibeufinServices
TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc) TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc)
{ {
@ -224,17 +198,6 @@ TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc)
} }
/**
* Start the (Python) bank process. Assume the port
* is available and the database is clean. Use the "prepare
* bank" function to do such tasks.
*
* @param config_filename configuration filename.
* @param bank_url base URL of the bank, used by `wget' to check
* that the bank was started right.
* @return the process, or NULL if the process could not
* be started.
*/
struct GNUNET_OS_Process * struct GNUNET_OS_Process *
TALER_TESTING_run_bank (const char *config_filename, TALER_TESTING_run_bank (const char *config_filename,
const char *bank_url) const char *bank_url)
@ -318,17 +281,6 @@ TALER_TESTING_run_bank (const char *config_filename,
} }
/**
* Prepare the Nexus execution. Check if the port is available
* and delete old database.
*
* @param config_filename configuration file name.
* @param reset_db should we reset the bank's database
* @param config_section section of the configuration with the exchange's account
* @param[out] bc set to the bank's configuration data
* @return the base url, or NULL upon errors. Must be freed
* by the caller.
*/
int int
TALER_TESTING_prepare_nexus (const char *config_filename, TALER_TESTING_prepare_nexus (const char *config_filename,
int reset_db, int reset_db,
@ -434,17 +386,6 @@ TALER_TESTING_prepare_nexus (const char *config_filename,
} }
/**
* Prepare the bank execution. Check if the port is available
* and reset database.
*
* @param config_filename configuration file name.
* @param reset_db should we reset the bank's database
* @param config_section section of the configuration with the exchange's account
* @param[out] bc set to the bank's configuration data
* @return the base url, or NULL upon errors. Must be freed
* by the caller.
*/
int int
TALER_TESTING_prepare_bank (const char *config_filename, TALER_TESTING_prepare_bank (const char *config_filename,
int reset_db, int reset_db,
@ -611,16 +552,6 @@ TALER_TESTING_prepare_bank (const char *config_filename,
} }
/**
* Prepare launching a fakebank. Check that the configuration
* file has the right option, and that the port is available.
* If everything is OK, return the configuration data of the fakebank.
*
* @param config_filename configuration file to use
* @param config_section which account to use (must match x-taler-bank)
* @param[out] bc set to the bank's configuration data
* @return #GNUNET_OK on success
*/
int int
TALER_TESTING_prepare_fakebank (const char *config_filename, TALER_TESTING_prepare_fakebank (const char *config_filename,
const char *config_section, const char *config_section,
@ -706,21 +637,14 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
} }
/**
* Allocate and return a piece of wire-details. Combines
* a @a payto -URL and adds some salt to create the JSON.
*
* @param payto payto://-URL to encapsulate
* @return JSON describing the account, including the
* payto://-URL of the account, must be manually decref'd
*/
json_t * json_t *
TALER_TESTING_make_wire_details (const char *payto) TALER_TESTING_make_wire_details (const char *payto)
{ {
return json_pack ("{s:s, s:s}", return GNUNET_JSON_PACK (
"payto_uri", payto, GNUNET_JSON_pack_string ("payto_uri",
"salt", payto),
"test-salt (must be constant for aggregation tests)"); GNUNET_JSON_pack_string ("salt",
"test-salt (must be constant for aggregation tests)"));
} }