From f2ec9c08b024dc1ee3dc2cd968d928e2672bc214 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Mon, 22 Jun 2020 03:13:10 -0400 Subject: testing traits for uint32_t and GNUNET_TIME_Relative --- src/testing/testing_api_trait_time.c | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/testing/testing_api_trait_time.c') diff --git a/src/testing/testing_api_trait_time.c b/src/testing/testing_api_trait_time.c index c77489bfa..207246bed 100644 --- a/src/testing/testing_api_trait_time.c +++ b/src/testing/testing_api_trait_time.c @@ -29,6 +29,7 @@ #include "taler_testing_lib.h" #define TALER_TESTING_TRAIT_TIME_ABS "time-abs" +#define TALER_TESTING_TRAIT_TIME_REL "time-rel" /** * Obtain a absolute time from @a cmd. @@ -73,4 +74,47 @@ TALER_TESTING_make_trait_absolute_time } +/** + * Obtain a relative time from @a cmd. + * + * @param cmd command to extract trait from + * @param index which time to pick if + * @a cmd has multiple on offer. + * @param[out] time set to the wanted WTID. + * @return #GNUNET_OK on success + */ +int +TALER_TESTING_get_trait_relative_time ( + const struct TALER_TESTING_Command *cmd, + unsigned int index, + const struct GNUNET_TIME_Relative **time) +{ + return cmd->traits (cmd->cls, + (const void **) time, + TALER_TESTING_TRAIT_TIME_REL, + index); +} + + +/** + * Offer a relative time. + * + * @param index associate the object with this index + * @param time which object should be returned + * @return the trait. + */ +struct TALER_TESTING_Trait +TALER_TESTING_make_trait_relative_time ( + unsigned int index, + const struct GNUNET_TIME_Relative *time) +{ + struct TALER_TESTING_Trait ret = { + .index = index, + .trait_name = TALER_TESTING_TRAIT_TIME_REL, + .ptr = (const void *) time + }; + return ret; +} + + /* end of testing_api_trait_time.c */ -- cgit v1.2.3