From 65808106c7d7ddad9420338f3fde139ec0c9295e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 20 Mar 2022 15:42:16 +0100 Subject: add test for reserve GET long polling --- src/testing/testing_api_cmd_reserve_get.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/testing/testing_api_cmd_reserve_get.c') diff --git a/src/testing/testing_api_cmd_reserve_get.c b/src/testing/testing_api_cmd_reserve_get.c index 3e590f4bc..b4375ee20 100644 --- a/src/testing/testing_api_cmd_reserve_get.c +++ b/src/testing/testing_api_cmd_reserve_get.c @@ -33,6 +33,11 @@ struct PollState { + /** + * How long do we give the exchange to respond? + */ + struct GNUNET_TIME_Relative timeout; + /** * Label to the command which created the reserve to check, * needed to resort the reserve key. @@ -331,7 +336,7 @@ finish_run (void *cls, } GNUNET_assert (NULL == ss->ps); ss->ps = ps; - ps->tt = GNUNET_SCHEDULER_add_delayed (ss->timeout, + ps->tt = GNUNET_SCHEDULER_add_delayed (ps->timeout, &finish_timeout, ps); } @@ -347,29 +352,31 @@ static void finish_cleanup (void *cls, const struct TALER_TESTING_Command *cmd) { - struct PollState *ss = cls; + struct PollState *ps = cls; - if (NULL != ss->tt) + if (NULL != ps->tt) { - GNUNET_SCHEDULER_cancel (ss->tt); - ss->tt = NULL; + GNUNET_SCHEDULER_cancel (ps->tt); + ps->tt = NULL; } - GNUNET_free (ss); + GNUNET_free (ps); } struct TALER_TESTING_Command TALER_TESTING_cmd_reserve_poll_finish (const char *label, + struct GNUNET_TIME_Relative timeout, const char *poll_reference) { - struct PollState *ss; + struct PollState *ps; GNUNET_assert (NULL != poll_reference); - ss = GNUNET_new (struct PollState); - ss->poll_reference = poll_reference; + ps = GNUNET_new (struct PollState); + ps->timeout = timeout; + ps->poll_reference = poll_reference; { struct TALER_TESTING_Command cmd = { - .cls = ss, + .cls = ps, .label = label, .run = &finish_run, .cleanup = &finish_cleanup -- cgit v1.2.3