LCOV - code coverage report
Current view: top level - testing - testing_api_cmd_bank_check_empty.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 62.5 % 24 15
Test Date: 2025-12-26 23:00:34 Functions: 100.0 % 4 4

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   Copyright (C) 2018-2020 Taler Systems SA
       4              : 
       5              :   TALER is free software; you can redistribute it and/or modify
       6              :   it under the terms of the GNU General Public License as
       7              :   published by the Free Software Foundation; either version 3, or
       8              :   (at your option) any later version.
       9              : 
      10              :   TALER is distributed in the hope that it will be useful, but
      11              :   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, see
      17              :   <http://www.gnu.org/licenses/>
      18              : */
      19              : /**
      20              :  * @file testing/testing_api_cmd_bank_check_empty.c
      21              :  * @brief command to check if a particular wire transfer took
      22              :  *        place.
      23              :  * @author Marcello Stanisci
      24              :  */
      25              : #include "taler/platform.h"
      26              : #include "taler/taler_json_lib.h"
      27              : #include <gnunet/gnunet_curl_lib.h>
      28              : #include "taler/taler_testing_lib.h"
      29              : #include "taler/taler_fakebank_lib.h"
      30              : 
      31              : 
      32              : /**
      33              :  * Cleanup the state, only defined to respect the API.
      34              :  *
      35              :  * @param cls closure.
      36              :  * @param cmd the command which is being cleaned up.
      37              :  */
      38              : static void
      39           40 : check_bank_empty_cleanup
      40              :   (void *cls,
      41              :   const struct TALER_TESTING_Command *cmd)
      42              : {
      43              :   (void) cls;
      44              :   (void) cmd;
      45           40 :   return;
      46              : }
      47              : 
      48              : 
      49              : /**
      50              :  * Run the command.
      51              :  *
      52              :  * @param cls closure.
      53              :  * @param cmd the command to execute.
      54              :  * @param is the interpreter state.
      55              :  */
      56              : static void
      57           40 : check_bank_empty_run (
      58              :   void *cls,
      59              :   const struct TALER_TESTING_Command *cmd,
      60              :   struct TALER_TESTING_Interpreter *is)
      61              : {
      62              :   struct TALER_FAKEBANK_Handle *fakebank;
      63              : 
      64              :   (void) cls;
      65              :   (void) cmd;
      66              :   {
      67              :     const struct TALER_TESTING_Command *fakebank_cmd;
      68              : 
      69              :     fakebank_cmd
      70           40 :       = TALER_TESTING_interpreter_get_command (is,
      71              :                                                "fakebank");
      72           40 :     if (NULL == fakebank_cmd)
      73              :     {
      74            0 :       GNUNET_break (0);
      75            0 :       TALER_TESTING_interpreter_fail (is);
      76            0 :       return;
      77              :     }
      78           40 :     if (GNUNET_OK !=
      79           40 :         TALER_TESTING_get_trait_fakebank (fakebank_cmd,
      80              :                                           &fakebank))
      81              :     {
      82            0 :       GNUNET_break (0);
      83            0 :       TALER_TESTING_interpreter_fail (is);
      84            0 :       return;
      85              :     }
      86              :   }
      87           40 :   if (GNUNET_OK !=
      88           40 :       TALER_FAKEBANK_check_empty (fakebank))
      89              :   {
      90            0 :     GNUNET_break (0);
      91            0 :     TALER_TESTING_interpreter_fail (is);
      92            0 :     return;
      93              :   }
      94           40 :   TALER_TESTING_interpreter_next (is);
      95              : }
      96              : 
      97              : 
      98              : /**
      99              :  * Some commands (notably "bank history") could randomly
     100              :  * look for traits; this way makes sure we don't segfault.
     101              :  */
     102              : static enum GNUNET_GenericReturnValue
     103           36 : check_bank_empty_traits (void *cls,
     104              :                          const void **ret,
     105              :                          const char *trait,
     106              :                          unsigned int index)
     107              : {
     108              :   (void) cls;
     109              :   (void) ret;
     110              :   (void) trait;
     111              :   (void) index;
     112           36 :   return GNUNET_SYSERR;
     113              : }
     114              : 
     115              : 
     116              : /**
     117              :  * Checks whether all the wire transfers got "checked"
     118              :  * by the "bank check" CMD.
     119              :  *
     120              :  * @param label command label.
     121              :  *
     122              :  * @return the command
     123              :  */
     124              : struct TALER_TESTING_Command
     125           40 : TALER_TESTING_cmd_check_bank_empty (const char *label)
     126              : {
     127           40 :   struct TALER_TESTING_Command cmd = {
     128              :     .label = label,
     129              :     .run = &check_bank_empty_run,
     130              :     .cleanup = &check_bank_empty_cleanup,
     131              :     .traits = &check_bank_empty_traits
     132              :   };
     133              : 
     134           40 :   return cmd;
     135              : }
        

Generated by: LCOV version 2.0-1