aboutsummaryrefslogtreecommitdiff
path: root/src/merchant-tools/taler-merchant-generate-payments_new.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/merchant-tools/taler-merchant-generate-payments_new.c')
-rw-r--r--src/merchant-tools/taler-merchant-generate-payments_new.c165
1 files changed, 88 insertions, 77 deletions
diff --git a/src/merchant-tools/taler-merchant-generate-payments_new.c b/src/merchant-tools/taler-merchant-generate-payments_new.c
index 986ddc73..b910d81f 100644
--- a/src/merchant-tools/taler-merchant-generate-payments_new.c
+++ b/src/merchant-tools/taler-merchant-generate-payments_new.c
@@ -127,58 +127,38 @@ static char *merchant_url;
127static char *currency; 127static char *currency;
128 128
129/** 129/**
130 * Actual commands collection. 130 * Convenience macros to allocate all the currency-dependant
131 * strings; note that the argument list of the macro is ignored.
132 * It is kept as a way to make the macro more auto-descriptive
133 * where it is called.
131 */ 134 */
132static void
133run (void *cls,
134 struct TALER_TESTING_Interpreter *is)
135{
136 135
137 /* Currency strings. */ 136#define ALLOCATE_AMOUNTS(...) \
138 char *CURRENCY_25_05; 137 GNUNET_asprintf (&CURRENCY_25_05, \
139 char *CURRENCY_10; 138 "%s:25.05", \
140 char *CURRENCY_9_98; 139 currency); \
141 char *CURRENCY_5; 140 GNUNET_asprintf (&CURRENCY_10, \
142 char *CURRENCY_4_99; 141 "%s:10", \
143 char *CURRENCY_0_02; 142 currency); \
144 char *CURRENCY_0_01; 143 GNUNET_asprintf (&CURRENCY_9_98, \
145 144 "%s:9.98", \
146 GNUNET_asprintf (&CURRENCY_25_05, 145 currency); \
147 "%s:25.05", 146 GNUNET_asprintf (&CURRENCY_5, \
148 currency); 147 "%s:5", \
149 148 currency); \
150 GNUNET_asprintf (&CURRENCY_10, 149 GNUNET_asprintf (&CURRENCY_4_99, \
151 "%s:10", 150 "%s:4.99", \
151 currency); \
152 GNUNET_asprintf (&CURRENCY_0_02, \
153 "%s:0.02", \
154 currency); \
155 GNUNET_asprintf (&CURRENCY_0_01, \
156 "%s:0.01", \
152 currency); 157 currency);
153 158
154 GNUNET_asprintf (&CURRENCY_9_98, 159#define ALLOCATE_ORDERS(...) \
155 "%s:9.98", 160 GNUNET_asprintf \
156 currency); 161 (&order_worth_5, \
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\":\ 162 "{\"max_fee\":\
183 {\"currency\":\"%s\",\ 163 {\"currency\":\"%s\",\
184 \"value\":0,\ 164 \"value\":0,\
@@ -192,14 +172,12 @@ run (void *cls,
192 \"summary\": \"merchant-lib testcase\",\ 172 \"summary\": \"merchant-lib testcase\",\
193 \"fulfillment_url\": \"https://example.com/\",\ 173 \"fulfillment_url\": \"https://example.com/\",\
194 \"products\": [ {\"description\":\"ice cream\",\ 174 \"products\": [ {\"description\":\"ice cream\",\
195 \"value\":\"{%s:5}\"} ]\ 175 \"value\":\"{%s:5}\"} ] }", \
196 }", 176 currency, \
197 currency, 177 currency, \
198 currency, 178 currency); \
199 currency); 179 GNUNET_asprintf \
200 180 (&order_worth_10_2coins, \
201 GNUNET_asprintf
202 (&order_worth_10_2coins,
203 "{\"max_fee\":\ 181 "{\"max_fee\":\
204 {\"currency\":\"%s\",\ 182 {\"currency\":\"%s\",\
205 \"value\":0,\ 183 \"value\":0,\
@@ -213,14 +191,12 @@ run (void *cls,
213 \"summary\": \"2-coins untracked payment\",\ 191 \"summary\": \"2-coins untracked payment\",\
214 \"fulfillment_url\": \"https://example.com/\",\ 192 \"fulfillment_url\": \"https://example.com/\",\
215 \"products\": [ {\"description\":\"2-coins payment\",\ 193 \"products\": [ {\"description\":\"2-coins payment\",\
216 \"value\":\"{%s:10}\"} ]\ 194 \"value\":\"{%s:10}\"} ] }", \
217 }", 195 currency, \
218 currency, 196 currency, \
219 currency, 197 currency); \
220 currency); 198 GNUNET_asprintf \
221 199 (&order_worth_5_track, \
222 GNUNET_asprintf
223 (&order_worth_5_track,
224 "{\"max_fee\":\ 200 "{\"max_fee\":\
225 {\"currency\":\"%s\",\ 201 {\"currency\":\"%s\",\
226 \"value\":0,\ 202 \"value\":0,\
@@ -234,15 +210,12 @@ run (void *cls,
234 \"summary\": \"ice track cream!\",\ 210 \"summary\": \"ice track cream!\",\
235 \"fulfillment_url\": \"https://example.com/\",\ 211 \"fulfillment_url\": \"https://example.com/\",\
236 \"products\": [ {\"description\":\"ice track cream\",\ 212 \"products\": [ {\"description\":\"ice track cream\",\
237 \"value\":\"{%s:5}\"} ]\ 213 \"value\":\"{%s:5}\"} ] }", \
238 }", 214 currency, \
239 currency, 215 currency, \
240 currency, 216 currency); \
241 currency); 217 GNUNET_asprintf \
242 218 (&order_worth_5_unaggregated, \
243
244 GNUNET_asprintf
245 (&order_worth_5_unaggregated,
246 "{\"max_fee\":\ 219 "{\"max_fee\":\
247 {\"currency\":\"%s\",\ 220 {\"currency\":\"%s\",\
248 \"value\":0,\ 221 \"value\":0,\
@@ -256,12 +229,50 @@ run (void *cls,
256 \"summary\": \"unaggregated deposit!\",\ 229 \"summary\": \"unaggregated deposit!\",\
257 \"fulfillment_url\": \"https://example.com/\",\ 230 \"fulfillment_url\": \"https://example.com/\",\
258 \"products\": [ {\"description\":\"unaggregated cream\",\ 231 \"products\": [ {\"description\":\"unaggregated cream\",\
259 \"value\":\"{%s:5}\"} ]\ 232 \"value\":\"{%s:5}\"} ] }", \
260 }", 233 currency, \
261 currency, 234 currency, \
262 currency,
263 currency); 235 currency);
264 236
237/**
238 * Actual commands collection.
239 */
240static void
241run (void *cls,
242 struct TALER_TESTING_Interpreter *is)
243{
244
245 /* Currency strings. */
246 char *CURRENCY_25_05;
247 char *CURRENCY_10;
248 char *CURRENCY_9_98;
249 char *CURRENCY_5;
250 char *CURRENCY_4_99;
251 char *CURRENCY_0_02;
252 char *CURRENCY_0_01;
253
254 ALLOCATE_AMOUNTS
255 (CURRENCY_25_05,
256 CURRENCY_10,
257 CURRENCY_9_98,
258 CURRENCY_5,
259 CURRENCY_4_99,
260 CURRENCY_0_02,
261 CURRENCY_0_01);
262
263
264 /* Orders. */
265 char *order_worth_5;
266 char *order_worth_10_2coins;
267 char *order_worth_5_track;
268 char *order_worth_5_unaggregated;
269
270 ALLOCATE_ORDERS
271 (order_worth_5,
272 order_worth_10_2coins,
273 order_worth_5_track,
274 order_worth_5_unaggregated);
275
265 struct TALER_TESTING_Command commands[] = { 276 struct TALER_TESTING_Command commands[] = {
266 277
267 CMD_TRANSFER_TO_EXCHANGE 278 CMD_TRANSFER_TO_EXCHANGE