1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
|
/*
This file is part of TALER
Copyright (C) 2018-2022 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your
option) any later version.
TALER is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with TALER; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
/**
* @file testing/testing_api_cmd_refresh.c
* @brief commands for testing all "refresh" features.
* @author Marcello Stanisci
*/
#include "platform.h"
#include "taler_json_lib.h"
#include <gnunet/gnunet_curl_lib.h>
#include "taler_testing_lib.h"
#include "taler_signatures.h"
#include "backoff.h"
/**
* How long do we wait AT MOST when retrying?
*/
#define MAX_BACKOFF GNUNET_TIME_relative_multiply ( \
GNUNET_TIME_UNIT_MILLISECONDS, 100)
/**
* How often do we retry before giving up?
*/
#define NUM_RETRIES 5
/**
* How long do we wait AT MOST when retrying?
*/
#define MAX_BACKOFF GNUNET_TIME_relative_multiply ( \
GNUNET_TIME_UNIT_MILLISECONDS, 100)
/**
* Information about a fresh coin generated by the refresh
* operation.
*/
struct TALER_TESTING_FreshCoinData
{
/**
* If @e amount is NULL, this specifies the denomination key to
* use. Otherwise, this will be set (by the interpreter) to the
* denomination PK matching @e amount.
*/
const struct TALER_EXCHANGE_DenomPublicKey *pk;
/**
* Set (by the interpreter) to the exchange's signature over the
* coin's public key.
*/
struct TALER_DenominationSignature sig;
/**
* Set (by the interpreter) to the coin's private key.
*/
struct TALER_CoinSpendPrivateKeyP coin_priv;
/*
* Fresh age commitment for the coin with proof and its hash, NULL if not
* applicable.
*/
struct TALER_AgeCommitmentProof *age_commitment_proof;
struct TALER_AgeCommitmentHash *h_age_commitment;
/**
* The blinding key (needed for recoup operations).
*/
union TALER_DenominationBlindingKeyP blinding_key;
};
/**
* State for a "refresh melt" command.
*/
struct RefreshMeltState
{
/**
* Reference to reserve_withdraw operations for coin to
* be used for the /refresh/melt operation.
*/
const char *coin_reference;
/**
* Data used in the refresh operation.
*/
struct TALER_EXCHANGE_RefreshData refresh_data;
/**
* Reference to a previous melt command.
*/
const char *melt_reference;
/**
* Melt handle while operation is running.
*/
struct TALER_EXCHANGE_MeltHandle *rmh;
/**
* Interpreter state.
*/
struct TALER_TESTING_Interpreter *is;
/**
* Array of the denomination public keys
* corresponding to the @e num_fresh_coins;
*/
struct TALER_EXCHANGE_DenomPublicKey *fresh_pks;
/**
* Array of @e num_fresh_coins of results from
* the melt operation.
*/
struct TALER_EXCHANGE_MeltBlindingDetail *mbds;
/**
* Entropy seed for the refresh-melt operation.
*/
struct TALER_RefreshMasterSecretP rms;
/**
* Private key of the dirty coin being melted.
*/
const struct TALER_CoinSpendPrivateKeyP *melt_priv;
/**
* Task scheduled to try later.
*/
struct GNUNET_SCHEDULER_Task *retry_task;
/**
* How long do we wait until we retry?
*/
struct GNUNET_TIME_Relative backoff;
/**
* How long did we wait in total for retries?
*/
struct GNUNET_TIME_Relative total_backoff;
/**
* Amounts to be generated during melt.
*/
const char **melt_fresh_amounts;
/**
* Number of fresh coins generated by the melt.
*/
unsigned int num_fresh_coins;
/**
* Expected HTTP response code.
*/
unsigned int expected_response_code;
/**
* if set to #GNUNET_YES, then two /refresh/melt operations
* will be performed. This is needed to trigger the logic
* that manages those already-made requests. Note: it
* is not possible to just copy-and-paste a test refresh melt
* CMD to have the same effect, because every data preparation
* generates new planchets that (in turn) make the whole "hash"
* different from any previous one, therefore NOT allowing the
* exchange to pick any previous /rerfesh/melt operation from
* the database.
*/
bool double_melt;
/**
* How often should we retry on (transient) failures?
*/
unsigned int do_retry;
/**
* Set by the melt callback as it comes from the exchange.
*/
uint16_t noreveal_index;
};
/**
* State for a "refresh reveal" CMD.
*/
struct RefreshRevealState
{
/**
* Link to a "refresh melt" command.
*/
const char *melt_reference;
/**
* Reveal handle while operation is running.
*/
struct TALER_EXCHANGE_RefreshesRevealHandle *rrh;
/**
* Convenience struct to keep in one place all the
* data related to one fresh coin, set by the reveal callback
* as it comes from the exchange.
*/
struct TALER_TESTING_FreshCoinData *fresh_coins;
/**
* Array of @e num_fresh_coins planchet secrets derived
* from the transfer secret per fresh coin.
*/
struct TALER_PlanchetMasterSecretP *psa;
/**
* Interpreter state.
*/
struct TALER_TESTING_Interpreter *is;
/**
* Task scheduled to try later.
*/
struct GNUNET_SCHEDULER_Task *retry_task;
/**
* How long do we wait until we retry?
*/
struct GNUNET_TIME_Relative backoff;
/**
* How long did we wait in total for retries?
*/
struct GNUNET_TIME_Relative total_backoff;
/**
* Number of fresh coins withdrawn, set by the
* reveal callback as it comes from the exchange,
* it is the length of the @e fresh_coins array.
*/
unsigned int num_fresh_coins;
/**
* Expected HTTP response code.
*/
unsigned int expected_response_code;
/**
* How often should we retry on (transient) failures?
*/
unsigned int do_retry;
};
/**
* State for a "refresh link" CMD.
*/
struct RefreshLinkState
{
/**
* Link to a "refresh reveal" command.
*/
const char *reveal_reference;
/**
* Handle to the ongoing operation.
*/
struct TALER_EXCHANGE_LinkHandle *rlh;
/**
* Interpreter state.
*/
struct TALER_TESTING_Interpreter *is;
/**
* Task scheduled to try later.
*/
struct GNUNET_SCHEDULER_Task *retry_task;
/**
* How long do we wait until we retry?
*/
struct GNUNET_TIME_Relative backoff;
/**
* How long did we wait in total for retries?
*/
struct GNUNET_TIME_Relative total_backoff;
/**
* Expected HTTP response code.
*/
unsigned int expected_response_code;
/**
* How often should we retry on (transient) failures?
*/
unsigned int do_retry;
};
/**
* Run the command.
*
* @param cls closure.
* @param cmd the command to execute.
* @param is the interpreter state.
*/
static void
refresh_reveal_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is);
/**
* Task scheduled to re-try #refresh_reveal_run.
*
* @param cls a `struct RefreshRevealState`
*/
static void
do_reveal_retry (void *cls)
{
struct RefreshRevealState *rrs = cls;
rrs->retry_task = NULL;
rrs->is->commands[rrs->is->ip].last_req_time
= GNUNET_TIME_absolute_get ();
refresh_reveal_run (rrs,
NULL,
rrs->is);
}
/**
* "refresh reveal" request callback; it checks that the response
* code is expected and copies into its command's state the data
* coming from the exchange, namely the fresh coins.
*
* @param cls closure, a `struct RefreshRevealState`
* @param hr HTTP response details
* @param num_coins number of fresh coins created, length of the
* @a sigs and @a coin_privs arrays, 0 if the operation
* failed.
* @param coin_privs array of @a num_coins private keys for the
* coins that were created, NULL on error.
* @param psa array of @a num_coins planchet secrets (derived from the transfer secret) for each of the coins
* @param sigs array of signature over @a num_coins coins,
* NULL on error.
*/
static void
reveal_cb (void *cls,
const struct TALER_EXCHANGE_RevealResult *rr)
{
struct RefreshRevealState *rrs = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &rr->hr;
const struct TALER_TESTING_Command *melt_cmd;
rrs->rrh = NULL;
if (rrs->expected_response_code != hr->http_status)
{
if (0 != rrs->do_retry)
{
rrs->do_retry--;
if ( (0 == hr->http_status) ||
(TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying refresh reveal failed with %u/%d\n",
hr->http_status,
(int) hr->ec);
/* on DB conflicts, do not use backoff */
if (TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec)
rrs->backoff = GNUNET_TIME_UNIT_ZERO;
else
rrs->backoff = GNUNET_TIME_randomized_backoff (rrs->backoff,
MAX_BACKOFF);
rrs->total_backoff = GNUNET_TIME_relative_add (rrs->total_backoff,
rrs->backoff);
rrs->is->commands[rrs->is->ip].num_tries++;
rrs->retry_task = GNUNET_SCHEDULER_add_delayed (rrs->backoff,
&do_reveal_retry,
rrs);
return;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d to command %s in %s:%u\n",
hr->http_status,
(int) hr->ec,
rrs->is->commands[rrs->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (rrs->is);
return;
}
melt_cmd = TALER_TESTING_interpreter_lookup_command (rrs->is,
rrs->melt_reference);
if (NULL == melt_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rrs->is);
return;
}
switch (hr->http_status)
{
case MHD_HTTP_OK:
rrs->num_fresh_coins = rr->details.success.num_coins;
rrs->psa = GNUNET_new_array (rrs->num_fresh_coins,
struct TALER_PlanchetMasterSecretP);
rrs->fresh_coins = GNUNET_new_array (rrs->num_fresh_coins,
struct TALER_TESTING_FreshCoinData);
for (unsigned int i = 0; i<rrs->num_fresh_coins; i++)
{
const struct TALER_EXCHANGE_RevealedCoinInfo *coin
= &rr->details.success.coins[i];
struct TALER_TESTING_FreshCoinData *fc = &rrs->fresh_coins[i];
rrs->psa[i] = coin->ps;
fc->blinding_key = coin->bks;
if (GNUNET_OK !=
TALER_TESTING_get_trait_denom_pub (melt_cmd,
i,
&fc->pk))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rrs->is);
return;
}
fc->coin_priv = coin->coin_priv;
fc->age_commitment_proof = coin->age_commitment_proof;
fc->h_age_commitment = coin->h_age_commitment;
TALER_denom_sig_deep_copy (&fc->sig,
&coin->sig);
}
if (0 != rrs->total_backoff.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Total reveal backoff for %s was %s\n",
rrs->is->commands[rrs->is->ip].label,
GNUNET_STRINGS_relative_time_to_string (rrs->total_backoff,
GNUNET_YES));
}
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Unknown HTTP status %u/%d\n",
hr->http_status,
(int) hr->ec);
}
TALER_TESTING_interpreter_next (rrs->is);
}
/**
* Run the command.
*
* @param cls closure.
* @param cmd the command to execute.
* @param is the interpreter state.
*/
static void
refresh_reveal_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is)
{
struct RefreshRevealState *rrs = cls;
struct RefreshMeltState *rms;
const struct TALER_TESTING_Command *melt_cmd;
rrs->is = is;
melt_cmd = TALER_TESTING_interpreter_lookup_command (is,
rrs->melt_reference);
if (NULL == melt_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rrs->is);
return;
}
// FIXME: use trait for 'rms'!
rms = melt_cmd->cls;
{
struct TALER_ExchangeWithdrawValues alg_values[rms->num_fresh_coins];
for (unsigned int i = 0; i<rms->num_fresh_coins; i++)
alg_values[i] = rms->mbds[i].alg_value;
rrs->rrh = TALER_EXCHANGE_refreshes_reveal (is->exchange,
&rms->rms,
&rms->refresh_data,
rms->num_fresh_coins,
alg_values,
rms->noreveal_index,
&reveal_cb,
rrs);
}
if (NULL == rrs->rrh)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
}
/**
* Free the state from a "refresh reveal" CMD, and possibly
* cancel a pending operation thereof.
*
* @param cls closure.
* @param cmd the command which is being cleaned up.
*/
static void
refresh_reveal_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd)
{
struct RefreshRevealState *rrs = cls;
(void) cmd;
if (NULL != rrs->rrh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
rrs->is->ip,
cmd->label);
TALER_EXCHANGE_refreshes_reveal_cancel (rrs->rrh);
rrs->rrh = NULL;
}
if (NULL != rrs->retry_task)
{
GNUNET_SCHEDULER_cancel (rrs->retry_task);
rrs->retry_task = NULL;
}
for (unsigned int j = 0; j < rrs->num_fresh_coins; j++)
TALER_denom_sig_free (&rrs->fresh_coins[j].sig);
GNUNET_free (rrs->fresh_coins);
GNUNET_free (rrs->psa);
rrs->num_fresh_coins = 0;
GNUNET_free (rrs);
}
/**
* Run the command.
*
* @param cls closure.
* @param cmd the command to execute.
* @param is the interpreter state.
*/
static void
refresh_link_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is);
/**
* Task scheduled to re-try #refresh_link_run.
*
* @param cls a `struct RefreshLinkState`
*/
static void
do_link_retry (void *cls)
{
struct RefreshLinkState *rls = cls;
rls->retry_task = NULL;
rls->is->commands[rls->is->ip].last_req_time
= GNUNET_TIME_absolute_get ();
refresh_link_run (rls,
NULL,
rls->is);
}
/**
* "refresh link" operation callback, checks that HTTP response
* code is expected _and_ that all the linked coins were actually
* withdrawn by the "refresh reveal" CMD.
*
* @param cls closure.
* @param hr HTTP response details
* @param num_coins number of fresh coins created, length of the
* @a sigs and @a coin_privs arrays, 0 if the operation
* failed.
* @param coin_privs array of @a num_coins private keys for the
* coins that were created, NULL on error.
* @param sigs array of signature over @a num_coins coins, NULL on
* error.
* @param pubs array of public keys for the @a sigs,
* NULL on error.
*/
static void
link_cb (void *cls,
const struct TALER_EXCHANGE_LinkResult *lr)
{
struct RefreshLinkState *rls = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &lr->hr;
const struct TALER_TESTING_Command *reveal_cmd;
struct TALER_TESTING_Command *link_cmd = &rls->is->commands[rls->is->ip];
unsigned int found;
const unsigned int *num_fresh_coins;
rls->rlh = NULL;
if (rls->expected_response_code != hr->http_status)
{
if (0 != rls->do_retry)
{
rls->do_retry--;
if ( (0 == hr->http_status) ||
(TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying refresh link failed with %u/%d\n",
hr->http_status,
(int) hr->ec);
/* on DB conflicts, do not use backoff */
if (TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec)
rls->backoff = GNUNET_TIME_UNIT_ZERO;
else
rls->backoff = GNUNET_TIME_randomized_backoff (rls->backoff,
MAX_BACKOFF);
rls->total_backoff = GNUNET_TIME_relative_add (rls->total_backoff,
rls->backoff);
rls->is->commands[rls->is->ip].num_tries++;
rls->retry_task = GNUNET_SCHEDULER_add_delayed (rls->backoff,
&do_link_retry,
rls);
return;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d to command %s in %s:%u\n",
hr->http_status,
(int) hr->ec,
link_cmd->label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
rls->reveal_reference);
if (NULL == reveal_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
switch (hr->http_status)
{
case MHD_HTTP_OK:
/* check that number of coins returned matches */
if (GNUNET_OK !=
TALER_TESTING_get_trait_array_length (reveal_cmd,
&num_fresh_coins))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
if (lr->details.success.num_coins != *num_fresh_coins)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected number of fresh coins: %d vs %d in %s:%u\n",
lr->details.success.num_coins,
*num_fresh_coins,
__FILE__,
__LINE__);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
/* check that the coins match */
for (unsigned int i = 0; i<lr->details.success.num_coins; i++)
for (unsigned int j = i + 1; j<lr->details.success.num_coins; j++)
if (0 ==
GNUNET_memcmp (&lr->details.success.coins[i].coin_priv,
&lr->details.success.coins[j].coin_priv))
GNUNET_break (0);
/* Note: coins might be legitimately permutated in here... */
found = 0;
/* Will point to the pointer inside the cmd state. */
{
const struct TALER_TESTING_FreshCoinData **fc = NULL;
if (GNUNET_OK !=
TALER_TESTING_get_trait_fresh_coins (reveal_cmd,
&fc))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
for (unsigned int i = 0; i<lr->details.success.num_coins; i++)
{
const struct TALER_EXCHANGE_LinkedCoinInfo *lci_i
= &lr->details.success.coins[i];
for (unsigned int j = 0; j<lr->details.success.num_coins; j++)
{
const struct TALER_TESTING_FreshCoinData *fcj
= &(*fc)[j];
if ( (0 ==
GNUNET_memcmp (&fcj->coin_priv,
&lci_i->coin_priv)) &&
(0 ==
TALER_denom_sig_cmp (&fcj->sig,
&lci_i->sig)) &&
(0 ==
TALER_denom_pub_cmp (&fcj->pk->key,
&lci_i->pub)) )
{
found++;
break;
}
} /* for j*/
} /* for i */
}
if (found != lr->details.success.num_coins)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Only %u/%u coins match expectations\n",
found,
lr->details.success.num_coins);
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
if (0 != rls->total_backoff.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Total link backoff for %s was %s\n",
rls->is->commands[rls->is->ip].label,
GNUNET_STRINGS_relative_time_to_string (rls->total_backoff,
GNUNET_YES));
}
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unknown HTTP response code %u/%d.\n",
hr->http_status,
hr->ec);
}
TALER_TESTING_interpreter_next (rls->is);
}
/**
* Run the command.
*
* @param cls closure.
* @param cmd the command to execute.
* @param is the interpreter state.
*/
static void
refresh_link_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is)
{
struct RefreshLinkState *rls = cls;
struct RefreshRevealState *rrs;
struct RefreshMeltState *rms;
const struct TALER_TESTING_Command *reveal_cmd;
const struct TALER_TESTING_Command *melt_cmd;
const struct TALER_TESTING_Command *coin_cmd;
(void) cmd;
rls->is = is;
reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
rls->reveal_reference);
if (NULL == reveal_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
rrs = reveal_cmd->cls;
melt_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
rrs->melt_reference);
if (NULL == melt_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
/* find reserve_withdraw command */
{
// FIXME: use trait!
rms = melt_cmd->cls;
coin_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
rms->coin_reference);
if (NULL == coin_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
}
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
if (GNUNET_OK !=
TALER_TESTING_get_trait_coin_priv (coin_cmd,
0,
&coin_priv))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
/* finally, use private key from withdraw sign command */
rls->rlh = TALER_EXCHANGE_link (is->exchange,
coin_priv,
rms->refresh_data.melt_age_commitment_proof,
&link_cb,
rls);
if (NULL == rls->rlh)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
return;
}
}
/**
* Free the state of the "refresh link" CMD, and possibly
* cancel a operation thereof.
*
* @param cls closure
* @param cmd the command which is being cleaned up.
*/
static void
refresh_link_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd)
{
struct RefreshLinkState *rls = cls;
if (NULL != rls->rlh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
rls->is->ip,
cmd->label);
TALER_EXCHANGE_link_cancel (rls->rlh);
rls->rlh = NULL;
}
if (NULL != rls->retry_task)
{
GNUNET_SCHEDULER_cancel (rls->retry_task);
rls->retry_task = NULL;
}
GNUNET_free (rls);
}
/**
* Run the command.
*
* @param cls closure.
* @param cmd the command to execute.
* @param is the interpreter state.
*/
static void
melt_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is);
/**
* Task scheduled to re-try #melt_run.
*
* @param cls a `struct RefreshMeltState`
*/
static void
do_melt_retry (void *cls)
{
struct RefreshMeltState *rms = cls;
rms->retry_task = NULL;
rms->is->commands[rms->is->ip].last_req_time
= GNUNET_TIME_absolute_get ();
melt_run (rms,
NULL,
rms->is);
}
/**
* Callback for a "refresh melt" operation; checks if the HTTP
* response code is okay and re-run the melt operation if the
* CMD was set to do so.
*
* @param cls closure.
* @param mr melt response details
*/
static void
melt_cb (void *cls,
const struct TALER_EXCHANGE_MeltResponse *mr)
{
struct RefreshMeltState *rms = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &mr->hr;
rms->rmh = NULL;
if (rms->expected_response_code != hr->http_status)
{
if (0 != rms->do_retry)
{
rms->do_retry--;
if ( (0 == hr->http_status) ||
(TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == hr->http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying refresh melt failed with %u/%d\n",
hr->http_status,
(int) hr->ec);
/* on DB conflicts, do not use backoff */
if (TALER_EC_GENERIC_DB_SOFT_FAILURE == hr->ec)
rms->backoff = GNUNET_TIME_UNIT_ZERO;
else
rms->backoff = GNUNET_TIME_randomized_backoff (rms->backoff,
MAX_BACKOFF);
rms->total_backoff = GNUNET_TIME_relative_add (rms->total_backoff,
rms->backoff);
rms->is->commands[rms->is->ip].num_tries++;
rms->retry_task = GNUNET_SCHEDULER_add_delayed (rms->backoff,
&do_melt_retry,
rms);
return;
}
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d to command %s in %s:%u\n",
hr->http_status,
(int) hr->ec,
rms->is->commands[rms->is->ip].label,
__FILE__,
__LINE__);
json_dumpf (hr->reply,
stderr,
0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
if (MHD_HTTP_OK == hr->http_status)
{
rms->noreveal_index = mr->details.success.noreveal_index;
if (mr->details.success.num_mbds != rms->num_fresh_coins)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
GNUNET_free (rms->mbds);
rms->mbds = GNUNET_memdup (mr->details.success.mbds,
mr->details.success.num_mbds
* sizeof (struct
TALER_EXCHANGE_MeltBlindingDetail));
}
if (0 != rms->total_backoff.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Total melt backoff for %s was %s\n",
rms->is->commands[rms->is->ip].label,
GNUNET_STRINGS_relative_time_to_string (rms->total_backoff,
GNUNET_YES));
}
if (rms->double_melt)
{
TALER_LOG_DEBUG ("Doubling the melt (%s)\n",
rms->is->commands[rms->is->ip].label);
rms->rmh = TALER_EXCHANGE_melt (rms->is->exchange,
&rms->rms,
&rms->refresh_data,
&melt_cb,
rms);
rms->double_melt = false;
return;
}
TALER_TESTING_interpreter_next (rms->is);
}
/**
* Run the command.
*
* @param cls closure.
* @param cmd the command to execute.
* @param is the interpreter state.
*/
static void
melt_run (void *cls,
const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is)
{
struct RefreshMeltState *rms = cls;
unsigned int num_fresh_coins;
const char *default_melt_fresh_amounts[] = {
"EUR:1", "EUR:1", "EUR:1", "EUR:0.1",
NULL
};
const char **melt_fresh_amounts;
(void) cmd;
if (NULL == (melt_fresh_amounts = rms->melt_fresh_amounts))
melt_fresh_amounts = default_melt_fresh_amounts;
rms->is = is;
rms->noreveal_index = UINT16_MAX;
TALER_refresh_master_setup_random (&rms->rms);
for (num_fresh_coins = 0;
NULL != melt_fresh_amounts[num_fresh_coins];
num_fresh_coins++)
;
rms->num_fresh_coins = num_fresh_coins;
rms->fresh_pks = GNUNET_new_array (
num_fresh_coins,
struct TALER_EXCHANGE_DenomPublicKey);
{
struct TALER_Amount melt_amount;
struct TALER_Amount fresh_amount;
const struct TALER_AgeCommitmentProof *age_commitment_proof;
const struct TALER_AgeCommitmentHash *h_age_commitment;
const struct TALER_DenominationSignature *melt_sig;
const struct TALER_EXCHANGE_DenomPublicKey *melt_denom_pub;
const struct TALER_TESTING_Command *coin_command;
bool age_restricted;
if (NULL == (coin_command
= TALER_TESTING_interpreter_lookup_command (
is,
rms->coin_reference)))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_coin_priv (coin_command,
0,
&rms->melt_priv))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_age_commitment_proof (coin_command,
0,
&age_commitment_proof))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_h_age_commitment (coin_command,
0,
&h_age_commitment))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_denom_sig (coin_command,
0,
&melt_sig))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_denom_pub (coin_command,
0,
&melt_denom_pub))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
/* Melt amount starts with the melt fee of the old coin; we'll add the
values and withdraw fees of the fresh coins next */
melt_amount = melt_denom_pub->fees.refresh;
age_restricted = melt_denom_pub->key.age_mask.bits != 0;
for (unsigned int i = 0; i<num_fresh_coins; i++)
{
const struct TALER_EXCHANGE_DenomPublicKey *fresh_pk;
if (GNUNET_OK !=
TALER_string_to_amount (melt_fresh_amounts[i],
&fresh_amount))
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to parse amount `%s' at index %u\n",
melt_fresh_amounts[i],
i);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
fresh_pk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (is->exchange),
&fresh_amount,
age_restricted);
if (NULL == fresh_pk)
{
GNUNET_break (0);
/* Subroutine logs specific error */
TALER_TESTING_interpreter_fail (rms->is);
return;
}
GNUNET_assert (0 <=
TALER_amount_add (&melt_amount,
&melt_amount,
&fresh_amount));
GNUNET_assert (0 <=
TALER_amount_add (&melt_amount,
&melt_amount,
&fresh_pk->fees.withdraw));
rms->fresh_pks[i] = *fresh_pk;
/* Make a deep copy of the RSA key */
TALER_denom_pub_deep_copy (&rms->fresh_pks[i].key,
&fresh_pk->key);
} /* end for */
rms->refresh_data.melt_priv = *rms->melt_priv;
rms->refresh_data.melt_amount = melt_amount;
rms->refresh_data.melt_sig = *melt_sig;
rms->refresh_data.melt_pk = *melt_denom_pub;
rms->refresh_data.melt_age_commitment_proof = age_commitment_proof;
rms->refresh_data.melt_h_age_commitment = h_age_commitment;
rms->refresh_data.fresh_pks = rms->fresh_pks;
rms->refresh_data.fresh_pks_len = num_fresh_coins;
GNUNET_assert (age_restricted ==
(NULL != age_commitment_proof));
rms->rmh = TALER_EXCHANGE_melt (is->exchange,
&rms->rms,
&rms->refresh_data,
&melt_cb,
rms);
if (NULL == rms->rmh)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rms->is);
return;
}
}
}
/**
* Free the "refresh melt" CMD state, and possibly cancel a
* pending operation thereof.
*
* @param cls closure, must be a `struct RefreshMeltState`.
* @param cmd the command which is being cleaned up.
*/
static void
melt_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd)
{
struct RefreshMeltState *rms = cls;
(void) cmd;
if (NULL != rms->rmh)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command %u (%s) did not complete\n",
rms->is->ip,
rms->is->commands[rms->is->ip].label);
TALER_EXCHANGE_melt_cancel (rms->rmh);
rms->rmh = NULL;
}
if (NULL != rms->retry_task)
{
GNUNET_SCHEDULER_cancel (rms->retry_task);
rms->retry_task = NULL;
}
if (NULL != rms->fresh_pks)
{
for (unsigned int i = 0; i < rms->num_fresh_coins; i++)
TALER_denom_pub_free (&rms->fresh_pks[i].key);
GNUNET_free (rms->fresh_pks);
}
GNUNET_free (rms->mbds);
GNUNET_free (rms->melt_fresh_amounts);
GNUNET_free (rms);
}
/**
* Offer internal data to the "refresh melt" CMD.
*
* @param cls closure.
* @param[out] ret result (could be anything).
* @param trait name of the trait.
* @param index index number of the object to offer.
* @return #GNUNET_OK on success.
*/
static enum GNUNET_GenericReturnValue
melt_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
struct RefreshMeltState *rms = cls;
if (index >= rms->num_fresh_coins)
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
{
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_denom_pub (index,
&rms->fresh_pks[index]),
TALER_TESTING_make_trait_coin_priv (index,
rms->melt_priv),
TALER_TESTING_make_trait_age_commitment_proof (
index,
rms->refresh_data.melt_age_commitment_proof),
TALER_TESTING_make_trait_h_age_commitment (
index,
rms->refresh_data.melt_h_age_commitment),
TALER_TESTING_make_trait_exchange_wd_value (index,
&rms->mbds[index].alg_value),
TALER_TESTING_make_trait_refresh_secret (&rms->rms),
TALER_TESTING_trait_end ()
};
return TALER_TESTING_get_trait (traits,
ret,
trait,
index);
}
}
/**
* Parse list of amounts for melt operation.
*
* @param[in,out] rms where to store the list
* @param ap NULL-termianted list of amounts to be melted (one per fresh coin)
* @return #GNUNET_OK on success
*/
static enum GNUNET_GenericReturnValue
parse_amounts (struct RefreshMeltState *rms,
va_list ap)
{
unsigned int len;
unsigned int off;
const char *amount;
len = 0;
off = 0;
while (NULL != (amount = va_arg (ap, const char *)))
{
if (len == off)
{
struct TALER_Amount a;
GNUNET_array_grow (rms->melt_fresh_amounts,
len,
off + 16);
if (GNUNET_OK !=
TALER_string_to_amount (amount, &a))
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to parse amount `%s' at index %u\n",
amount, off);
GNUNET_free (rms->melt_fresh_amounts);
rms->melt_fresh_amounts = NULL;
return GNUNET_SYSERR;
}
rms->melt_fresh_amounts[off++] = amount;
}
}
if (0 == off)
return GNUNET_OK; /* no amounts given == use defaults! */
/* ensure NULL-termination */
GNUNET_array_grow (rms->melt_fresh_amounts,
len,
off + 1);
return GNUNET_OK;
}
struct TALER_TESTING_Command
TALER_TESTING_cmd_melt (const char *label,
const char *coin_reference,
unsigned int expected_response_code,
...)
{
struct RefreshMeltState *rms;
va_list ap;
rms = GNUNET_new (struct RefreshMeltState);
rms->coin_reference = coin_reference;
rms->expected_response_code = expected_response_code;
va_start (ap,
expected_response_code);
GNUNET_assert (GNUNET_OK ==
parse_amounts (rms, ap));
va_end (ap);
{
struct TALER_TESTING_Command cmd = {
.label = label,
.cls = rms,
.run = &melt_run,
.cleanup = &melt_cleanup,
.traits = &melt_traits
};
return cmd;
}
}
struct TALER_TESTING_Command
TALER_TESTING_cmd_melt_double (const char *label,
const char *coin_reference,
unsigned int expected_response_code,
...)
{
struct RefreshMeltState *rms;
va_list ap;
rms = GNUNET_new (struct RefreshMeltState);
rms->coin_reference = coin_reference;
rms->expected_response_code = expected_response_code;
rms->double_melt = true;
va_start (ap,
expected_response_code);
GNUNET_assert (GNUNET_OK ==
parse_amounts (rms, ap));
va_end (ap);
{
struct TALER_TESTING_Command cmd = {
.label = label,
.cls = rms,
.run = &melt_run,
.cleanup = &melt_cleanup,
.traits = &melt_traits
};
return cmd;
}
}
struct TALER_TESTING_Command
TALER_TESTING_cmd_melt_with_retry (struct TALER_TESTING_Command cmd)
{
struct RefreshMeltState *rms;
GNUNET_assert (&melt_run == cmd.run);
rms = cmd.cls;
rms->do_retry = NUM_RETRIES;
return cmd;
}
/**
* Offer internal data from a "refresh reveal" CMD.
*
* @param cls closure.
* @param[out] ret result (could be anything).
* @param trait name of the trait.
* @param index index number of the object to offer.
* @return #GNUNET_OK on success.
*/
static enum GNUNET_GenericReturnValue
refresh_reveal_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
struct RefreshRevealState *rrs = cls;
if (index >= rrs->num_fresh_coins)
return GNUNET_SYSERR;
{
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_coin_priv (
index,
&rrs->fresh_coins[index].coin_priv),
TALER_TESTING_make_trait_age_commitment_proof (
index,
rrs->fresh_coins[index].age_commitment_proof),
TALER_TESTING_make_trait_h_age_commitment (
index,
rrs->fresh_coins[index].h_age_commitment),
TALER_TESTING_make_trait_denom_pub (
index,
rrs->fresh_coins[index].pk),
TALER_TESTING_make_trait_denom_sig (
index,
&rrs->fresh_coins[index].sig),
TALER_TESTING_make_trait_blinding_key (
index,
&rrs->fresh_coins[index].blinding_key),
TALER_TESTING_make_trait_array_length (
&rrs->num_fresh_coins),
TALER_TESTING_make_trait_fresh_coins (
(const struct TALER_TESTING_FreshCoinData **) &rrs->fresh_coins),
TALER_TESTING_make_trait_planchet_secrets (index,
&rrs->psa[index]),
TALER_TESTING_trait_end ()
};
return TALER_TESTING_get_trait (traits,
ret,
trait,
index);
}
}
struct TALER_TESTING_Command
TALER_TESTING_cmd_refresh_reveal (const char *label,
const char *melt_reference,
unsigned int expected_response_code)
{
struct RefreshRevealState *rrs;
rrs = GNUNET_new (struct RefreshRevealState);
rrs->melt_reference = melt_reference;
rrs->expected_response_code = expected_response_code;
{
struct TALER_TESTING_Command cmd = {
.cls = rrs,
.label = label,
.run = &refresh_reveal_run,
.cleanup = &refresh_reveal_cleanup,
.traits = &refresh_reveal_traits
};
return cmd;
}
}
struct TALER_TESTING_Command
TALER_TESTING_cmd_refresh_reveal_with_retry (struct TALER_TESTING_Command cmd)
{
struct RefreshRevealState *rrs;
GNUNET_assert (&refresh_reveal_run == cmd.run);
rrs = cmd.cls;
rrs->do_retry = NUM_RETRIES;
return cmd;
}
struct TALER_TESTING_Command
TALER_TESTING_cmd_refresh_link (const char *label,
const char *reveal_reference,
unsigned int expected_response_code)
{
struct RefreshLinkState *rrs;
rrs = GNUNET_new (struct RefreshLinkState);
rrs->reveal_reference = reveal_reference;
rrs->expected_response_code = expected_response_code;
{
struct TALER_TESTING_Command cmd = {
.cls = rrs,
.label = label,
.run = &refresh_link_run,
.cleanup = &refresh_link_cleanup
};
return cmd;
}
}
struct TALER_TESTING_Command
TALER_TESTING_cmd_refresh_link_with_retry (struct TALER_TESTING_Command cmd)
{
struct RefreshLinkState *rls;
GNUNET_assert (&refresh_link_run == cmd.run);
rls = cmd.cls;
rls->do_retry = NUM_RETRIES;
return cmd;
}
|