LCOV - code coverage report
Current view: top level - testing - testing_api_trait_time.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 5 10 50.0 %
Date: 2021-08-30 06:43:37 Functions: 2 4 50.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 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_time.c
      22             :  * @brief traits to offer time stamps.
      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_TIME_ABS "time-abs"
      32             : #define TALER_TESTING_TRAIT_TIME_REL "time-rel"
      33             : 
      34             : /**
      35             :  * Obtain a absolute time from @a cmd.
      36             :  *
      37             :  * @param cmd command to extract trait from
      38             :  * @param index which time stamp to pick if
      39             :  *        @a cmd has multiple on offer.
      40             :  * @param[out] time set to the wanted WTID.
      41             :  * @return #GNUNET_OK on success
      42             :  */
      43             : int
      44           2 : TALER_TESTING_get_trait_absolute_time
      45             :   (const struct TALER_TESTING_Command *cmd,
      46             :   unsigned int index,
      47             :   const struct GNUNET_TIME_Absolute **time)
      48             : {
      49           2 :   return cmd->traits (cmd->cls,
      50             :                       (const void **) time,
      51             :                       TALER_TESTING_TRAIT_TIME_ABS,
      52             :                       index);
      53             : }
      54             : 
      55             : 
      56             : /**
      57             :  * Offer a absolute time.
      58             :  *
      59             :  * @param index associate the object with this index
      60             :  * @param time which object should be returned
      61             :  * @return the trait.
      62             :  */
      63             : struct TALER_TESTING_Trait
      64        1277 : TALER_TESTING_make_trait_absolute_time
      65             :   (unsigned int index,
      66             :   const struct GNUNET_TIME_Absolute *time)
      67             : {
      68        1277 :   struct TALER_TESTING_Trait ret = {
      69             :     .index = index,
      70             :     .trait_name = TALER_TESTING_TRAIT_TIME_ABS,
      71             :     .ptr = (const void *) time
      72             :   };
      73        1277 :   return ret;
      74             : }
      75             : 
      76             : 
      77             : /**
      78             :  * Obtain a relative time from @a cmd.
      79             :  *
      80             :  * @param cmd command to extract trait from
      81             :  * @param index which time to pick if
      82             :  *        @a cmd has multiple on offer.
      83             :  * @param[out] time set to the wanted WTID.
      84             :  * @return #GNUNET_OK on success
      85             :  */
      86             : int
      87           0 : TALER_TESTING_get_trait_relative_time (
      88             :   const struct TALER_TESTING_Command *cmd,
      89             :   unsigned int index,
      90             :   const struct GNUNET_TIME_Relative **time)
      91             : {
      92           0 :   return cmd->traits (cmd->cls,
      93             :                       (const void **) time,
      94             :                       TALER_TESTING_TRAIT_TIME_REL,
      95             :                       index);
      96             : }
      97             : 
      98             : 
      99             : /**
     100             :  * Offer a relative time.
     101             :  *
     102             :  * @param index associate the object with this index
     103             :  * @param time which object should be returned
     104             :  * @return the trait.
     105             :  */
     106             : struct TALER_TESTING_Trait
     107           0 : TALER_TESTING_make_trait_relative_time (
     108             :   unsigned int index,
     109             :   const struct GNUNET_TIME_Relative *time)
     110             : {
     111           0 :   struct TALER_TESTING_Trait ret = {
     112             :     .index = index,
     113             :     .trait_name = TALER_TESTING_TRAIT_TIME_REL,
     114             :     .ptr = (const void *) time
     115             :   };
     116           0 :   return ret;
     117             : }
     118             : 
     119             : 
     120             : /* end of testing_api_trait_time.c */

Generated by: LCOV version 1.14