LCOV - code coverage report
Current view: top level - testing - testing_api_trait_hash.c (source / functions) Hit Total Coverage
Test: GNU Taler merchant coverage report Lines: 10 10 100.0 %
Date: 2021-08-30 06:54:17 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2018 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_api_trait_hash.c
      21             :  * @brief offer any trait that is passed over as a hash code.
      22             :  * @author Marcello Stanisci
      23             :  */
      24             : #include "platform.h"
      25             : #include <taler/taler_signatures.h>
      26             : #include <taler/taler_exchange_service.h>
      27             : #include <taler/taler_testing_lib.h>
      28             : 
      29             : /**
      30             :  * FIXME: have _one_ pair of getter/setter for hash-coded
      31             :  * traits and define the getters/setters for tip id and hashed
      32             :  * contract terms as _macros_.
      33             :  */
      34             : 
      35             : #define TALER_TESTING_TRAIT_TIP_ID "tip-id"
      36             : #define TALER_TESTING_TRAIT_H_CONTRACT_TERMS "h-contract-terms"
      37             : 
      38             : int
      39          16 : TALER_TESTING_get_trait_tip_id
      40             :   (const struct TALER_TESTING_Command *cmd,
      41             :   unsigned int index,
      42             :   struct GNUNET_HashCode **tip_id)
      43             : {
      44          16 :   return cmd->traits (cmd->cls,
      45             :                       (const void **) tip_id,
      46             :                       TALER_TESTING_TRAIT_TIP_ID,
      47             :                       index);
      48             : }
      49             : 
      50             : 
      51             : struct TALER_TESTING_Trait
      52          33 : TALER_TESTING_make_trait_tip_id
      53             :   (unsigned int index,
      54             :   const struct GNUNET_HashCode *tip_id)
      55             : {
      56          33 :   struct TALER_TESTING_Trait ret = {
      57             :     .index = index,
      58             :     .trait_name = TALER_TESTING_TRAIT_TIP_ID,
      59             :     .ptr = (const void *) tip_id
      60             :   };
      61          33 :   return ret;
      62             : }
      63             : 
      64             : 
      65             : int
      66          40 : TALER_TESTING_get_trait_h_contract_terms
      67             :   (const struct TALER_TESTING_Command *cmd,
      68             :   unsigned int index,
      69             :   const struct GNUNET_HashCode **h_contract_terms)
      70             : {
      71          40 :   return cmd->traits (cmd->cls,
      72             :                       (const void **) h_contract_terms,
      73             :                       TALER_TESTING_TRAIT_H_CONTRACT_TERMS,
      74             :                       index);
      75             : }
      76             : 
      77             : 
      78             : struct TALER_TESTING_Trait
      79         259 : TALER_TESTING_make_trait_h_contract_terms
      80             :   (unsigned int index,
      81             :   const struct GNUNET_HashCode *h_contract_terms)
      82             : {
      83         259 :   struct TALER_TESTING_Trait ret = {
      84             :     .index = index,
      85             :     .trait_name = TALER_TESTING_TRAIT_H_CONTRACT_TERMS,
      86             :     .ptr = (const void *) h_contract_terms
      87             :   };
      88         259 :   return ret;
      89             : }

Generated by: LCOV version 1.14