summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast/dir/tests
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2021-12-27 12:57:50 +0100
committerSander Vrijders <[email protected]>2021-12-29 09:12:20 +0100
commitebf1b0c7415f394712c8dd71ae8c8e6821fd5fa3 (patch)
tree8a976b5541b97617b7edece8329754acaa5ed48c /src/ipcpd/unicast/dir/tests
parent0a0c244b9939059b86d304dd127763fed7d10af4 (diff)
downloadouroboros-ebf1b0c7415f394712c8dd71ae8c8e6821fd5fa3.tar.gz
ouroboros-ebf1b0c7415f394712c8dd71ae8c8e6821fd5fa3.zip
ipcpd: Allow creation of multiple directories
To allow merging large network layers, a situation will arise where multiple directories need to coexist within the layer. This reverts commit 9422e6be94ac1007e8115a920379fd545055e531. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd/unicast/dir/tests')
-rw-r--r--src/ipcpd/unicast/dir/tests/dht_test.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/ipcpd/unicast/dir/tests/dht_test.c b/src/ipcpd/unicast/dir/tests/dht_test.c
index 70773ea7..3f4c3b87 100644
--- a/src/ipcpd/unicast/dir/tests/dht_test.c
+++ b/src/ipcpd/unicast/dir/tests/dht_test.c
@@ -23,7 +23,6 @@
#define __DHT_TEST__
#define DHT_TEST_KEY_LEN 32
-
#include "dht.c"
#include <pthread.h>
@@ -31,45 +30,49 @@
#include <stdlib.h>
#include <stdio.h>
-#define CONTACTS 1000
+#define CONTACTS 1000
int dht_test(int argc,
char ** argv)
{
+ struct dht * dht;
uint8_t key[DHT_TEST_KEY_LEN];
size_t i;
(void) argc;
(void) argv;
- if (dht_init() < 0) {
+ dht = dht_create();
+ if (dht == NULL) {
printf("Failed to create dht.\n");
return -1;
}
- dht_fini();
+ dht_destroy(dht);
- if (dht_init() < 0) {
+ dht = dht_create();
+ if (dht == NULL) {
printf("Failed to re-create dht.\n");
return -1;
}
- if (dht_bootstrap()) {
+ if (dht_bootstrap(dht)) {
printf("Failed to bootstrap dht.\n");
- dht_fini();
+ dht_destroy(dht);
return -1;
}
- dht_fini();
+ dht_destroy(dht);
- if (dht_init() < 0) {
+ dht = dht_create();
+ if (dht == NULL) {
printf("Failed to re-create dht.\n");
return -1;
}
- if (dht_bootstrap()) {
+ if (dht_bootstrap(dht)) {
printf("Failed to bootstrap dht.\n");
- dht_fini();
+ dht_destroy(dht);
return -1;
}
@@ -77,17 +80,17 @@ int dht_test(int argc,
uint64_t addr;
random_buffer(&addr, sizeof(addr));
random_buffer(key, DHT_TEST_KEY_LEN);
- pthread_rwlock_wrlock(&dht.lock);
- if (dht_update_bucket(key, addr)) {
- pthread_rwlock_unlock(&dht.lock);
+ pthread_rwlock_wrlock(&dht->lock);
+ if (dht_update_bucket(dht, key, addr)) {
+ pthread_rwlock_unlock(&dht->lock);
printf("Failed to update bucket.\n");
- dht_fini();
+ dht_destroy(dht);
return -1;
}
- pthread_rwlock_unlock(&dht.lock);
+ pthread_rwlock_unlock(&dht->lock);
}
- dht_fini();
+ dht_destroy(dht);
return 0;
}