diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-07-31 21:48:36 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-07-31 21:48:36 +0200 |
commit | 33a28efef74d1db0c08a8e9e3facf3656b4b29e1 (patch) | |
tree | e35dd51b3364f9c41a40a6e8a8c715b1b623d35c | |
parent | fde9dc80f6e6a5fe4c5856b2ed78e6c024528c43 (diff) | |
download | exchange-33a28efef74d1db0c08a8e9e3facf3656b4b29e1.tar.gz exchange-33a28efef74d1db0c08a8e9e3facf3656b4b29e1.zip |
-more json_pack fixes
-rw-r--r-- | src/auditor/taler-helper-auditor-aggregation.c | 10 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-coins.c | 4 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-deposits.c | 14 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-reserves.c | 6 | ||||
-rw-r--r-- | src/exchangedb/Makefile.am | 5 | ||||
-rw-r--r-- | src/exchangedb/test_exchangedb.c | 17 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_insert_deposit.c | 8 | ||||
-rw-r--r-- | src/testing/testing_api_helpers_bank.c | 88 |
8 files changed, 41 insertions, 111 deletions
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index 4990ae405..c6398be2f 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c | |||
@@ -127,7 +127,7 @@ static int internal_checks; | |||
127 | * respect to calculations involving amounts. | 127 | * respect to calculations involving amounts. |
128 | * | 128 | * |
129 | * @param operation what operation had the inconsistency | 129 | * @param operation what operation had the inconsistency |
130 | * @param rowid affected row, UINT64_MAX if row is missing | 130 | * @param rowid affected row, 0 if row is missing |
131 | * @param exchange amount calculated by exchange | 131 | * @param exchange amount calculated by exchange |
132 | * @param auditor amount calculated by auditor | 132 | * @param auditor amount calculated by auditor |
133 | * @param profitable 1 if @a exchange being larger than @a auditor is | 133 | * @param profitable 1 if @a exchange being larger than @a auditor is |
@@ -254,7 +254,7 @@ report_coin_arithmetic_inconsistency ( | |||
254 | * Report a (serious) inconsistency in the exchange's database. | 254 | * Report a (serious) inconsistency in the exchange's database. |
255 | * | 255 | * |
256 | * @param table affected table | 256 | * @param table affected table |
257 | * @param rowid affected row, UINT64_MAX if row is missing | 257 | * @param rowid affected row, 0 if row is missing |
258 | * @param diagnostic message explaining the problem | 258 | * @param diagnostic message explaining the problem |
259 | */ | 259 | */ |
260 | static void | 260 | static void |
@@ -499,7 +499,7 @@ check_transaction_history_for_deposit ( | |||
499 | { | 499 | { |
500 | /* Disagreement in fee structure between auditor and exchange DB! */ | 500 | /* Disagreement in fee structure between auditor and exchange DB! */ |
501 | report_amount_arithmetic_inconsistency ("deposit fee", | 501 | report_amount_arithmetic_inconsistency ("deposit fee", |
502 | UINT64_MAX, | 502 | 0, |
503 | fee_claimed, | 503 | fee_claimed, |
504 | &fee_expected, | 504 | &fee_expected, |
505 | 1); | 505 | 1); |
@@ -524,7 +524,7 @@ check_transaction_history_for_deposit ( | |||
524 | { | 524 | { |
525 | /* Disagreement in fee structure between exchange and auditor */ | 525 | /* Disagreement in fee structure between exchange and auditor */ |
526 | report_amount_arithmetic_inconsistency ("melt fee", | 526 | report_amount_arithmetic_inconsistency ("melt fee", |
527 | UINT64_MAX, | 527 | 0, |
528 | fee_claimed, | 528 | fee_claimed, |
529 | &fee_expected, | 529 | &fee_expected, |
530 | 1); | 530 | 1); |
@@ -568,7 +568,7 @@ check_transaction_history_for_deposit ( | |||
568 | { | 568 | { |
569 | /* Disagreement in fee structure between exchange and auditor! */ | 569 | /* Disagreement in fee structure between exchange and auditor! */ |
570 | report_amount_arithmetic_inconsistency ("refund fee", | 570 | report_amount_arithmetic_inconsistency ("refund fee", |
571 | UINT64_MAX, | 571 | 0, |
572 | fee_claimed, | 572 | fee_claimed, |
573 | &fee_expected, | 573 | &fee_expected, |
574 | 1); | 574 | 1); |
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index 40b68c4ad..b3050542d 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c | |||
@@ -364,7 +364,7 @@ report_emergency_by_count ( | |||
364 | * respect to calculations involving amounts. | 364 | * respect to calculations involving amounts. |
365 | * | 365 | * |
366 | * @param operation what operation had the inconsistency | 366 | * @param operation what operation had the inconsistency |
367 | * @param rowid affected row, UINT64_MAX if row is missing | 367 | * @param rowid affected row, 0 if row is missing |
368 | * @param exchange amount calculated by exchange | 368 | * @param exchange amount calculated by exchange |
369 | * @param auditor amount calculated by auditor | 369 | * @param auditor amount calculated by auditor |
370 | * @param profitable 1 if @a exchange being larger than @a auditor is | 370 | * @param profitable 1 if @a exchange being larger than @a auditor is |
@@ -429,7 +429,7 @@ report_amount_arithmetic_inconsistency ( | |||
429 | * Report a (serious) inconsistency in the exchange's database. | 429 | * Report a (serious) inconsistency in the exchange's database. |
430 | * | 430 | * |
431 | * @param table affected table | 431 | * @param table affected table |
432 | * @param rowid affected row, UINT64_MAX if row is missing | 432 | * @param rowid affected row, 0 if row is missing |
433 | * @param diagnostic message explaining the problem | 433 | * @param diagnostic message explaining the problem |
434 | */ | 434 | */ |
435 | static void | 435 | static void |
diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c index 17b32f25e..c9c8bf662 100644 --- a/src/auditor/taler-helper-auditor-deposits.c +++ b/src/auditor/taler-helper-auditor-deposits.c | |||
@@ -216,13 +216,13 @@ analyze_deposit_confirmations (void *cls) | |||
216 | dcc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; | 216 | dcc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; |
217 | dcc.missed_count = 0LLU; | 217 | dcc.missed_count = 0LLU; |
218 | dcc.first_missed_coin_serial = UINT64_MAX; | 218 | dcc.first_missed_coin_serial = UINT64_MAX; |
219 | qsx = TALER_ARL_adb->get_deposit_confirmations (TALER_ARL_adb->cls, | 219 | qsx = TALER_ARL_adb->get_deposit_confirmations ( |
220 | TALER_ARL_asession, | 220 | TALER_ARL_adb->cls, |
221 | &TALER_ARL_master_pub, | 221 | TALER_ARL_asession, |
222 | ppdc. | 222 | &TALER_ARL_master_pub, |
223 | last_deposit_confirmation_serial_id, | 223 | ppdc.last_deposit_confirmation_serial_id, |
224 | &test_dc, | 224 | &test_dc, |
225 | &dcc); | 225 | &dcc); |
226 | if (0 > qsx) | 226 | if (0 > qsx) |
227 | { | 227 | { |
228 | GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); | 228 | GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); |
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index 22d7f5c27..efeaa4f63 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c | |||
@@ -155,7 +155,7 @@ static int internal_checks; | |||
155 | * respect to calculations involving amounts. | 155 | * respect to calculations involving amounts. |
156 | * | 156 | * |
157 | * @param operation what operation had the inconsistency | 157 | * @param operation what operation had the inconsistency |
158 | * @param rowid affected row, UINT64_MAX if row is missing | 158 | * @param rowid affected row, 0 if row is missing |
159 | * @param exchange amount calculated by exchange | 159 | * @param exchange amount calculated by exchange |
160 | * @param auditor amount calculated by auditor | 160 | * @param auditor amount calculated by auditor |
161 | * @param profitable 1 if @a exchange being larger than @a auditor is | 161 | * @param profitable 1 if @a exchange being larger than @a auditor is |
@@ -218,7 +218,7 @@ report_amount_arithmetic_inconsistency ( | |||
218 | * Report a (serious) inconsistency in the exchange's database. | 218 | * Report a (serious) inconsistency in the exchange's database. |
219 | * | 219 | * |
220 | * @param table affected table | 220 | * @param table affected table |
221 | * @param rowid affected row, UINT64_MAX if row is missing | 221 | * @param rowid affected row, 0 if row is missing |
222 | * @param diagnostic message explaining the problem | 222 | * @param diagnostic message explaining the problem |
223 | */ | 223 | */ |
224 | static void | 224 | static void |
@@ -1231,7 +1231,7 @@ verify_reserve_balance (void *cls, | |||
1231 | to be withdrawn more than it was IN TOTAL ever given (exchange balance | 1231 | to be withdrawn more than it was IN TOTAL ever given (exchange balance |
1232 | went negative!). Woopsie. Calculate how badly it went and log. */ | 1232 | went negative!). Woopsie. Calculate how badly it went and log. */ |
1233 | report_amount_arithmetic_inconsistency ("global escrow balance", | 1233 | report_amount_arithmetic_inconsistency ("global escrow balance", |
1234 | UINT64_MAX, | 1234 | 0, |
1235 | &total_escrow_balance, /* what we had */ | 1235 | &total_escrow_balance, /* what we had */ |
1236 | &rs->total_out, /* what we needed */ | 1236 | &rs->total_out, /* what we needed */ |
1237 | 0 /* specific profit/loss does not apply to the total summary */); | 1237 | 0 /* specific profit/loss does not apply to the total summary */); |
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index 26f5a3cbc..5114fb9cb 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am | |||
@@ -83,9 +83,10 @@ test_exchangedb_postgres_SOURCES = \ | |||
83 | test_exchangedb_postgres_LDADD = \ | 83 | test_exchangedb_postgres_LDADD = \ |
84 | libtalerexchangedb.la \ | 84 | libtalerexchangedb.la \ |
85 | $(top_builddir)/src/json/libtalerjson.la \ | 85 | $(top_builddir)/src/json/libtalerjson.la \ |
86 | $(top_srcdir)/src/util/libtalerutil.la \ | 86 | $(top_builddir)/src/util/libtalerutil.la \ |
87 | $(top_srcdir)/src/pq/libtalerpq.la \ | 87 | $(top_builddir)/src/pq/libtalerpq.la \ |
88 | -ljansson \ | 88 | -ljansson \ |
89 | -lgnunetjson \ | ||
89 | -lgnunetutil \ | 90 | -lgnunetutil \ |
90 | $(XLIB) | 91 | $(XLIB) |
91 | 92 | ||
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 462134275..fd11de2eb 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c | |||
@@ -1348,10 +1348,11 @@ test_wire_out (struct TALER_EXCHANGEDB_Session *session, | |||
1348 | { | 1348 | { |
1349 | json_t *wire_out_account; | 1349 | json_t *wire_out_account; |
1350 | 1350 | ||
1351 | wire_out_account = json_pack ("{s:s,s:s}", | 1351 | wire_out_account = GNUNET_JSON_PACK ( |
1352 | "payto_uri", | 1352 | GNUNET_JSON_pack_string ("payto_uri", |
1353 | "payto://x-taler-bank/localhost:8080/1", | 1353 | "payto://x-taler-bank/localhost:8080/1"), |
1354 | "salt", "this-is-my-salt"); | 1354 | GNUNET_JSON_pack_string ("salt", |
1355 | "this-is-my-salt")); | ||
1355 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != | 1356 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != |
1356 | plugin->store_wire_transfer_out (plugin->cls, | 1357 | plugin->store_wire_transfer_out (plugin->cls, |
1357 | session, | 1358 | session, |
@@ -1567,9 +1568,11 @@ run (void *cls) | |||
1567 | rh = NULL; | 1568 | rh = NULL; |
1568 | session = NULL; | 1569 | session = NULL; |
1569 | deposit.coin.denom_sig.rsa_signature = NULL; | 1570 | deposit.coin.denom_sig.rsa_signature = NULL; |
1570 | wire = json_pack ("{s:s, s:s}", | 1571 | wire = GNUNET_JSON_PACK ( |
1571 | "payto_uri", "payto://sepa/DE67830654080004822650", | 1572 | GNUNET_JSON_pack_string ("payto_uri", |
1572 | "salt", "this-is-a-salt-value"); | 1573 | "payto://sepa/DE67830654080004822650"), |
1574 | GNUNET_JSON_pack_string ("salt", | ||
1575 | "this-is-a-salt-value")); | ||
1573 | ZR_BLK (&cbc); | 1576 | ZR_BLK (&cbc); |
1574 | ZR_BLK (&cbc2); | 1577 | ZR_BLK (&cbc2); |
1575 | if (NULL == | 1578 | if (NULL == |
diff --git a/src/testing/testing_api_cmd_insert_deposit.c b/src/testing/testing_api_cmd_insert_deposit.c index 06f2dbe0e..607baeef3 100644 --- a/src/testing/testing_api_cmd_insert_deposit.c +++ b/src/testing/testing_api_cmd_insert_deposit.c | |||
@@ -189,9 +189,11 @@ insert_deposit_run (void *cls, | |||
189 | "payto://x-taler-bank/localhost/%s", | 189 | "payto://x-taler-bank/localhost/%s", |
190 | ids->merchant_account); | 190 | ids->merchant_account); |
191 | deposit.receiver_wire_account | 191 | deposit.receiver_wire_account |
192 | = json_pack ("{s:s, s:s}", | 192 | = GNUNET_JSON_PACK ( |
193 | "salt", "this-is-a-salt-value", | 193 | GNUNET_JSON_pack_string ("salt", |
194 | "payto_uri", str); | 194 | "this-is-a-salt-value"), |
195 | GNUNET_JSON_pack_string ("payto_uri", | ||
196 | str)); | ||
195 | GNUNET_free (str); | 197 | GNUNET_free (str); |
196 | } | 198 | } |
197 | 199 | ||
diff --git a/src/testing/testing_api_helpers_bank.c b/src/testing/testing_api_helpers_bank.c index 6751f3f4d..a82bcbfe3 100644 --- a/src/testing/testing_api_helpers_bank.c +++ b/src/testing/testing_api_helpers_bank.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2018-2020 Taler Systems SA | 3 | Copyright (C) 2018-2021 Taler Systems SA |
4 | 4 | ||
5 | TALER is free software; you can redistribute it and/or modify | 5 | TALER is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as | 6 | it under the terms of the GNU General Public License as |
@@ -31,15 +31,6 @@ | |||
31 | do {GNUNET_break (0); return NULL; } while (0) | 31 | do {GNUNET_break (0); return NULL; } while (0) |
32 | 32 | ||
33 | 33 | ||
34 | /** | ||
35 | * Runs the Fakebank by guessing / extracting the portnumber | ||
36 | * from the base URL. | ||
37 | * | ||
38 | * @param bank_url bank's base URL. | ||
39 | * @param currency currency the bank uses | ||
40 | * @return the fakebank process handle, or NULL if any | ||
41 | * error occurs. | ||
42 | */ | ||
43 | struct TALER_FAKEBANK_Handle * | 34 | struct TALER_FAKEBANK_Handle * |
44 | TALER_TESTING_run_fakebank (const char *bank_url, | 35 | TALER_TESTING_run_fakebank (const char *bank_url, |
45 | const char *currency) | 36 | const char *currency) |
@@ -69,13 +60,6 @@ TALER_TESTING_run_fakebank (const char *bank_url, | |||
69 | } | 60 | } |
70 | 61 | ||
71 | 62 | ||
72 | /** | ||
73 | * Look for substring in a programs' name. | ||
74 | * | ||
75 | * @param prog program's name to look into | ||
76 | * @param marker chunk to find in @a prog | ||
77 | * @return #GNUNET_YES if @a marker is present, otherwise #GNUNET_NO | ||
78 | */ | ||
79 | int | 63 | int |
80 | TALER_TESTING_has_in_name (const char *prog, | 64 | TALER_TESTING_has_in_name (const char *prog, |
81 | const char *marker) | 65 | const char *marker) |
@@ -100,16 +84,6 @@ TALER_TESTING_has_in_name (const char *prog, | |||
100 | } | 84 | } |
101 | 85 | ||
102 | 86 | ||
103 | /** | ||
104 | * Start the (nexus) bank process. Assume the port | ||
105 | * is available and the database is clean. Use the "prepare | ||
106 | * bank" function to do such tasks. This function is also | ||
107 | * responsible to create the exchange user at Nexus. | ||
108 | * | ||
109 | * @param bc bank configuration of the bank | ||
110 | * @return the pair of both service handles. In case of | ||
111 | * errors, each element of the pair will be set to NULL. | ||
112 | */ | ||
113 | struct TALER_TESTING_LibeufinServices | 87 | struct TALER_TESTING_LibeufinServices |
114 | TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc) | 88 | TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc) |
115 | { | 89 | { |
@@ -224,17 +198,6 @@ TALER_TESTING_run_libeufin (const struct TALER_TESTING_BankConfiguration *bc) | |||
224 | } | 198 | } |
225 | 199 | ||
226 | 200 | ||
227 | /** | ||
228 | * Start the (Python) bank process. Assume the port | ||
229 | * is available and the database is clean. Use the "prepare | ||
230 | * bank" function to do such tasks. | ||
231 | * | ||
232 | * @param config_filename configuration filename. | ||
233 | * @param bank_url base URL of the bank, used by `wget' to check | ||
234 | * that the bank was started right. | ||
235 | * @return the process, or NULL if the process could not | ||
236 | * be started. | ||
237 | */ | ||
238 | struct GNUNET_OS_Process * | 201 | struct GNUNET_OS_Process * |
239 | TALER_TESTING_run_bank (const char *config_filename, | 202 | TALER_TESTING_run_bank (const char *config_filename, |
240 | const char *bank_url) | 203 | const char *bank_url) |
@@ -318,17 +281,6 @@ TALER_TESTING_run_bank (const char *config_filename, | |||
318 | } | 281 | } |
319 | 282 | ||
320 | 283 | ||
321 | /** | ||
322 | * Prepare the Nexus execution. Check if the port is available | ||
323 | * and delete old database. | ||
324 | * | ||
325 | * @param config_filename configuration file name. | ||
326 | * @param reset_db should we reset the bank's database | ||
327 | * @param config_section section of the configuration with the exchange's account | ||
328 | * @param[out] bc set to the bank's configuration data | ||
329 | * @return the base url, or NULL upon errors. Must be freed | ||
330 | * by the caller. | ||
331 | */ | ||
332 | int | 284 | int |
333 | TALER_TESTING_prepare_nexus (const char *config_filename, | 285 | TALER_TESTING_prepare_nexus (const char *config_filename, |
334 | int reset_db, | 286 | int reset_db, |
@@ -434,17 +386,6 @@ TALER_TESTING_prepare_nexus (const char *config_filename, | |||
434 | } | 386 | } |
435 | 387 | ||
436 | 388 | ||
437 | /** | ||
438 | * Prepare the bank execution. Check if the port is available | ||
439 | * and reset database. | ||
440 | * | ||
441 | * @param config_filename configuration file name. | ||
442 | * @param reset_db should we reset the bank's database | ||
443 | * @param config_section section of the configuration with the exchange's account | ||
444 | * @param[out] bc set to the bank's configuration data | ||
445 | * @return the base url, or NULL upon errors. Must be freed | ||
446 | * by the caller. | ||
447 | */ | ||
448 | int | 389 | int |
449 | TALER_TESTING_prepare_bank (const char *config_filename, | 390 | TALER_TESTING_prepare_bank (const char *config_filename, |
450 | int reset_db, | 391 | int reset_db, |
@@ -611,16 +552,6 @@ TALER_TESTING_prepare_bank (const char *config_filename, | |||
611 | } | 552 | } |
612 | 553 | ||
613 | 554 | ||
614 | /** | ||
615 | * Prepare launching a fakebank. Check that the configuration | ||
616 | * file has the right option, and that the port is available. | ||
617 | * If everything is OK, return the configuration data of the fakebank. | ||
618 | * | ||
619 | * @param config_filename configuration file to use | ||
620 | * @param config_section which account to use (must match x-taler-bank) | ||
621 | * @param[out] bc set to the bank's configuration data | ||
622 | * @return #GNUNET_OK on success | ||
623 | */ | ||
624 | int | 555 | int |
625 | TALER_TESTING_prepare_fakebank (const char *config_filename, | 556 | TALER_TESTING_prepare_fakebank (const char *config_filename, |
626 | const char *config_section, | 557 | const char *config_section, |
@@ -706,21 +637,14 @@ TALER_TESTING_prepare_fakebank (const char *config_filename, | |||
706 | } | 637 | } |
707 | 638 | ||
708 | 639 | ||
709 | /** | ||
710 | * Allocate and return a piece of wire-details. Combines | ||
711 | * a @a payto -URL and adds some salt to create the JSON. | ||
712 | * | ||
713 | * @param payto payto://-URL to encapsulate | ||
714 | * @return JSON describing the account, including the | ||
715 | * payto://-URL of the account, must be manually decref'd | ||
716 | */ | ||
717 | json_t * | 640 | json_t * |
718 | TALER_TESTING_make_wire_details (const char *payto) | 641 | TALER_TESTING_make_wire_details (const char *payto) |
719 | { | 642 | { |
720 | return json_pack ("{s:s, s:s}", | 643 | return GNUNET_JSON_PACK ( |
721 | "payto_uri", payto, | 644 | GNUNET_JSON_pack_string ("payto_uri", |
722 | "salt", | 645 | payto), |
723 | "test-salt (must be constant for aggregation tests)"); | 646 | GNUNET_JSON_pack_string ("salt", |
647 | "test-salt (must be constant for aggregation tests)")); | ||
724 | } | 648 | } |
725 | 649 | ||
726 | 650 | ||