aboutsummaryrefslogtreecommitdiff
path: root/src/lib/testing_api_cmd_history.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/testing_api_cmd_history.c')
-rw-r--r--src/lib/testing_api_cmd_history.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/lib/testing_api_cmd_history.c b/src/lib/testing_api_cmd_history.c
index 48dd05ff..51368ba7 100644
--- a/src/lib/testing_api_cmd_history.c
+++ b/src/lib/testing_api_cmd_history.c
@@ -43,17 +43,17 @@ struct HistoryState
43 unsigned int http_status; 43 unsigned int http_status;
44 44
45 /** 45 /**
46 * The merchant instance. 46 * The merchant instance executing this CMD.
47 */ 47 */
48 const char *instance; 48 const char *instance;
49 49
50 /** 50 /**
51 * URL of the merchant backend. 51 * URL of the merchant backend serving the /history request.
52 */ 52 */
53 const char *merchant_url; 53 const char *merchant_url;
54 54
55 /** 55 /**
56 * The curl context. 56 * The CURL context.
57 */ 57 */
58 struct GNUNET_CURL_Context *ctx; 58 struct GNUNET_CURL_Context *ctx;
59 59
@@ -63,27 +63,29 @@ struct HistoryState
63 struct TALER_TESTING_Interpreter *is; 63 struct TALER_TESTING_Interpreter *is;
64 64
65 /** 65 /**
66 * Handle to /history. 66 * Handle to the /history operation.
67 */ 67 */
68 struct TALER_MERCHANT_HistoryOperation *ho; 68 struct TALER_MERCHANT_HistoryOperation *ho;
69 69
70 /** 70 /**
71 * FIXME 71 * Only history entries younger than this
72 * value will be returned.
72 */ 73 */
73 struct GNUNET_TIME_Absolute time; 74 struct GNUNET_TIME_Absolute time;
74 75
75 /** 76 /**
76 * FIXME 77 * First row index we want in the results.
77 */ 78 */
78 unsigned int start; 79 unsigned int start;
79 80
80 /** 81 /**
81 * FIXME 82 * How many rows we want the response to contain, at most.
82 */ 83 */
83 unsigned int nrows; 84 unsigned int nrows;
84 85
85 /** 86 /**
86 * FIXME 87 * Expected number of history entries returned by the
88 * backend.
87 */ 89 */
88 unsigned int nresult; 90 unsigned int nresult;
89}; 91};
@@ -93,7 +95,8 @@ struct HistoryState
93 * 95 *
94 * @param root the json object representing data 96 * @param root the json object representing data
95 * @param[out] ret where to write the data 97 * @param[out] ret where to write the data
96 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error 98 * @return #GNUNET_OK upon successful parsing;
99 * #GNUNET_SYSERR upon error
97 */ 100 */
98static int 101static int
99parse_abs_time (json_t *root, 102parse_abs_time (json_t *root,
@@ -125,7 +128,8 @@ parse_abs_time (json_t *root,
125 GNUNET_break_op (0); 128 GNUNET_break_op (0);
126 return GNUNET_SYSERR; 129 return GNUNET_SYSERR;
127 } 130 }
128 /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */ 131 /* Time is in seconds in JSON, but in microseconds in
132 * GNUNET_TIME_Absolute */
129 ret->abs_value_us = tval * 1000LL * 1000LL; 133 ret->abs_value_us = tval * 1000LL * 1000LL;
130 if ( (ret->abs_value_us) / 1000LL / 1000LL != tval) 134 if ( (ret->abs_value_us) / 1000LL / 1000LL != tval)
131 { 135 {
@@ -138,15 +142,15 @@ parse_abs_time (json_t *root,
138 142
139 143
140/** 144/**
141 * Callback for a /history request. It's up to this function 145 * Callback for a /history request; checks that (1) HTTP status
142 * how to render the array containing transactions details (FIXME 146 * is expected, the number of rows returned is expected, and that
143 * link to documentation) 147 * the rows are sorted from the youngest to the oldest record.
144 * 148 *
145 * @param cls closure 149 * @param cls closure
146 * @param http_status HTTP status returned by the merchant 150 * @param http_status HTTP status returned by the merchant
147 * backend 151 * backend
148 * @param ec taler-specific error code 152 * @param ec taler-specific error code
149 * @param json actual body containing history 153 * @param json actual body containing the history
150 */ 154 */
151static void 155static void
152history_cb (void *cls, 156history_cb (void *cls,
@@ -213,10 +217,11 @@ history_cb (void *cls,
213} 217}
214 218
215/** 219/**
216 * Clean up after the command. Run during forced termination 220 * Free the state for a "history" CMD, and possibly cancel
217 * (CTRL-C) or test failure or test success. 221 * any pending operation thereof.
218 * 222 *
219 * @param cls closure 223 * @param cls closure
224 * @param cmd command being freed now.
220 */ 225 */
221static void 226static void
222history_cleanup (void *cls, 227history_cleanup (void *cls,
@@ -234,14 +239,11 @@ history_cleanup (void *cls,
234} 239}
235 240
236/** 241/**
237 * Runs the command. Note that upon return, the interpreter 242 * Run a "history" CMD.
238 * will not automatically run the next command, as the command
239 * may continue asynchronously in other scheduler tasks. Thus,
240 * the command must ensure to eventually call
241 * #TALER_TESTING_interpreter_next() or
242 * #TALER_TESTING_interpreter_fail().
243 * 243 *
244 * @param is interpreter state 244 * @param cls closure.
245 * @param cmd current command.
246 * @param is interpreter state.
245 */ 247 */
246static void 248static void
247history_run (void *cls, 249history_run (void *cls,
@@ -274,13 +276,15 @@ history_run (void *cls,
274/** 276/**
275 * Make a "history" command. 277 * Make a "history" command.
276 * 278 *
277 * @param label command label 279 * @param label command label.
278 * @param merchant_url merchant base URL 280 * @param merchant_url base URL of the merchant serving the
279 * @param ctx main CURL context 281 * request.
282 * @param ctx CURL context.
280 * @param http_status expected HTTP response code 283 * @param http_status expected HTTP response code
281 * @param time FIXME 284 * @param time limit towards the past for the history
285 * records we want returned.
282 * @param nresult how many results are expected 286 * @param nresult how many results are expected
283 * @param start FIXME. 287 * @param start first row id we want in the result.
284 * @param nrows how many row we want to receive, at most. 288 * @param nrows how many row we want to receive, at most.
285 */ 289 */
286struct TALER_TESTING_Command 290struct TALER_TESTING_Command