summaryrefslogtreecommitdiff
path: root/src/gnsrecord/test_gnsrecord_block_expiration.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnsrecord/test_gnsrecord_block_expiration.c')
-rw-r--r--src/gnsrecord/test_gnsrecord_block_expiration.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/gnsrecord/test_gnsrecord_block_expiration.c b/src/gnsrecord/test_gnsrecord_block_expiration.c
index 1a9dbc105..24aa3d921 100644
--- a/src/gnsrecord/test_gnsrecord_block_expiration.c
+++ b/src/gnsrecord/test_gnsrecord_block_expiration.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20/** 20/**
21 * @file gnsrecord/test_gnsrecord_crypto.c 21 * @file gnsrecord/test_gnsrecord_crypto.c
22 * @brief testcase for block creation, verification and decryption 22 * @brief testcase for block creation, verification and decryption
@@ -44,17 +44,17 @@ static int res;
44 44
45 45
46static void 46static void
47run (void *cls, char *const *args, const char *cfgfile, 47run(void *cls, char *const *args, const char *cfgfile,
48 const struct GNUNET_CONFIGURATION_Handle *cfg) 48 const struct GNUNET_CONFIGURATION_Handle *cfg)
49{ 49{
50 struct GNUNET_GNSRECORD_Data rd[2]; 50 struct GNUNET_GNSRECORD_Data rd[2];
51 struct GNUNET_TIME_Absolute expiration_abs; 51 struct GNUNET_TIME_Absolute expiration_abs;
52 struct GNUNET_TIME_Absolute expiration_abs_shadow; 52 struct GNUNET_TIME_Absolute expiration_abs_shadow;
53 53
54 expiration_abs.abs_value_us = GNUNET_TIME_absolute_get().abs_value_us + 54 expiration_abs.abs_value_us = GNUNET_TIME_absolute_get().abs_value_us +
55 GNUNET_TIME_UNIT_SECONDS.rel_value_us; 55 GNUNET_TIME_UNIT_SECONDS.rel_value_us;
56 expiration_abs_shadow.abs_value_us = GNUNET_TIME_absolute_get().abs_value_us + 56 expiration_abs_shadow.abs_value_us = GNUNET_TIME_absolute_get().abs_value_us +
57 GNUNET_TIME_UNIT_MINUTES.rel_value_us; 57 GNUNET_TIME_UNIT_MINUTES.rel_value_us;
58 58
59 /* create record */ 59 /* create record */
60 rd[0].expiration_time = expiration_abs.abs_value_us; 60 rd[0].expiration_time = expiration_abs.abs_value_us;
@@ -62,42 +62,41 @@ run (void *cls, char *const *args, const char *cfgfile,
62 rd[0].data_size = TEST_RECORD_DATALEN; 62 rd[0].data_size = TEST_RECORD_DATALEN;
63 rd[0].data = GNUNET_malloc(TEST_RECORD_DATALEN); 63 rd[0].data = GNUNET_malloc(TEST_RECORD_DATALEN);
64 rd[0].flags = GNUNET_GNSRECORD_RF_NONE; 64 rd[0].flags = GNUNET_GNSRECORD_RF_NONE;
65 memset ((char *) rd[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 65 memset((char *)rd[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
66 66
67 rd[1].expiration_time = expiration_abs.abs_value_us; 67 rd[1].expiration_time = expiration_abs.abs_value_us;
68 rd[1].record_type = TEST_RECORD_TYPE; 68 rd[1].record_type = TEST_RECORD_TYPE;
69 rd[1].data_size = TEST_RECORD_DATALEN; 69 rd[1].data_size = TEST_RECORD_DATALEN;
70 rd[1].data = GNUNET_malloc(TEST_RECORD_DATALEN); 70 rd[1].data = GNUNET_malloc(TEST_RECORD_DATALEN);
71 rd[1].flags = GNUNET_GNSRECORD_RF_NONE; 71 rd[1].flags = GNUNET_GNSRECORD_RF_NONE;
72 memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 72 memset((char *)rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
73 73
74 GNUNET_assert (expiration_abs.abs_value_us == GNUNET_GNSRECORD_record_get_expiration_time(2, rd).abs_value_us); 74 GNUNET_assert(expiration_abs.abs_value_us == GNUNET_GNSRECORD_record_get_expiration_time(2, rd).abs_value_us);
75 75
76 rd[1].expiration_time = expiration_abs_shadow.abs_value_us; 76 rd[1].expiration_time = expiration_abs_shadow.abs_value_us;
77 rd[1].record_type = TEST_RECORD_TYPE; 77 rd[1].record_type = TEST_RECORD_TYPE;
78 rd[1].data_size = TEST_RECORD_DATALEN; 78 rd[1].data_size = TEST_RECORD_DATALEN;
79 rd[1].data = GNUNET_malloc(TEST_RECORD_DATALEN); 79 rd[1].data = GNUNET_malloc(TEST_RECORD_DATALEN);
80 rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW_RECORD; 80 rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW_RECORD;
81 memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 81 memset((char *)rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
82 82
83 GNUNET_assert (expiration_abs_shadow.abs_value_us == GNUNET_GNSRECORD_record_get_expiration_time(2, rd).abs_value_us); 83 GNUNET_assert(expiration_abs_shadow.abs_value_us == GNUNET_GNSRECORD_record_get_expiration_time(2, rd).abs_value_us);
84 res = 0; 84 res = 0;
85} 85}
86 86
87 87
88int 88int
89main (int argc, char *argv[]) 89main(int argc, char *argv[])
90{ 90{
91 static char *const argvx[] = { "test-gnsrecord-crypto", 91 static char *const argvx[] = { "test-gnsrecord-crypto",
92 NULL 92 NULL };
93 };
94 static struct GNUNET_GETOPT_CommandLineOption options[] = { 93 static struct GNUNET_GETOPT_CommandLineOption options[] = {
95 GNUNET_GETOPT_OPTION_END 94 GNUNET_GETOPT_OPTION_END
96 }; 95 };
97 96
98 res = 1; 97 res = 1;
99 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, "test-namestore-api", 98 GNUNET_PROGRAM_run((sizeof(argvx) / sizeof(char *)) - 1, argvx, "test-namestore-api",
100 "nohelp", options, &run, &res); 99 "nohelp", options, &run, &res);
101 return res; 100 return res;
102} 101}
103 102