summaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-21 16:45:27 +0100
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-21 16:45:27 +0100
commit9e1f3ef55b86baa796b8bc650dbecdb8d17be9cf (patch)
tree6e3b20d07fc1057fb28efd3dde8eab150318b616 /src/transport/transport-testing2.c
parent783a12b3c32a1b68ef1bf308066cf2a57f26c0f7 (diff)
-towards tng tests
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r--src/transport/transport-testing2.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index ca338c52f..374d78f67 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -335,9 +335,15 @@ hello_iter_cb (void *cb_cls,
const char *emsg)
{
struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cb_cls;
+ if ((NULL == record) && (NULL == emsg))
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n");
+ return;
+ }
//Check record type et al?
- p->hello = GNUNET_malloc (record->value_size);
- memcpy (p->hello, record->value, record->value_size);
+ p->hello_size = record->value_size;
+ p->hello = GNUNET_malloc (p->hello_size);
+ memcpy (p->hello, record->value, p->hello_size);
GNUNET_PEERSTORE_iterate_cancel (p->pic);
if (NULL != p->start_cb)
@@ -351,6 +357,23 @@ hello_iter_cb (void *cb_cls,
}
}
+static void
+retrieve_hello(void *cls)
+{
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Getting hello...\n");
+
+ p->pic = GNUNET_PEERSTORE_iterate (p->ph,
+ "transport",
+ &p->id,
+ GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
+ hello_iter_cb,
+ p);
+
+}
+
+
/**
* Start a peer with the given configuration
@@ -507,13 +530,15 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct
GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
- p->pic = GNUNET_PEERSTORE_iterate (p->ph,
- "transport",
- &p->id,
- GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
- hello_iter_cb,
- p);
- GNUNET_assert (NULL != p->pic);
+ p->ph = GNUNET_PEERSTORE_connect (p->cfg);
+ // FIXME Error handling
+ p->ah = GNUNET_TRANSPORT_application_init (p->cfg);
+ GNUNET_assert (NULL != p->ah);
+ // FIXME Error handleing
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ retrieve_hello,
+ p);
+ //GNUNET_assert (NULL != p->pic);
return p;
}
@@ -739,18 +764,18 @@ offer_hello (void *cls)
GNUNET_i2s (&p1->id),
p2->no,
p2_s,
- cc->p2->hello);
+ p2->hello);
GNUNET_free (p2_s);
}
- addr = GNUNET_HELLO_extract_address (cc->p2->hello,
- cc->p2->hello_size,
- &cc->p2->id,
+ addr = GNUNET_HELLO_extract_address (p2->hello,
+ strlen (p2->hello),
+ &p2->id,
&nt,
&t);
- GNUNET_assert (NULL == addr);
- GNUNET_TRANSPORT_application_validate (cc->p1->ah,
- &cc->p2->id,
+ GNUNET_assert (NULL != addr);
+ GNUNET_TRANSPORT_application_validate (p1->ah,
+ &p2->id,
nt,
addr);
GNUNET_free (addr);