diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-18 11:58:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-18 11:58:09 +0000 |
commit | ba7d316cff500d0bffee07994f970b80f811d089 (patch) | |
tree | f2447a588c89b775b0abc1f0c313b3f9a20eb872 /src/gnsrecord/test_gnsrecord_crypto.c | |
parent | fe41d052396d6d63c0ad3ff10852f3289418b0db (diff) | |
download | gnunet-ba7d316cff500d0bffee07994f970b80f811d089.tar.gz gnunet-ba7d316cff500d0bffee07994f970b80f811d089.zip |
-fix testcase to not use expired records
Diffstat (limited to 'src/gnsrecord/test_gnsrecord_crypto.c')
-rw-r--r-- | src/gnsrecord/test_gnsrecord_crypto.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c index 91bafdf21..89e65e69b 100644 --- a/src/gnsrecord/test_gnsrecord_crypto.c +++ b/src/gnsrecord/test_gnsrecord_crypto.c | |||
@@ -53,12 +53,12 @@ static struct GNUNET_GNSRECORD_Data * | |||
53 | create_record (int count) | 53 | create_record (int count) |
54 | { | 54 | { |
55 | unsigned int c; | 55 | unsigned int c; |
56 | struct GNUNET_GNSRECORD_Data * rd; | 56 | struct GNUNET_GNSRECORD_Data *rd; |
57 | 57 | ||
58 | rd = GNUNET_malloc (count * sizeof (struct GNUNET_GNSRECORD_Data)); | 58 | rd = GNUNET_malloc (count * sizeof (struct GNUNET_GNSRECORD_Data)); |
59 | for (c = 0; c < count; c++) | 59 | for (c = 0; c < count; c++) |
60 | { | 60 | { |
61 | rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us; | 61 | rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000; |
62 | rd[c].record_type = TEST_RECORD_TYPE; | 62 | rd[c].record_type = TEST_RECORD_TYPE; |
63 | rd[c].data_size = TEST_RECORD_DATALEN; | 63 | rd[c].data_size = TEST_RECORD_DATALEN; |
64 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); | 64 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); |
@@ -70,23 +70,21 @@ create_record (int count) | |||
70 | 70 | ||
71 | static void | 71 | static void |
72 | rd_decrypt_cb (void *cls, | 72 | rd_decrypt_cb (void *cls, |
73 | unsigned int rd_count, | 73 | unsigned int rd_count, |
74 | const struct GNUNET_GNSRECORD_Data *rd) | 74 | const struct GNUNET_GNSRECORD_Data *rd) |
75 | { | 75 | { |
76 | char rd_cmp_data[TEST_RECORD_DATALEN]; | 76 | char rd_cmp_data[TEST_RECORD_DATALEN]; |
77 | |||
78 | int c; | 77 | int c; |
79 | 78 | ||
80 | GNUNET_assert (RECORDS == rd_count); | 79 | GNUNET_assert (RECORDS == rd_count); |
81 | GNUNET_assert (NULL != rd); | 80 | GNUNET_assert (NULL != rd); |
82 | 81 | ||
83 | memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN); | 82 | memset (rd_cmp_data, 'a', TEST_RECORD_DATALEN); |
84 | |||
85 | for (c = 0; c < rd_count; c++) | 83 | for (c = 0; c < rd_count; c++) |
86 | { | 84 | { |
87 | GNUNET_assert (TEST_RECORD_TYPE == rd[c].record_type); | 85 | GNUNET_assert (TEST_RECORD_TYPE == rd[c].record_type); |
88 | GNUNET_assert (TEST_RECORD_DATALEN == rd[c].data_size); | 86 | GNUNET_assert (TEST_RECORD_DATALEN == rd[c].data_size); |
89 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[c].data, TEST_RECORD_DATALEN)); | 87 | GNUNET_assert (0 == memcmp (&rd_cmp_data, rd[c].data, TEST_RECORD_DATALEN)); |
90 | } | 88 | } |
91 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 89 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
92 | "Block was decrypted successfully \n"); | 90 | "Block was decrypted successfully \n"); |
@@ -103,9 +101,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
103 | 101 | ||
104 | /* load privat key */ | 102 | /* load privat key */ |
105 | char *hostkey_file; | 103 | char *hostkey_file; |
106 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 104 | GNUNET_asprintf(&hostkey_file, |
107 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 105 | "zonefiles%s%s", |
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 106 | DIR_SEPARATOR_STR, |
107 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | ||
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
109 | "Using zonekey file `%s'\n", | ||
110 | hostkey_file); | ||
109 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); | 111 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); |
110 | GNUNET_free (hostkey_file); | 112 | GNUNET_free (hostkey_file); |
111 | GNUNET_assert (privkey != NULL); | 113 | GNUNET_assert (privkey != NULL); |