summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Summermatter <elias.summermatter@seccom.ch>2021-03-18 16:07:40 +0100
committerElias Summermatter <elias.summermatter@seccom.ch>2021-03-18 16:07:40 +0100
commitc4ccd75504124e816264597fe21c892b33919819 (patch)
tree351a2de1468abe9ed7a5a0359768b593c8d72a70
parentf9ae0c23ccd894f6422b0b21841cd65c01e831d3 (diff)
Setu tests use gnunet internal functions to generate randum elements
-rw-r--r--src/setu/test_setu_api.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/setu/test_setu_api.c b/src/setu/test_setu_api.c
index bfef88908..02c5ddf87 100644
--- a/src/setu/test_setu_api.c
+++ b/src/setu/test_setu_api.c
@@ -210,12 +210,8 @@ init_set2 (void *cls)
unsigned char *gen_rdm_bytestream (size_t num_bytes)
{
- unsigned char *stream = malloc (num_bytes);
- size_t i;
- for (i = 0; i < num_bytes; i++)
- {
- stream[i] = rand ();
- }
+ unsigned char *stream = GNUNET_malloc (num_bytes);
+ GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, stream, sizeof(stream));
return stream;
}
@@ -253,12 +249,15 @@ initRandomSets(int overlap, int set1_size, int set2_size, int element_size_in_by
while(set2_size > 0) {
element.data = gen_rdm_bytestream(element_size_in_bytes);
element.size = strlen (element.data);
- GNUNET_SETU_add_element (set2, &element,NULL, NULL);
+
+ if(set2_size != 1) {
+ GNUNET_SETU_add_element (set2, &element,NULL, NULL);
+ } else {
+ GNUNET_SETU_add_element (set2, &element,&start, NULL);
+ }
+
set2_size--;
}
- element.data = gen_rdm_bytestream(element_size_in_bytes);
- element.size = strlen (element.data);
- GNUNET_SETU_add_element (set2, &element,&start, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "initialized elements in set2\n");
}