diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-05-23 10:36:39 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-05-23 10:36:39 +0200 |
commit | b3844e4923df39b41b8a8d46df173b1432c92364 (patch) | |
tree | d3bfa4a3019321d53828817994709c3ac4f1a4f5 /src/testing/testing_api_cmd_reserve_history.c | |
parent | fcaf508647f86af4409aaec25a138e45fcb90be3 (diff) | |
download | exchange-b3844e4923df39b41b8a8d46df173b1432c92364.tar.xz |
-deduplicate and expand reserve history validation logic in testing library
Diffstat (limited to 'src/testing/testing_api_cmd_reserve_history.c')
-rw-r--r-- | src/testing/testing_api_cmd_reserve_history.c | 77 |
1 files changed, 3 insertions, 74 deletions
diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c index fc94d8443..e79180643 100644 --- a/src/testing/testing_api_cmd_reserve_history.c +++ b/src/testing/testing_api_cmd_reserve_history.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2020 Taler Systems SA + Copyright (C) 2014-2022 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -71,76 +71,6 @@ struct HistoryState /** - * Compare @a h1 and @a h2. - * - * @param h1 a history entry - * @param h2 a history entry - * @return 0 if @a h1 and @a h2 are equal - */ -static int -history_entry_cmp (const struct TALER_EXCHANGE_ReserveHistoryEntry *h1, - const struct TALER_EXCHANGE_ReserveHistoryEntry *h2) -{ - if (h1->type != h2->type) - return 1; - switch (h1->type) - { - case TALER_EXCHANGE_RTT_CREDIT: - if ( (0 == - TALER_amount_cmp (&h1->amount, - &h2->amount)) && - (0 == strcasecmp (h1->details.in_details.sender_url, - h2->details.in_details.sender_url)) && - (h1->details.in_details.wire_reference == - h2->details.in_details.wire_reference) && - (GNUNET_TIME_timestamp_cmp (h1->details.in_details.timestamp, - ==, - h2->details.in_details.timestamp)) ) - return 0; - return 1; - case TALER_EXCHANGE_RTT_WITHDRAWAL: - if ( (0 == - TALER_amount_cmp (&h1->amount, - &h2->amount)) && - (0 == - TALER_amount_cmp (&h1->details.withdraw.fee, - &h2->details.withdraw.fee)) ) - /* testing_api_cmd_withdraw doesn't set the out_authorization_sig, - so we cannot test for it here. but if the amount matches, - that should be good enough. */ - return 0; - return 1; - case TALER_EXCHANGE_RTT_RECOUP: - /* exchange_sig, exchange_pub and timestamp are NOT available - from the original recoup response, hence here NOT check(able/ed) */ - if ( (0 == - TALER_amount_cmp (&h1->amount, - &h2->amount)) && - (0 == - GNUNET_memcmp (&h1->details.recoup_details.coin_pub, - &h2->details.recoup_details.coin_pub)) ) - return 0; - return 1; - case TALER_EXCHANGE_RTT_CLOSE: - /* testing_api_cmd_exec_closer doesn't set the - receiver_account_details, exchange_sig, exchange_pub or wtid or timestamp - so we cannot test for it here. but if the amount matches, - that should be good enough. */ - if ( (0 == - TALER_amount_cmp (&h1->amount, - &h2->amount)) && - (0 == - TALER_amount_cmp (&h1->details.close_details.fee, - &h2->details.close_details.fee)) ) - return 0; - return 1; - } - GNUNET_assert (0); - return 1; -} - - -/** * Check if @a cmd changed the reserve, if so, find the * entry in @a history and set the respective index in @a found * to #GNUNET_YES. If the entry is not found, return #GNUNET_SYSERR. @@ -216,8 +146,8 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub, if (found[i]) continue; /* already found, skip */ if (0 == - history_entry_cmp (he, - &history[i])) + TALER_TESTING_history_entry_cmp (he, + &history[i])) { found[i] = GNUNET_YES; return GNUNET_OK; @@ -336,7 +266,6 @@ history_run (void *cls, create_reserve = TALER_TESTING_interpreter_lookup_command (is, ss->reserve_reference); - if (NULL == create_reserve) { GNUNET_break (0); |