diff options
Diffstat (limited to 'src/merchant-tools/taler-merchant-generate-payments_new.c')
-rw-r--r-- | src/merchant-tools/taler-merchant-generate-payments_new.c | 237 |
1 files changed, 156 insertions, 81 deletions
diff --git a/src/merchant-tools/taler-merchant-generate-payments_new.c b/src/merchant-tools/taler-merchant-generate-payments_new.c index c30dd343..986ddc73 100644 --- a/src/merchant-tools/taler-merchant-generate-payments_new.c +++ b/src/merchant-tools/taler-merchant-generate-payments_new.c | |||
@@ -134,11 +134,139 @@ run (void *cls, | |||
134 | struct TALER_TESTING_Interpreter *is) | 134 | struct TALER_TESTING_Interpreter *is) |
135 | { | 135 | { |
136 | 136 | ||
137 | /* Currency strings. */ | ||
138 | char *CURRENCY_25_05; | ||
139 | char *CURRENCY_10; | ||
140 | char *CURRENCY_9_98; | ||
141 | char *CURRENCY_5; | ||
142 | char *CURRENCY_4_99; | ||
143 | char *CURRENCY_0_02; | ||
144 | char *CURRENCY_0_01; | ||
145 | |||
146 | GNUNET_asprintf (&CURRENCY_25_05, | ||
147 | "%s:25.05", | ||
148 | currency); | ||
149 | |||
150 | GNUNET_asprintf (&CURRENCY_10, | ||
151 | "%s:10", | ||
152 | currency); | ||
153 | |||
154 | GNUNET_asprintf (&CURRENCY_9_98, | ||
155 | "%s:9.98", | ||
156 | currency); | ||
157 | |||
158 | GNUNET_asprintf (&CURRENCY_5, | ||
159 | "%s:5", | ||
160 | currency); | ||
161 | |||
162 | GNUNET_asprintf (&CURRENCY_4_99, | ||
163 | "%s:4.99", | ||
164 | currency); | ||
165 | |||
166 | GNUNET_asprintf (&CURRENCY_0_02, | ||
167 | "%s:0.02", | ||
168 | currency); | ||
169 | |||
170 | GNUNET_asprintf (&CURRENCY_0_01, | ||
171 | "%s:0.01", | ||
172 | currency); | ||
173 | |||
174 | /* Orders. */ | ||
175 | char *order_worth_5; | ||
176 | char *order_worth_10_2coins; | ||
177 | char *order_worth_5_track; | ||
178 | char *order_worth_5_unaggregated; | ||
179 | |||
180 | GNUNET_asprintf | ||
181 | (&order_worth_5, | ||
182 | "{\"max_fee\":\ | ||
183 | {\"currency\":\"%s\",\ | ||
184 | \"value\":0,\ | ||
185 | \"fraction\":50000000},\ | ||
186 | \"refund_deadline\":\"\\/Date(0)\\/\",\ | ||
187 | \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ | ||
188 | \"amount\":\ | ||
189 | {\"currency\":\"%s\",\ | ||
190 | \"value\":5,\ | ||
191 | \"fraction\":0},\ | ||
192 | \"summary\": \"merchant-lib testcase\",\ | ||
193 | \"fulfillment_url\": \"https://example.com/\",\ | ||
194 | \"products\": [ {\"description\":\"ice cream\",\ | ||
195 | \"value\":\"{%s:5}\"} ]\ | ||
196 | }", | ||
197 | currency, | ||
198 | currency, | ||
199 | currency); | ||
200 | |||
201 | GNUNET_asprintf | ||
202 | (&order_worth_10_2coins, | ||
203 | "{\"max_fee\":\ | ||
204 | {\"currency\":\"%s\",\ | ||
205 | \"value\":0,\ | ||
206 | \"fraction\":50000000},\ | ||
207 | \"refund_deadline\":\"\\/Date(0)\\/\",\ | ||
208 | \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ | ||
209 | \"amount\":\ | ||
210 | {\"currency\":\"%s\",\ | ||
211 | \"value\":10,\ | ||
212 | \"fraction\":0},\ | ||
213 | \"summary\": \"2-coins untracked payment\",\ | ||
214 | \"fulfillment_url\": \"https://example.com/\",\ | ||
215 | \"products\": [ {\"description\":\"2-coins payment\",\ | ||
216 | \"value\":\"{%s:10}\"} ]\ | ||
217 | }", | ||
218 | currency, | ||
219 | currency, | ||
220 | currency); | ||
221 | |||
222 | GNUNET_asprintf | ||
223 | (&order_worth_5_track, | ||
224 | "{\"max_fee\":\ | ||
225 | {\"currency\":\"%s\",\ | ||
226 | \"value\":0,\ | ||
227 | \"fraction\":50000000},\ | ||
228 | \"refund_deadline\":\"\\/Date(0)\\/\",\ | ||
229 | \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ | ||
230 | \"amount\":\ | ||
231 | {\"currency\":\"%s\",\ | ||
232 | \"value\":5,\ | ||
233 | \"fraction\":0},\ | ||
234 | \"summary\": \"ice track cream!\",\ | ||
235 | \"fulfillment_url\": \"https://example.com/\",\ | ||
236 | \"products\": [ {\"description\":\"ice track cream\",\ | ||
237 | \"value\":\"{%s:5}\"} ]\ | ||
238 | }", | ||
239 | currency, | ||
240 | currency, | ||
241 | currency); | ||
242 | |||
243 | |||
244 | GNUNET_asprintf | ||
245 | (&order_worth_5_unaggregated, | ||
246 | "{\"max_fee\":\ | ||
247 | {\"currency\":\"%s\",\ | ||
248 | \"value\":0,\ | ||
249 | \"fraction\":50000000},\ | ||
250 | \"refund_deadline\":\"\\/Date(0)\\/\",\ | ||
251 | \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ | ||
252 | \"amount\":\ | ||
253 | {\"currency\":\"%s\",\ | ||
254 | \"value\":5,\ | ||
255 | \"fraction\":0},\ | ||
256 | \"summary\": \"unaggregated deposit!\",\ | ||
257 | \"fulfillment_url\": \"https://example.com/\",\ | ||
258 | \"products\": [ {\"description\":\"unaggregated cream\",\ | ||
259 | \"value\":\"{%s:5}\"} ]\ | ||
260 | }", | ||
261 | currency, | ||
262 | currency, | ||
263 | currency); | ||
264 | |||
137 | struct TALER_TESTING_Command commands[] = { | 265 | struct TALER_TESTING_Command commands[] = { |
138 | 266 | ||
139 | CMD_TRANSFER_TO_EXCHANGE | 267 | CMD_TRANSFER_TO_EXCHANGE |
140 | ("create-reserve-1", | 268 | ("create-reserve-1", |
141 | "USD:25.05"), | 269 | CURRENCY_25_05), |
142 | 270 | ||
143 | TALER_TESTING_cmd_exec_wirewatch | 271 | TALER_TESTING_cmd_exec_wirewatch |
144 | ("wirewatch-1", | 272 | ("wirewatch-1", |
@@ -148,14 +276,14 @@ run (void *cls, | |||
148 | ("withdraw-coin-1", | 276 | ("withdraw-coin-1", |
149 | is->exchange, // picks port from config's [exchange]. | 277 | is->exchange, // picks port from config's [exchange]. |
150 | "create-reserve-1", | 278 | "create-reserve-1", |
151 | "USD:5", | 279 | CURRENCY_5, |
152 | MHD_HTTP_OK), | 280 | MHD_HTTP_OK), |
153 | 281 | ||
154 | TALER_TESTING_cmd_withdraw_amount | 282 | TALER_TESTING_cmd_withdraw_amount |
155 | ("withdraw-coin-2", | 283 | ("withdraw-coin-2", |
156 | is->exchange, | 284 | is->exchange, |
157 | "create-reserve-1", | 285 | "create-reserve-1", |
158 | "USD:5", | 286 | CURRENCY_5, |
159 | MHD_HTTP_OK), | 287 | MHD_HTTP_OK), |
160 | 288 | ||
161 | /* This coin will be spent but never aggregated, | 289 | /* This coin will be spent but never aggregated, |
@@ -164,7 +292,7 @@ run (void *cls, | |||
164 | ("withdraw-coin-3", | 292 | ("withdraw-coin-3", |
165 | is->exchange, | 293 | is->exchange, |
166 | "create-reserve-1", | 294 | "create-reserve-1", |
167 | "USD:5", | 295 | CURRENCY_5, |
168 | MHD_HTTP_OK), | 296 | MHD_HTTP_OK), |
169 | 297 | ||
170 | /* coin 4 & 5 will be deposited for the same | 298 | /* coin 4 & 5 will be deposited for the same |
@@ -174,14 +302,14 @@ run (void *cls, | |||
174 | ("withdraw-coin-4", | 302 | ("withdraw-coin-4", |
175 | is->exchange, | 303 | is->exchange, |
176 | "create-reserve-1", | 304 | "create-reserve-1", |
177 | "USD:5", | 305 | CURRENCY_5, |
178 | MHD_HTTP_OK), | 306 | MHD_HTTP_OK), |
179 | 307 | ||
180 | TALER_TESTING_cmd_withdraw_amount | 308 | TALER_TESTING_cmd_withdraw_amount |
181 | ("withdraw-coin-5", | 309 | ("withdraw-coin-5", |
182 | is->exchange, | 310 | is->exchange, |
183 | "create-reserve-1", | 311 | "create-reserve-1", |
184 | "USD:5", | 312 | CURRENCY_5, |
185 | MHD_HTTP_OK), | 313 | MHD_HTTP_OK), |
186 | 314 | ||
187 | TALER_TESTING_cmd_proposal | 315 | TALER_TESTING_cmd_proposal |
@@ -189,21 +317,8 @@ run (void *cls, | |||
189 | merchant_url, | 317 | merchant_url, |
190 | is->ctx, | 318 | is->ctx, |
191 | MHD_HTTP_OK, | 319 | MHD_HTTP_OK, |
192 | "{\"max_fee\":\ | 320 | order_worth_5, |
193 | {\"currency\":\"USD\",\ | 321 | NULL), |
194 | \"value\":0,\ | ||
195 | \"fraction\":50000000},\ | ||
196 | \"refund_deadline\":\"\\/Date(0)\\/\",\ | ||
197 | \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ | ||
198 | \"amount\":\ | ||
199 | {\"currency\":\"USD\",\ | ||
200 | \"value\":5,\ | ||
201 | \"fraction\":0},\ | ||
202 | \"summary\": \"merchant-lib testcase\",\ | ||
203 | \"fulfillment_url\": \"https://example.com/\",\ | ||
204 | \"products\": [ {\"description\":\"ice cream\",\ | ||
205 | \"value\":\"{USD:5}\"} ] }", | ||
206 | NULL), | ||
207 | 322 | ||
208 | TALER_TESTING_cmd_pay | 323 | TALER_TESTING_cmd_pay |
209 | ("deposit-simple", | 324 | ("deposit-simple", |
@@ -212,9 +327,9 @@ run (void *cls, | |||
212 | MHD_HTTP_OK, | 327 | MHD_HTTP_OK, |
213 | "create-proposal-1", | 328 | "create-proposal-1", |
214 | "withdraw-coin-1", | 329 | "withdraw-coin-1", |
215 | "USD:5", | 330 | CURRENCY_5, |
216 | "USD:4.99", | 331 | CURRENCY_4_99, |
217 | "USD:0.01"), | 332 | CURRENCY_0_01), |
218 | 333 | ||
219 | TALER_TESTING_cmd_rewind_ip | 334 | TALER_TESTING_cmd_rewind_ip |
220 | ("rewind-payments", | 335 | ("rewind-payments", |
@@ -230,21 +345,8 @@ run (void *cls, | |||
230 | merchant_url, | 345 | merchant_url, |
231 | is->ctx, | 346 | is->ctx, |
232 | MHD_HTTP_OK, | 347 | MHD_HTTP_OK, |
233 | "{\"max_fee\":\ | 348 | order_worth_5_track, |
234 | {\"currency\":\"USD\",\ | 349 | NULL), |
235 | \"value\":0,\ | ||
236 | \"fraction\":50000000},\ | ||
237 | \"refund_deadline\":\"\\/Date(0)\\/\",\ | ||
238 | \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ | ||
239 | \"amount\":\ | ||
240 | {\"currency\":\"USD\",\ | ||
241 | \"value\":5,\ | ||
242 | \"fraction\":0},\ | ||
243 | \"summary\": \"merchant-lib testcase\",\ | ||
244 | \"fulfillment_url\": \"https://example.com/\",\ | ||
245 | \"products\": [ {\"description\":\"ice track cream\",\ | ||
246 | \"value\":\"{USD:5}\"} ] }", | ||
247 | NULL), | ||
248 | 350 | ||
249 | TALER_TESTING_cmd_pay | 351 | TALER_TESTING_cmd_pay |
250 | ("deposit-simple-2", | 352 | ("deposit-simple-2", |
@@ -253,9 +355,9 @@ run (void *cls, | |||
253 | MHD_HTTP_OK, | 355 | MHD_HTTP_OK, |
254 | "create-proposal-2", | 356 | "create-proposal-2", |
255 | "withdraw-coin-2", | 357 | "withdraw-coin-2", |
256 | "USD:5", | 358 | CURRENCY_5, |
257 | "USD:4.99", | 359 | CURRENCY_4_99, |
258 | "USD:0.01"), | 360 | CURRENCY_0_01), |
259 | 361 | ||
260 | /* /track/transaction over deposit-simple-2 */ | 362 | /* /track/transaction over deposit-simple-2 */ |
261 | 363 | ||
@@ -270,7 +372,7 @@ run (void *cls, | |||
270 | MHD_HTTP_OK, | 372 | MHD_HTTP_OK, |
271 | "dummy", // "check bank" CMD, never used, to be deleted. | 373 | "dummy", // "check bank" CMD, never used, to be deleted. |
272 | "deposit-simple-2", | 374 | "deposit-simple-2", |
273 | "USD:0.01"), | 375 | CURRENCY_0_01), |
274 | 376 | ||
275 | TALER_TESTING_cmd_merchant_track_transfer | 377 | TALER_TESTING_cmd_merchant_track_transfer |
276 | ("track-transfer-1", | 378 | ("track-transfer-1", |
@@ -293,21 +395,8 @@ run (void *cls, | |||
293 | merchant_url, | 395 | merchant_url, |
294 | is->ctx, | 396 | is->ctx, |
295 | MHD_HTTP_OK, | 397 | MHD_HTTP_OK, |
296 | "{\"max_fee\":\ | 398 | order_worth_10_2coins, |
297 | {\"currency\":\"USD\",\ | 399 | NULL), |
298 | \"value\":0,\ | ||
299 | \"fraction\":50000000},\ | ||
300 | \"refund_deadline\":\"\\/Date(0)\\/\",\ | ||
301 | \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ | ||
302 | \"amount\":\ | ||
303 | {\"currency\":\"USD\",\ | ||
304 | \"value\":10,\ | ||
305 | \"fraction\":0},\ | ||
306 | \"summary\": \"2-coins untracked payment\",\ | ||
307 | \"fulfillment_url\": \"https://example.com/\",\ | ||
308 | \"products\": [ {\"description\":\"2-coins payment\",\ | ||
309 | \"value\":\"{USD:10}\"} ] }", | ||
310 | NULL), | ||
311 | 400 | ||
312 | TALER_TESTING_cmd_pay ("deposit-4&5", | 401 | TALER_TESTING_cmd_pay ("deposit-4&5", |
313 | merchant_url, | 402 | merchant_url, |
@@ -316,9 +405,9 @@ run (void *cls, | |||
316 | "create-proposal-4&5", | 405 | "create-proposal-4&5", |
317 | "withdraw-coin-4;" \ | 406 | "withdraw-coin-4;" \ |
318 | "withdraw-coin-5", | 407 | "withdraw-coin-5", |
319 | "EUR:10", | 408 | CURRENCY_10, |
320 | "EUR:9.98", // no sense now | 409 | CURRENCY_9_98, // no sense now |
321 | "EUR:0.02"), // no sense now | 410 | CURRENCY_0_02), // no sense now |
322 | 411 | ||
323 | TALER_TESTING_cmd_exec_aggregator | 412 | TALER_TESTING_cmd_exec_aggregator |
324 | ("aggregate-2", | 413 | ("aggregate-2", |
@@ -330,21 +419,8 @@ run (void *cls, | |||
330 | merchant_url, | 419 | merchant_url, |
331 | is->ctx, | 420 | is->ctx, |
332 | MHD_HTTP_OK, | 421 | MHD_HTTP_OK, |
333 | "{\"max_fee\":\ | 422 | order_worth_5_unaggregated, |
334 | {\"currency\":\"USD\",\ | 423 | NULL), |
335 | \"value\":0,\ | ||
336 | \"fraction\":50000000},\ | ||
337 | \"refund_deadline\":\"\\/Date(0)\\/\",\ | ||
338 | \"pay_deadline\":\"\\/Date(99999999999)\\/\",\ | ||
339 | \"amount\":\ | ||
340 | {\"currency\":\"USD\",\ | ||
341 | \"value\":5,\ | ||
342 | \"fraction\":0},\ | ||
343 | \"summary\": \"unaggregated deposit!\",\ | ||
344 | \"fulfillment_url\": \"https://example.com/\",\ | ||
345 | \"products\": [ {\"description\":\"unaggregated cream\",\ | ||
346 | \"value\":\"{USD:5}\"} ] }", | ||
347 | NULL), | ||
348 | 424 | ||
349 | TALER_TESTING_cmd_pay | 425 | TALER_TESTING_cmd_pay |
350 | ("deposit-simple-3", | 426 | ("deposit-simple-3", |
@@ -353,9 +429,9 @@ run (void *cls, | |||
353 | MHD_HTTP_OK, | 429 | MHD_HTTP_OK, |
354 | "create-proposal-3", | 430 | "create-proposal-3", |
355 | "withdraw-coin-3", | 431 | "withdraw-coin-3", |
356 | "USD:5", | 432 | CURRENCY_5, |
357 | "USD:4.99", | 433 | CURRENCY_4_99, |
358 | "USD:0.01"), | 434 | CURRENCY_0_01), |
359 | 435 | ||
360 | TALER_TESTING_cmd_merchant_track_transaction | 436 | TALER_TESTING_cmd_merchant_track_transaction |
361 | ("track-transaction-2", | 437 | ("track-transaction-2", |
@@ -364,8 +440,7 @@ run (void *cls, | |||
364 | MHD_HTTP_ACCEPTED, | 440 | MHD_HTTP_ACCEPTED, |
365 | "dummy", // "check bank" CMD, never used, to be deleted. | 441 | "dummy", // "check bank" CMD, never used, to be deleted. |
366 | "deposit-simple-3", | 442 | "deposit-simple-3", |
367 | "USD:0.01"), | 443 | CURRENCY_0_01), |
368 | |||
369 | 444 | ||
370 | TALER_TESTING_cmd_rewind_ip | 445 | TALER_TESTING_cmd_rewind_ip |
371 | ("rewind-tracks", | 446 | ("rewind-tracks", |