LCOV - code coverage report
Current view: top level - testing - testing_api_trait_json.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 10 15 66.7 %
Date: 2021-08-30 06:43:37 Functions: 4 6 66.7 %
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 it
       6             :   under the terms of the GNU General Public License as published
       7             :   by the Free Software Foundation; either version 3, or (at your
       8             :   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 GNU
      13             :   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             : /**
      21             :  * @file testing/testing_api_trait_json.c
      22             :  * @brief offers JSON traits.
      23             :  * @author Marcello Stanisci
      24             :  */
      25             : #include "platform.h"
      26             : #include "taler_json_lib.h"
      27             : #include <gnunet/gnunet_curl_lib.h>
      28             : #include "taler_signatures.h"
      29             : #include "taler_testing_lib.h"
      30             : 
      31             : #define TALER_TESTING_TRAIT_WIRE_DETAILS "wire-details"
      32             : #define TALER_TESTING_TRAIT_EXCHANGE_KEYS "exchange-keys"
      33             : #define TALER_TESTING_TRAIT_JSON "json"
      34             : 
      35             : /**
      36             :  * Obtain serialized exchange keys from @a cmd.
      37             :  *
      38             :  * @param cmd command to extract the keys from.
      39             :  * @param index index number associate with the keys on offer.
      40             :  * @param[out] keys where to write the serialized keys.
      41             :  * @return #GNUNET_OK on success.
      42             :  */
      43             : int
      44           1 : TALER_TESTING_get_trait_exchange_keys
      45             :   (const struct TALER_TESTING_Command *cmd,
      46             :   unsigned int index,
      47             :   const json_t **keys)
      48             : {
      49           1 :   return cmd->traits (cmd->cls,
      50             :                       (const void **) keys,
      51             :                       TALER_TESTING_TRAIT_EXCHANGE_KEYS,
      52             :                       index);
      53             : }
      54             : 
      55             : 
      56             : /**
      57             :  * Offer serialized keys in a trait.
      58             :  *
      59             :  * @param index index number associate with the serial keys
      60             :  *        on offer.
      61             :  * @param keys serialized keys to offer.
      62             :  * @return the trait.
      63             :  */
      64             : struct TALER_TESTING_Trait
      65           2 : TALER_TESTING_make_trait_exchange_keys
      66             :   (unsigned int index,
      67             :   const json_t *keys)
      68             : {
      69           2 :   struct TALER_TESTING_Trait ret = {
      70             :     .index = index,
      71             :     .trait_name = TALER_TESTING_TRAIT_EXCHANGE_KEYS,
      72             :     .ptr = (const json_t *) keys
      73             :   };
      74           2 :   return ret;
      75             : }
      76             : 
      77             : 
      78             : /**
      79             :  * Obtain wire details from @a cmd.
      80             :  *
      81             :  * @param cmd command to extract the wire details from.
      82             :  * @param index index number associate with the wire details
      83             :  *        on offer; usually zero, as one command sticks to
      84             :  *        one bank account.
      85             :  * @param[out] wire_details where to write the wire details.
      86             :  * @return #GNUNET_OK on success.
      87             :  */
      88             : int
      89           4 : TALER_TESTING_get_trait_wire_details
      90             :   (const struct TALER_TESTING_Command *cmd,
      91             :   unsigned int index,
      92             :   const json_t **wire_details)
      93             : {
      94           4 :   return cmd->traits (cmd->cls,
      95             :                       (const void **) wire_details,
      96             :                       TALER_TESTING_TRAIT_WIRE_DETAILS,
      97             :                       index);
      98             : }
      99             : 
     100             : 
     101             : /**
     102             :  * Offer wire details in a trait.
     103             :  *
     104             :  * @param index index number associate with the wire details
     105             :  *        on offer; usually zero, as one command sticks to
     106             :  *        one bank account.
     107             :  * @param wire_details wire details to offer.
     108             :  * @return the trait.
     109             :  */
     110             : struct TALER_TESTING_Trait
     111         160 : TALER_TESTING_make_trait_wire_details
     112             :   (unsigned int index,
     113             :   const json_t *wire_details)
     114             : {
     115         160 :   struct TALER_TESTING_Trait ret = {
     116             :     .index = index,
     117             :     .trait_name = TALER_TESTING_TRAIT_WIRE_DETAILS,
     118             :     .ptr = (const json_t *) wire_details
     119             :   };
     120         160 :   return ret;
     121             : }
     122             : 
     123             : 
     124             : /**
     125             :  * Obtain json from @a cmd.
     126             :  *
     127             :  * @param cmd command to extract the json from.
     128             :  * @param index index number associate with the json on offer.
     129             :  * @param[out] json where to write the json.
     130             :  * @return #GNUNET_OK on success.
     131             :  */
     132             : int
     133           0 : TALER_TESTING_get_trait_json (const struct TALER_TESTING_Command *cmd,
     134             :                               unsigned int index,
     135             :                               const json_t **json)
     136             : {
     137           0 :   return cmd->traits (cmd->cls,
     138             :                       (const void **) json,
     139             :                       TALER_TESTING_TRAIT_JSON,
     140             :                       index);
     141             : }
     142             : 
     143             : 
     144             : /**
     145             :  * Offer json in a trait.
     146             :  *
     147             :  * @param index index number associate with the json
     148             :  *        on offer.
     149             :  * @param json json to offer.
     150             :  * @return the trait.
     151             :  */
     152             : struct TALER_TESTING_Trait
     153           0 : TALER_TESTING_make_trait_json (unsigned int index,
     154             :                                const json_t *json)
     155             : {
     156           0 :   struct TALER_TESTING_Trait ret = {
     157             :     .index = index,
     158             :     .trait_name = TALER_TESTING_TRAIT_JSON,
     159             :     .ptr = (const json_t *) json
     160             :   };
     161           0 :   return ret;
     162             : }
     163             : 
     164             : 
     165             : /* end of testing_api_trait_json.c */

Generated by: LCOV version 1.14