aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_trait_hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_trait_hash.c')
-rw-r--r--src/testing/testing_api_trait_hash.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/testing/testing_api_trait_hash.c b/src/testing/testing_api_trait_hash.c
new file mode 100644
index 0000000..18be1ea
--- /dev/null
+++ b/src/testing/testing_api_trait_hash.c
@@ -0,0 +1,72 @@
1/*
2 This file is part of TALER
3 Copyright (C) 2019 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 * @file lib/testing_api_trait_hash.c
21 * @brief traits to offer a hash
22 * @author Christian Grothoff
23 */
24#include "platform.h"
25#include "anastasis_testing_lib.h"
26
27#define ANASTASIS_TESTING_TRAIT_HASH "anastasis-hash"
28
29
30/**
31 * Obtain a hash from @a cmd.
32 *
33 * @param cmd command to extract the number from.
34 * @param index the number's index number.
35 * @param n[out] set to the number coming from @a cmd.
36 * @return #GNUNET_OK on success.
37 */
38int
39ANASTASIS_TESTING_get_trait_hash
40 (const struct TALER_TESTING_Command *cmd,
41 unsigned int index,
42 const struct GNUNET_HashCode **h)
43{
44 return cmd->traits (cmd->cls,
45 (const void **) h,
46 ANASTASIS_TESTING_TRAIT_HASH,
47 index);
48}
49
50
51/**
52 * Offer a hash.
53 *
54 * @param index the number's index number.
55 * @param h the hash to offer.
56 * @return #GNUNET_OK on success.
57 */
58struct TALER_TESTING_Trait
59ANASTASIS_TESTING_make_trait_hash
60 (unsigned int index,
61 const struct GNUNET_HashCode *h)
62{
63 struct TALER_TESTING_Trait ret = {
64 .index = index,
65 .trait_name = ANASTASIS_TESTING_TRAIT_HASH,
66 .ptr = (const void *) h
67 };
68 return ret;
69}
70
71
72/* end of testing_api_trait_hash.c */