LCOV - code coverage report
Current view: top level - bank-lib - fakebank_bank_accounts_withdrawals.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 15 0
Test Date: 2026-04-14 15:39:31 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   (C) 2016-2024 Taler Systems SA
       4              : 
       5              :   TALER is free software; you can redistribute it and/or
       6              :   modify it under the terms of the GNU General Public License
       7              :   as published by the Free Software Foundation; either version 3,
       8              :   or (at your option) any later version.
       9              : 
      10              :   TALER is distributed in the hope that it will be useful,
      11              :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      12              :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13              :   GNU General Public License for more details.
      14              : 
      15              :   You should have received a copy of the GNU General Public
      16              :   License along with TALER; see the file COPYING.  If not,
      17              :   see <http://www.gnu.org/licenses/>
      18              : */
      19              : /**
      20              :  * @file bank-lib/fakebank_bank_accounts_withdrawals.c
      21              :  * @brief library that fakes being a Taler bank for testcases
      22              :  * @author Christian Grothoff <christian@grothoff.org>
      23              :  */
      24              : #include <pthread.h>
      25              : #include "taler/taler_fakebank_lib.h"
      26              : #include "taler/taler_bank_service.h"
      27              : #include "taler/taler_mhd_lib.h"
      28              : #include <gnunet/gnunet_mhd_compat.h>
      29              : #include "fakebank.h"
      30              : #include "fakebank_bank_accounts_withdrawals.h"
      31              : #include "fakebank_common_lookup.h"
      32              : 
      33              : 
      34              : MHD_RESULT
      35            0 : TALER_FAKEBANK_bank_account_withdrawals_ (
      36              :   struct TALER_FAKEBANK_Handle *h,
      37              :   struct MHD_Connection *connection,
      38              :   const char *account_name,
      39              :   const char *withdrawal_id)
      40              : {
      41              :   struct WithdrawalOperation *wo;
      42              :   struct Account *acc;
      43              : 
      44            0 :   GNUNET_assert (0 ==
      45              :                  pthread_mutex_lock (&h->big_lock));
      46            0 :   wo = TALER_FAKEBANK_lookup_withdrawal_operation_ (h,
      47              :                                                     withdrawal_id);
      48            0 :   if (NULL == wo)
      49              :   {
      50            0 :     GNUNET_assert (0 ==
      51              :                    pthread_mutex_unlock (&h->big_lock));
      52            0 :     return TALER_MHD_reply_with_error (connection,
      53              :                                        MHD_HTTP_NOT_FOUND,
      54              :                                        TALER_EC_BANK_TRANSACTION_NOT_FOUND,
      55              :                                        withdrawal_id);
      56              :   }
      57            0 :   acc = TALER_FAKEBANK_lookup_account_ (h,
      58              :                                         account_name,
      59              :                                         NULL);
      60            0 :   if (NULL == acc)
      61              :   {
      62            0 :     GNUNET_assert (0 ==
      63              :                    pthread_mutex_unlock (&h->big_lock));
      64            0 :     return TALER_MHD_reply_with_error (connection,
      65              :                                        MHD_HTTP_NOT_FOUND,
      66              :                                        TALER_EC_BANK_UNKNOWN_ACCOUNT,
      67              :                                        account_name);
      68              :   }
      69            0 :   if (wo->debit_account != acc)
      70              :   {
      71            0 :     GNUNET_assert (0 ==
      72              :                    pthread_mutex_unlock (&h->big_lock));
      73            0 :     return TALER_MHD_reply_with_error (connection,
      74              :                                        MHD_HTTP_NOT_FOUND,
      75              :                                        TALER_EC_BANK_TRANSACTION_NOT_FOUND,
      76              :                                        account_name);
      77              :   }
      78            0 :   GNUNET_assert (0 ==
      79              :                  pthread_mutex_unlock (&h->big_lock));
      80            0 :   return TALER_MHD_REPLY_JSON_PACK (
      81              :     connection,
      82              :     MHD_HTTP_OK,
      83              :     GNUNET_JSON_pack_bool ("aborted",
      84              :                            wo->aborted),
      85              :     GNUNET_JSON_pack_bool ("selection_done",
      86              :                            wo->selection_done),
      87              :     GNUNET_JSON_pack_bool ("transfer_done",
      88              :                            wo->confirmation_done),
      89              :     GNUNET_JSON_pack_allow_null (
      90              :       GNUNET_JSON_pack_string ("selected_exchange_account",
      91              :                                wo->exchange_account->payto_uri)),
      92              :     GNUNET_JSON_pack_allow_null (
      93              :       wo->selection_done
      94              :       ? GNUNET_JSON_pack_data_auto ("selected_reserve_pub",
      95              :                                     &wo->reserve_pub)
      96              :       : GNUNET_JSON_pack_string ("selected_reserve_pub",
      97              :                                  NULL)),
      98              :     GNUNET_JSON_pack_allow_null (
      99              :       TALER_JSON_pack_amount ("amount",
     100              :                               wo->amount)));
     101              : }
        

Generated by: LCOV version 2.0-1