LCOV - code coverage report
Current view: top level - bank-lib - fakebank_bank_accounts_withdrawals.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 15 0.0 %
Date: 2025-06-22 12:09:43 Functions: 0 1 0.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 "taler/platform.h"
      25             : #include <pthread.h>
      26             : #include "taler/taler_fakebank_lib.h"
      27             : #include "taler/taler_bank_service.h"
      28             : #include "taler/taler_mhd_lib.h"
      29             : #include <gnunet/gnunet_mhd_compat.h>
      30             : #include "fakebank.h"
      31             : #include "fakebank_bank_accounts_withdrawals.h"
      32             : #include "fakebank_common_lookup.h"
      33             : 
      34             : 
      35             : MHD_RESULT
      36           0 : TALER_FAKEBANK_bank_account_withdrawals_ (
      37             :   struct TALER_FAKEBANK_Handle *h,
      38             :   struct MHD_Connection *connection,
      39             :   const char *account_name,
      40             :   const char *withdrawal_id)
      41             : {
      42             :   struct WithdrawalOperation *wo;
      43             :   struct Account *acc;
      44             : 
      45           0 :   GNUNET_assert (0 ==
      46             :                  pthread_mutex_lock (&h->big_lock));
      47           0 :   wo = TALER_FAKEBANK_lookup_withdrawal_operation_ (h,
      48             :                                                     withdrawal_id);
      49           0 :   if (NULL == wo)
      50             :   {
      51           0 :     GNUNET_assert (0 ==
      52             :                    pthread_mutex_unlock (&h->big_lock));
      53           0 :     return TALER_MHD_reply_with_error (connection,
      54             :                                        MHD_HTTP_NOT_FOUND,
      55             :                                        TALER_EC_BANK_TRANSACTION_NOT_FOUND,
      56             :                                        withdrawal_id);
      57             :   }
      58           0 :   acc = TALER_FAKEBANK_lookup_account_ (h,
      59             :                                         account_name,
      60             :                                         NULL);
      61           0 :   if (NULL == acc)
      62             :   {
      63           0 :     GNUNET_assert (0 ==
      64             :                    pthread_mutex_unlock (&h->big_lock));
      65           0 :     return TALER_MHD_reply_with_error (connection,
      66             :                                        MHD_HTTP_NOT_FOUND,
      67             :                                        TALER_EC_BANK_UNKNOWN_ACCOUNT,
      68             :                                        account_name);
      69             :   }
      70           0 :   if (wo->debit_account != acc)
      71             :   {
      72           0 :     GNUNET_assert (0 ==
      73             :                    pthread_mutex_unlock (&h->big_lock));
      74           0 :     return TALER_MHD_reply_with_error (connection,
      75             :                                        MHD_HTTP_NOT_FOUND,
      76             :                                        TALER_EC_BANK_TRANSACTION_NOT_FOUND,
      77             :                                        account_name);
      78             :   }
      79           0 :   GNUNET_assert (0 ==
      80             :                  pthread_mutex_unlock (&h->big_lock));
      81           0 :   return TALER_MHD_REPLY_JSON_PACK (
      82             :     connection,
      83             :     MHD_HTTP_OK,
      84             :     GNUNET_JSON_pack_bool ("aborted",
      85             :                            wo->aborted),
      86             :     GNUNET_JSON_pack_bool ("selection_done",
      87             :                            wo->selection_done),
      88             :     GNUNET_JSON_pack_bool ("transfer_done",
      89             :                            wo->confirmation_done),
      90             :     GNUNET_JSON_pack_allow_null (
      91             :       GNUNET_JSON_pack_string ("selected_exchange_account",
      92             :                                wo->exchange_account->payto_uri)),
      93             :     GNUNET_JSON_pack_allow_null (
      94             :       wo->selection_done
      95             :       ? GNUNET_JSON_pack_data_auto ("selected_reserve_pub",
      96             :                                     &wo->reserve_pub)
      97             :       : GNUNET_JSON_pack_string ("selected_reserve_pub",
      98             :                                  NULL)),
      99             :     GNUNET_JSON_pack_allow_null (
     100             :       TALER_JSON_pack_amount ("amount",
     101             :                               wo->amount)));
     102             : }

Generated by: LCOV version 1.16