rippled
Loading...
Searching...
No Matches
RPCCall_test.cpp
1#include <test/jtx.h>
2#include <test/jtx/utility.h>
3
4#include <xrpld/rpc/RPCCall.h>
5
6#include <xrpl/beast/unit_test.h>
7#include <xrpl/json/json_reader.h>
8#include <xrpl/protocol/ApiVersion.h>
9#include <xrpl/protocol/ErrorCodes.h>
10
11#include <boost/algorithm/string.hpp>
12
13#include <functional>
14#include <initializer_list>
15#include <vector>
16
17namespace xrpl {
18namespace test {
19
21{
22 char const* const description;
23 int const line;
24 // List of passed arguments.
26
27 // If it throws, what does it throw?
30
31 // Expected JSON response.
33
35 char const* description_,
36 int line_,
38 Exception throwsWhat_,
39 char const* exp_)
40 : description(description_), line(line_), args(args_), throwsWhat(throwsWhat_), exp(1, exp_)
41 {
42 }
43
45 char const* description_,
46 int line_,
48 Exception throwsWhat_,
50 : description(description_), line(line_), args(args_), throwsWhat(throwsWhat_), exp(exp_)
51 {
52 }
53
54 RPCCallTestData() = delete;
58 operator=(RPCCallTestData const&) = delete;
61};
62
64 // account_channels
65 // ------------------------------------------------------------
66 {"account_channels: minimal.",
67 __LINE__,
68 {"account_channels", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
70 R"({
71 "method" : "account_channels",
72 "params" : [
73 {
74 "api_version" : %API_VER%,
75 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
76 }
77 ]
78 })"},
79 {"account_channels: account and ledger hash.",
80 __LINE__,
81 {"account_channels",
82 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
83 "rD5MbavGfiSC5m7mkxy1FANuT7s3HxqpoF"},
85 R"({
86 "method" : "account_channels",
87 "params" : [
88 {
89 "api_version" : %API_VER%,
90 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
91 "destination_account" : "rD5MbavGfiSC5m7mkxy1FANuT7s3HxqpoF"
92 }
93 ]
94 })"},
95 {"account_channels: account and ledger index.",
96 __LINE__,
97 {"account_channels",
98 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
99 "r9emE59aTWb85t64dAebKrxYMBTpzK5yR7"},
101 R"({
102 "method" : "account_channels",
103 "params" : [
104 {
105 "api_version" : %API_VER%,
106 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
107 "destination_account" : "r9emE59aTWb85t64dAebKrxYMBTpzK5yR7"
108 }
109 ]
110 })"},
111 {"account_channels: two accounts.",
112 __LINE__,
113 {"account_channels",
114 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
115 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"},
117 R"({
118 "method" : "account_channels",
119 "params" : [
120 {
121 "api_version" : %API_VER%,
122 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
123 "destination_account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
124 }
125 ]
126 })"},
127 {"account_channels: two accounts and ledger hash.",
128 __LINE__,
129 {"account_channels",
130 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
131 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
132 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
134 R"({
135 "method" : "account_channels",
136 "params" : [
137 {
138 "api_version" : %API_VER%,
139 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
140 "destination_account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
141 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
142 }
143 ]
144 })"},
145 {"account_channels: two accounts and ledger index.",
146 __LINE__,
147 {"account_channels",
148 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
149 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
150 "90210"},
152 R"({
153 "method" : "account_channels",
154 "params" : [
155 {
156 "api_version" : %API_VER%,
157 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
158 "destination_account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
159 "ledger_index" : 90210
160 }
161 ]
162 })"},
163 {"account_channels: too few arguments.",
164 __LINE__,
165 {
166 "account_channels",
167 },
169 R"({
170 "method" : "account_channels",
171 "params" : [
172 {
173 "error" : "badSyntax",
174 "error_code" : 1,
175 "error_message" : "Syntax error."
176 }
177 ]
178 })"},
179 {"account_channels: too many arguments.",
180 __LINE__,
181 {"account_channels",
182 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
183 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
184 "current",
185 "extra"},
187 R"({
188 "method" : "account_channels",
189 "params" : [
190 {
191 "error" : "badSyntax",
192 "error_code" : 1,
193 "error_message" : "Syntax error."
194 }
195 ]
196 })"},
197 {"account_channels: invalid accountID.",
198 __LINE__,
199 {
200 "account_channels",
201 "", // Note: very few values are detected as bad!
202 },
204 R"({
205 "method" : "account_channels",
206 "params" : [
207 {
208 "error" : "actMalformed",
209 "error_code" : 35,
210 "error_message" : "Account malformed."
211 }
212 ]
213 })"},
214
215 // account_currencies
216 // ----------------------------------------------------------
217 {"account_currencies: minimal 1.",
218 __LINE__,
219 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
221 R"({
222 "method" : "account_currencies",
223 "params" : [
224 {
225 "api_version" : %API_VER%,
226 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
227 }
228 ]
229 })"},
230 {"account_currencies: minimal 2.",
231 __LINE__,
232 {"account_currencies", "racb4o3DrdYxuCfyVa6vsLb7vgju9RFbBr"},
234 R"({
235 "method" : "account_currencies",
236 "params" : [
237 {
238 "api_version" : %API_VER%,
239 "account" : "racb4o3DrdYxuCfyVa6vsLb7vgju9RFbBr"
240 }
241 ]
242 })"},
243 {"account_currencies: ledger index.",
244 __LINE__,
245 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "42"},
247 R"({
248 "method" : "account_currencies",
249 "params" : [
250 {
251 "api_version" : %API_VER%,
252 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
253 "ledger_index" : 42
254 }
255 ]
256 })"},
257 {"account_currencies: validated ledger.",
258 __LINE__,
259 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
261 R"({
262 "method" : "account_currencies",
263 "params" : [
264 {
265 "api_version" : %API_VER%,
266 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
267 "ledger_index" : "validated"
268 }
269 ]
270 })"},
271 {"account_currencies: current ledger.",
272 __LINE__,
273 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "current"},
275 R"({
276 "method" : "account_currencies",
277 "params" : [
278 {
279 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
280 "api_version" : %API_VER%,
281 "ledger_index" : "current"
282 }
283 ]
284 })"},
285 {"account_currencies: too few arguments.",
286 __LINE__,
287 {
288 "account_currencies",
289 },
291 R"({
292 "method" : "account_currencies",
293 "params" : [
294 {
295 "error" : "badSyntax",
296 "error_code" : 1,
297 "error_message" : "Syntax error."
298 }
299 ]
300 })"},
301 {"account_currencies: too many arguments.",
302 __LINE__,
303 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "current", "spare1", "spare2"},
305 R"({
306 "method" : "account_currencies",
307 "params" : [
308 {
309 "error" : "badSyntax",
310 "error_code" : 1,
311 "error_message" : "Syntax error."
312 }
313 ]
314 })"},
315 {"account_currencies: invalid second argument.",
316 __LINE__,
317 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "yup"},
319 R"({
320 "method" : "account_currencies",
321 "params" : [
322 {
323 "api_version" : %API_VER%,
324 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
325 "ledger_index" : 0
326 }
327 ]
328 })"},
329 {
330 "account_currencies: invalid accountID.",
331 __LINE__,
332 {
333 "account_currencies",
334 "", // Note: very few values are detected as bad!
335 },
337 R"({
338 "method" : "account_currencies",
339 "params" : [
340 {
341 "error" : "actMalformed",
342 "error_code" : 35,
343 "error_message" : "Account malformed."
344 }
345 ]
346 })",
347 },
348
349 // account_info
350 // ----------------------------------------------------------------
351 {"account_info: minimal.",
352 __LINE__,
353 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
355 R"({
356 "method" : "account_info",
357 "params" : [
358 {
359 "api_version" : %API_VER%,
360 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
361 }
362 ]
363 })"},
364 {"account_info: with numeric ledger index.",
365 __LINE__,
366 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "77777"},
368 R"({
369 "method" : "account_info",
370 "params" : [
371 {
372 "api_version" : %API_VER%,
373 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
374 "ledger_index" : 77777
375 }
376 ]
377 })"},
378 {"account_info: with text ledger index.",
379 __LINE__,
380 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "closed"},
382 R"({
383 "method" : "account_info",
384 "params" : [
385 {
386 "api_version" : %API_VER%,
387 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
388 "ledger_index" : "closed"
389 }
390 ]
391 })"},
392 {"account_info: with ledger hash.",
393 __LINE__,
394 {"account_info",
395 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
396 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
398 R"({
399 "method" : "account_info",
400 "params" : [
401 {
402 "api_version" : %API_VER%,
403 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
404 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
405 }
406 ]
407 })"},
408 {"account_info: with ledger index.",
409 __LINE__,
410 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
412 R"({
413 "method" : "account_info",
414 "params" : [
415 {
416 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
417 "api_version" : %API_VER%,
418 "ledger_index" : "validated"
419 }
420 ]
421 })"},
422 {"account_info: too few arguments.",
423 __LINE__,
424 {
425 "account_info",
426 },
428 R"({
429 "method" : "account_info",
430 "params" : [
431 {
432 "error" : "badSyntax",
433 "error_code" : 1,
434 "error_message" : "Syntax error."
435 }
436 ]
437 })"},
438 {"account_info: too many arguments.",
439 __LINE__,
440 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "current", "extra1", "extra2"},
442 R"({
443 "method" : "account_info",
444 "params" : [
445 {
446 "error" : "badSyntax",
447 "error_code" : 1,
448 "error_message" : "Syntax error."
449 }
450 ]
451 })"},
452 {
453 "account_info: invalid accountID.",
454 __LINE__,
455 {
456 "account_info",
457 "", // Note: very few values are detected as bad!
458 },
460 R"({
461 "method" : "account_info",
462 "params" : [
463 {
464 "error" : "actMalformed",
465 "error_code" : 35,
466 "error_message" : "Account malformed."
467 }
468 ]
469 })",
470 },
471
472 // account_lines
473 // ---------------------------------------------------------------
474 {"account_lines: minimal.",
475 __LINE__,
476 {"account_lines", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
478 R"({
479 "method" : "account_lines",
480 "params" : [
481 {
482 "api_version" : %API_VER%,
483 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
484 }
485 ]
486 })"},
487 {"account_lines: peer.",
488 __LINE__,
489 {"account_lines", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"},
491 R"({
492 "method" : "account_lines",
493 "params" : [
494 {
495 "api_version" : %API_VER%,
496 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
497 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
498 }
499 ]
500 })"},
501 {"account_lines: peer and numeric ledger index.",
502 __LINE__,
503 {"account_lines",
504 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
505 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
506 "888888888"},
508 R"({
509 "method" : "account_lines",
510 "params" : [
511 {
512 "api_version" : %API_VER%,
513 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
514 "ledger_index" : 888888888,
515 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
516 }
517 ]
518 })"},
519 {"account_lines: peer and text ledger index.",
520 __LINE__,
521 {"account_lines",
522 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
523 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
524 "closed"},
526 R"({
527 "method" : "account_lines",
528 "params" : [
529 {
530 "api_version" : %API_VER%,
531 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
532 "ledger_index" : "closed",
533 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
534 }
535 ]
536 })"},
537 {"account_lines: peer and ledger hash.",
538 __LINE__,
539 {"account_lines",
540 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
541 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
542 "FFFFEEEEDDDDCCCCBBBBAAAA9999888877776666555544443333222211110000"},
544 R"({
545 "method" : "account_lines",
546 "params" : [
547 {
548 "api_version" : %API_VER%,
549 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
550 "ledger_hash" : "FFFFEEEEDDDDCCCCBBBBAAAA9999888877776666555544443333222211110000",
551 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
552 }
553 ]
554 })"},
555 {"account_lines: too few arguments.",
556 __LINE__,
557 {
558 "account_lines",
559 },
561 R"({
562 "method" : "account_lines",
563 "params" : [
564 {
565 "error" : "badSyntax",
566 "error_code" : 1,
567 "error_message" : "Syntax error."
568 }
569 ]
570 })"},
571 {// Note: I believe this _ought_ to be detected as too many arguments.
572 "account_lines: four arguments.",
573 __LINE__,
574 {"account_lines",
575 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
576 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
577 "12345678",
578 "current"},
580 R"({
581 "method" : "account_lines",
582 "params" : [
583 {
584 "api_version" : %API_VER%,
585 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
586 "ledger_index" : 12345678,
587 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
588 }
589 ]
590 })"},
591 {// Note: I believe this _ought_ to be detected as too many arguments.
592 "account_lines: five arguments.",
593 __LINE__,
594 {"account_lines",
595 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
596 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
597 "12345678",
598 "current",
599 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
601 R"({
602 "method" : "account_lines",
603 "params" : [
604 {
605 "api_version" : %API_VER%,
606 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
607 "ledger_index" : 12345678,
608 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
609 }
610 ]
611 })"},
612 {"account_lines: too many arguments.",
613 __LINE__,
614 {"account_lines",
615 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
616 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
617 "12345678",
618 "current",
619 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
620 "validated"},
622 R"({
623 "method" : "account_lines",
624 "params" : [
625 {
626 "error" : "badSyntax",
627 "error_code" : 1,
628 "error_message" : "Syntax error."
629 }
630 ]
631 })"},
632 {
633 "account_lines: first invalid accountID.",
634 __LINE__,
635 {
636 "account_lines",
637 "", // Note: very few values are detected as bad!
638 },
640 R"({
641 "method" : "account_lines",
642 "params" : [
643 {
644 "error" : "actMalformed",
645 "error_code" : 35,
646 "error_message" : "Account malformed."
647 }
648 ]
649 })",
650 },
651 {
652 "account_lines: second invalid accountID.",
653 __LINE__,
654 {
655 "account_lines",
656 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
657 "" // Note: very few values are detected as bad!
658 },
660 R"({
661 "method" : "account_lines",
662 "params" : [
663 {
664 "api_version" : %API_VER%,
665 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
666 }
667 ]
668 })",
669 },
670 {
671 "account_lines: invalid ledger selector.",
672 __LINE__,
673 {"account_lines",
674 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
675 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
676 "not_a_ledger"},
678 R"({
679 "method" : "account_lines",
680 "params" : [
681 {
682 "api_version" : %API_VER%,
683 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
684 "ledger_index" : 0,
685 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
686 }
687 ]
688 })",
689 },
690
691 // account_objects
692 // -------------------------------------------------------------
693 {"account_objects: minimal.",
694 __LINE__,
695 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
697 R"({
698 "method" : "account_objects",
699 "params" : [
700 {
701 "api_version" : %API_VER%,
702 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
703 }
704 ]
705 })"},
706 {"account_objects: with numeric ledger index.",
707 __LINE__,
708 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "77777"},
710 R"({
711 "method" : "account_objects",
712 "params" : [
713 {
714 "api_version" : %API_VER%,
715 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
716 "ledger_index" : 77777
717 }
718 ]
719 })"},
720 {"account_objects: with text ledger index.",
721 __LINE__,
722 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "closed"},
724 R"({
725 "method" : "account_objects",
726 "params" : [
727 {
728 "api_version" : %API_VER%,
729 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
730 "ledger_index" : "closed"
731 }
732 ]
733 })"},
734 {"account_objects: with ledger hash.",
735 __LINE__,
736 {"account_objects",
737 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
738 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
740 R"({
741 "method" : "account_objects",
742 "params" : [
743 {
744 "api_version" : %API_VER%,
745 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
746 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
747 }
748 ]
749 })"},
750 {"account_objects: with ledger index.",
751 __LINE__,
752 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
754 R"({
755 "method" : "account_objects",
756 "params" : [
757 {
758 "api_version" : %API_VER%,
759 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
760 "ledger_index" : "validated"
761 }
762 ]
763 })"},
764 {"account_objects: too few arguments.",
765 __LINE__,
766 {
767 "account_objects",
768 },
770 R"({
771 "method" : "account_objects",
772 "params" : [
773 {
774 "error" : "badSyntax",
775 "error_code" : 1,
776 "error_message" : "Syntax error."
777 }
778 ]
779 })"},
780 {// Note: I believe this _ought_ to be detected as too many arguments.
781 "account_objects: four arguments.",
782 __LINE__,
783 {
784 "account_objects",
785 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
786 "current",
787 "extra1",
788 "extra2",
789 },
791 R"({
792 "method" : "account_objects",
793 "params" : [
794 {
795 "api_version" : %API_VER%,
796 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
797 }
798 ]
799 })"},
800 {// Note: I believe this _ought_ to be detected as too many arguments.
801 "account_objects: five arguments.",
802 __LINE__,
803 {
804 "account_objects",
805 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
806 "current",
807 "extra1",
808 "extra2",
809 "extra3",
810 },
812 R"({
813 "method" : "account_objects",
814 "params" : [
815 {
816 "api_version" : %API_VER%,
817 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
818 }
819 ]
820 })"},
821 {"account_objects: too many arguments.",
822 __LINE__,
823 {
824 "account_objects",
825 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
826 "current",
827 "extra1",
828 "extra2",
829 "extra3",
830 "extra4",
831 },
833 R"({
834 "method" : "account_objects",
835 "params" : [
836 {
837 "error" : "badSyntax",
838 "error_code" : 1,
839 "error_message" : "Syntax error."
840 }
841 ]
842 })"},
843 {
844 "account_objects: invalid accountID.",
845 __LINE__,
846 {
847 "account_objects",
848 "", // Note: very few values are detected as bad!
849 },
851 R"({
852 "method" : "account_objects",
853 "params" : [
854 {
855 "error" : "actMalformed",
856 "error_code" : 35,
857 "error_message" : "Account malformed."
858 }
859 ]
860 })",
861 },
862 {
863 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
864 // cannot currently occur because jvParseLedger() always returns true.
865 "account_objects: invalid ledger selection 1.",
866 __LINE__,
867 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
869 R"({
870 "method" : "account_objects",
871 "params" : [
872 {
873 "api_version" : %API_VER%,
874 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
875 "ledger_index" : 0
876 }
877 ]
878 })",
879 },
880 {
881 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
882 // cannot currently occur because jvParseLedger() always returns true.
883 "account_objects: invalid ledger selection 2.",
884 __LINE__,
885 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
887 R"({
888 "method" : "account_objects",
889 "params" : [
890 {
891 "api_version" : %API_VER%,
892 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
893 "ledger_index" : 0
894 }
895 ]
896 })",
897 },
898
899 // account_offers
900 // --------------------------------------------------------------
901 {"account_offers: minimal.",
902 __LINE__,
903 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
905 R"({
906 "method" : "account_offers",
907 "params" : [
908 {
909 "api_version" : %API_VER%,
910 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
911 }
912 ]
913 })"},
914 {"account_offers: with numeric ledger index.",
915 __LINE__,
916 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "987654321"},
918 R"({
919 "method" : "account_offers",
920 "params" : [
921 {
922 "api_version" : %API_VER%,
923 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
924 "ledger_index" : 987654321
925 }
926 ]
927 })"},
928 {"account_offers: with text ledger index.",
929 __LINE__,
930 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
932 R"({
933 "method" : "account_offers",
934 "params" : [
935 {
936 "api_version" : %API_VER%,
937 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
938 "ledger_index" : "validated"
939 }
940 ]
941 })"},
942 {"account_offers: with ledger hash.",
943 __LINE__,
944 {"account_offers",
945 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
946 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
948 R"({
949 "method" : "account_offers",
950 "params" : [
951 {
952 "api_version" : %API_VER%,
953 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
954 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
955 }
956 ]
957 })"},
958 {"account_offers: with ledger index.",
959 __LINE__,
960 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
962 R"({
963 "method" : "account_offers",
964 "params" : [
965 {
966 "api_version" : %API_VER%,
967 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
968 "ledger_index" : "validated"
969 }
970 ]
971 })"},
972 {"account_offers: too few arguments.",
973 __LINE__,
974 {
975 "account_offers",
976 },
978 R"({
979 "method" : "account_offers",
980 "params" : [
981 {
982 "error" : "badSyntax",
983 "error_code" : 1,
984 "error_message" : "Syntax error."
985 }
986 ]
987 })"},
988 {// Note: I believe this _ought_ to be detected as too many arguments.
989 "account_offers: four arguments.",
990 __LINE__,
991 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "current", "extra"},
993 R"({
994 "method" : "account_offers",
995 "params" : [
996 {
997 "api_version" : %API_VER%,
998 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
999 }
1000 ]
1001 })"},
1002 {"account_offers: too many arguments.",
1003 __LINE__,
1004 {
1005 "account_offers",
1006 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1007 "current",
1008 "extra1",
1009 "extra2",
1010 "extra3",
1011 },
1013 R"({
1014 "method" : "account_offers",
1015 "params" : [
1016 {
1017 "error" : "badSyntax",
1018 "error_code" : 1,
1019 "error_message" : "Syntax error."
1020 }
1021 ]
1022 })"},
1023 {
1024 "account_offers: invalid accountID.",
1025 __LINE__,
1026 {
1027 "account_offers",
1028 "", // Note: very few values are detected as bad!
1029 },
1031 R"({
1032 "method" : "account_offers",
1033 "params" : [
1034 {
1035 "error" : "actMalformed",
1036 "error_code" : 35,
1037 "error_message" : "Account malformed."
1038 }
1039 ]
1040 })",
1041 },
1042 {
1043 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
1044 // cannot currently occur because jvParseLedger() always returns true.
1045 "account_offers: invalid ledger selection 1.",
1046 __LINE__,
1047 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
1049 R"({
1050 "method" : "account_offers",
1051 "params" : [
1052 {
1053 "api_version" : %API_VER%,
1054 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1055 "ledger_index" : 0
1056 }
1057 ]
1058 })",
1059 },
1060 {
1061 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
1062 // cannot currently occur because jvParseLedger() always returns true.
1063 "account_offers: invalid ledger selection 2.",
1064 __LINE__,
1065 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
1067 R"({
1068 "method" : "account_offers",
1069 "params" : [
1070 {
1071 "api_version" : %API_VER%,
1072 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1073 "ledger_index" : 0
1074 }
1075 ]
1076 })",
1077 },
1078
1079 // account_tx
1080 // ------------------------------------------------------------------
1081 {"account_tx: minimal.",
1082 __LINE__,
1083 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
1085 R"({
1086 "method" : "account_tx",
1087 "params" : [
1088 {
1089 "api_version" : %API_VER%,
1090 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1091 }
1092 ]
1093 })"},
1094 {"account_tx: ledger_index .",
1095 __LINE__,
1096 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "444"},
1098 R"({
1099 "method" : "account_tx",
1100 "params" : [
1101 {
1102 "api_version" : %API_VER%,
1103 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1104 "ledger_index" : 444
1105 }
1106 ]
1107 })"},
1108 {"account_tx: ledger_index plus trailing params.",
1109 __LINE__,
1110 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "707", "descending", "binary", "count"},
1112 R"({
1113 "method" : "account_tx",
1114 "params" : [
1115 {
1116 "api_version" : %API_VER%,
1117 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1118 "count" : true,
1119 "binary" : true,
1120 "descending" : true,
1121 "ledger_index" : 707
1122 }
1123 ]
1124 })"},
1125 {"account_tx: ledger_index_min and _max.",
1126 __LINE__,
1127 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "-1"},
1129 R"({
1130 "method" : "account_tx",
1131 "params" : [
1132 {
1133 "api_version" : %API_VER%,
1134 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1135 "ledger_index_max" : -1,
1136 "ledger_index_min" : -1
1137 }
1138 ]
1139 })"},
1140 {"account_tx: ledger_index_min and _max plus trailing params.",
1141 __LINE__,
1142 {"account_tx",
1143 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1144 "-1",
1145 "413",
1146 "binary",
1147 "count",
1148 "descending"},
1150 R"({
1151 "method" : "account_tx",
1152 "params" : [
1153 {
1154 "api_version" : %API_VER%,
1155 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1156 "binary" : true,
1157 "count" : true,
1158 "descending" : true,
1159 "ledger_index_max" : 413,
1160 "ledger_index_min" : -1
1161 }
1162 ]
1163 })"},
1164 {"account_tx: ledger_index_min and _max plus limit.",
1165 __LINE__,
1166 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "247", "-1", "300"},
1168 R"({
1169 "method" : "account_tx",
1170 "params" : [
1171 {
1172 "api_version" : %API_VER%,
1173 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1174 "ledger_index_max" : -1,
1175 "ledger_index_min" : 247,
1176 "limit" : 300
1177 }
1178 ]
1179 })"},
1180 {"account_tx: ledger_index_min and _max, limit, trailing args.",
1181 __LINE__,
1182 {"account_tx",
1183 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1184 "247",
1185 "-1",
1186 "300",
1187 "count",
1188 "descending",
1189 "binary"},
1191 R"({
1192 "method" : "account_tx",
1193 "params" : [
1194 {
1195 "api_version" : %API_VER%,
1196 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1197 "binary" : true,
1198 "count" : true,
1199 "descending" : true,
1200 "ledger_index_max" : -1,
1201 "ledger_index_min" : 247,
1202 "limit" : 300
1203 }
1204 ]
1205 })"},
1206 {"account_tx: ledger_index_min and _max plus limit and offset.",
1207 __LINE__,
1208 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "589", "590", "67", "45"},
1210 R"({
1211 "method" : "account_tx",
1212 "params" : [
1213 {
1214 "api_version" : %API_VER%,
1215 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1216 "ledger_index_max" : 590,
1217 "ledger_index_min" : 589,
1218 "limit" : 67,
1219 "offset" : 45
1220 }
1221 ]
1222 })"},
1223 {"account_tx: ledger_index_min and _max, limit, offset, trailing.",
1224 __LINE__,
1225 {"account_tx",
1226 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1227 "589",
1228 "590",
1229 "67",
1230 "45",
1231 "descending",
1232 "count"},
1234 R"({
1235 "method" : "account_tx",
1236 "params" : [
1237 {
1238 "api_version" : %API_VER%,
1239 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1240 "count" : true,
1241 "descending" : true,
1242 "ledger_index_max" : 590,
1243 "ledger_index_min" : 589,
1244 "limit" : 67,
1245 "offset" : 45
1246 }
1247 ]
1248 })"},
1249 {"account_tx: too few arguments.",
1250 __LINE__,
1251 {
1252 "account_tx",
1253 },
1255 R"({
1256 "method" : "account_tx",
1257 "params" : [
1258 {
1259 "error" : "badSyntax",
1260 "error_code" : 1,
1261 "error_message" : "Syntax error."
1262 }
1263 ]
1264 })"},
1265 {"account_tx: too many arguments.",
1266 __LINE__,
1267 {"account_tx",
1268 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1269 "589",
1270 "590",
1271 "67",
1272 "45",
1273 "extra",
1274 "descending",
1275 "count",
1276 "binary"},
1278 R"({
1279 "method" : "account_tx",
1280 "params" : [
1281 {
1282 "error" : "badSyntax",
1283 "error_code" : 1,
1284 "error_message" : "Syntax error."
1285 }
1286 ]
1287 })"},
1288 {
1289 "account_tx: invalid accountID.",
1290 __LINE__,
1291 {"account_tx", "rHb9CJAWyB4rj9!VRWn96DkukG4bwdtyTh"},
1293 R"({
1294 "method" : "account_tx",
1295 "params" : [
1296 {
1297 "error" : "actMalformed",
1298 "error_code" : 35,
1299 "error_message" : "Account malformed."
1300 }
1301 ]
1302 })",
1303 },
1304 {
1305 // Note: not currently detected as bad input.
1306 "account_tx: invalid ledger.",
1307 __LINE__,
1308 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-478.7"},
1310 R"({
1311 "method" : "account_tx",
1312 "params" : [
1313 {
1314 "api_version" : %API_VER%,
1315 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1316 "ledger_index" : 0
1317 }
1318 ]
1319 })",
1320 },
1321 {
1322 "account_tx: max less than min.",
1323 __LINE__,
1324 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "580", "579"},
1326 {
1327 R"({
1328 "method" : "account_tx",
1329 "params" : [
1330 {
1331 "error" : "lgrIdxsInvalid",
1332 "error_code" : 55,
1333 "error_message" : "Ledger indexes invalid."
1334 }
1335 ]
1336 })",
1337 R"({
1338 "method" : "account_tx",
1339 "params" : [
1340 {
1341 "error" : "notSynced",
1342 "error_code" : 55,
1343 "error_message" : "Not synced to the network."
1344 }
1345 ]
1346 })"},
1347 },
1348 {
1349 // Note: this really shouldn't throw, but does at the moment.
1350 "account_tx: non-integer min.",
1351 __LINE__,
1352 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Binary", "-1"},
1354 R"()",
1355 },
1356 {
1357 // Note: this really shouldn't throw, but does at the moment.
1358 "account_tx: non-integer max.",
1359 __LINE__,
1360 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "counts"},
1362 R"()",
1363 },
1364 {
1365 // Note: this really shouldn't throw, but does at the moment.
1366 "account_tx: non-integer offset.",
1367 __LINE__,
1368 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "-1", "decending"},
1370 R"()",
1371 },
1372 {
1373 // Note: this really shouldn't throw, but does at the moment.
1374 "account_tx: non-integer limit.",
1375 __LINE__,
1376 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "-1", "300", "false"},
1378 R"()",
1379 },
1380 {// Note: this really shouldn't throw, but does at the moment.
1381 "account_tx: RIPD-1570.",
1382 __LINE__,
1383 {"account_tx",
1384 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1385 "-1",
1386 "-1",
1387 "2",
1388 "false",
1389 "false",
1390 "false"},
1392 R"()"},
1393
1394 // book_offers
1395 // -----------------------------------------------------------------
1396 {"book_offers: minimal no issuer.",
1397 __LINE__,
1398 {
1399 "book_offers",
1400 "USD",
1401 "EUR",
1402 },
1404 R"({
1405 "method" : "book_offers",
1406 "params" : [
1407 {
1408 "api_version" : %API_VER%,
1409 "taker_gets" : {
1410 "currency" : "EUR"
1411 },
1412 "taker_pays" : {
1413 "currency" : "USD"
1414 }
1415 }
1416 ]
1417 })"},
1418 {"book_offers: minimal with currency/issuer",
1419 __LINE__,
1420 {
1421 "book_offers",
1422 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1423 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1424 },
1426 R"({
1427 "method" : "book_offers",
1428 "params" : [
1429 {
1430 "api_version" : %API_VER%,
1431 "taker_gets" : {
1432 "currency" : "EUR",
1433 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1434 },
1435 "taker_pays" : {
1436 "currency" : "USD",
1437 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1438 }
1439 }
1440 ]
1441 })"},
1442 {// Note: documentation suggests that "issuer" is the wrong type.
1443 // Should it be "taker" instead?
1444 "book_offers: add issuer.",
1445 __LINE__,
1446 {"book_offers", "USD", "EUR", "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"},
1448 R"({
1449 "method" : "book_offers",
1450 "params" : [
1451 {
1452 "api_version" : %API_VER%,
1453 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1454 "taker_gets" : {
1455 "currency" : "EUR"
1456 },
1457 "taker_pays" : {
1458 "currency" : "USD"
1459 }
1460 }
1461 ]
1462 })"},
1463 {"book_offers: add issuer and numeric ledger index.",
1464 __LINE__,
1465 {"book_offers",
1466 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1467 "EUR",
1468 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1469 "666"},
1471 R"({
1472 "method" : "book_offers",
1473 "params" : [
1474 {
1475 "api_version" : %API_VER%,
1476 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1477 "ledger_index" : 666,
1478 "taker_gets" : {
1479 "currency" : "EUR"
1480 },
1481 "taker_pays" : {
1482 "currency" : "USD",
1483 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1484 }
1485 }
1486 ]
1487 })"},
1488 {"book_offers: add issuer and text ledger index.",
1489 __LINE__,
1490 {"book_offers",
1491 "USD",
1492 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1493 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1494 "current"},
1496 R"({
1497 "method" : "book_offers",
1498 "params" : [
1499 {
1500 "api_version" : %API_VER%,
1501 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1502 "ledger_index" : "current",
1503 "taker_gets" : {
1504 "currency" : "EUR",
1505 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1506 },
1507 "taker_pays" : {
1508 "currency" : "USD"
1509 }
1510 }
1511 ]
1512 })"},
1513 {"book_offers: add issuer and ledger hash.",
1514 __LINE__,
1515 {"book_offers",
1516 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1517 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1518 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1519 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
1521 R"({
1522 "method" : "book_offers",
1523 "params" : [
1524 {
1525 "api_version" : %API_VER%,
1526 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1527 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1528 "taker_gets" : {
1529 "currency" : "EUR",
1530 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1531 },
1532 "taker_pays" : {
1533 "currency" : "USD",
1534 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1535 }
1536 }
1537 ]
1538 })"},
1539 {"book_offers: issuer, ledger hash, and limit.",
1540 __LINE__,
1541 {
1542 "book_offers",
1543 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1544 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1545 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1546 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1547 "200",
1548 },
1550 R"({
1551 "method" : "book_offers",
1552 "params" : [
1553 {
1554 "api_version" : %API_VER%,
1555 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1556 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1557 "limit" : 200,
1558 "taker_gets" : {
1559 "currency" : "EUR",
1560 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1561 },
1562 "taker_pays" : {
1563 "currency" : "USD",
1564 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1565 }
1566 }
1567 ]
1568 })"},
1569 {// Note: parser supports "marker", but the docs don't cover it.
1570 "book_offers: issuer, ledger hash, limit, and marker.",
1571 __LINE__,
1572 {"book_offers",
1573 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1574 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1575 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1576 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1577 "200",
1578 "0",
1579 "MyMarker"},
1581 R"({
1582 "method" : "book_offers",
1583 "params" : [
1584 {
1585 "api_version" : %API_VER%,
1586 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1587 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1588 "limit" : 200,
1589 "marker" : "MyMarker",
1590 "taker_gets" : {
1591 "currency" : "EUR",
1592 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1593 },
1594 "taker_pays" : {
1595 "currency" : "USD",
1596 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1597 }
1598 }
1599 ]
1600 })"},
1601 {"book_offers: too few arguments.",
1602 __LINE__,
1603 {
1604 "book_offers",
1605 },
1607 R"({
1608 "method" : "book_offers",
1609 "params" : [
1610 {
1611 "error" : "badSyntax",
1612 "error_code" : 1,
1613 "error_message" : "Syntax error."
1614 }
1615 ]
1616 })"},
1617 {"book_offers: too many arguments.",
1618 __LINE__,
1619 {"book_offers",
1620 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1621 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1622 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1623 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1624 "200",
1625 "0",
1626 "MyMarker",
1627 "extra"},
1629 R"({
1630 "method" : "book_offers",
1631 "params" : [
1632 {
1633 "error" : "badSyntax",
1634 "error_code" : 1,
1635 "error_message" : "Syntax error."
1636 }
1637 ]
1638 })"},
1639
1640 {"book_offers: taker pays no currency.",
1641 __LINE__,
1642 {
1643 "book_offers",
1644 "/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1645 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1646 },
1648 R"({
1649 "method" : "book_offers",
1650 "params" : [
1651 {
1652 "error" : "invalidParams",
1653 "error_code" : 31,
1654 "error_message" : "Invalid currency/issuer '/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'"
1655 }
1656 ]
1657 })"},
1658 {"book_offers: taker gets no currency.",
1659 __LINE__,
1660 {
1661 "book_offers",
1662 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1663 "/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1664 },
1666 R"({
1667 "method" : "book_offers",
1668 "params" : [
1669 {
1670 "error" : "invalidParams",
1671 "error_code" : 31,
1672 "error_message" : "Invalid currency/issuer '/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA'"
1673 }
1674 ]
1675 })"},
1676 {"book_offers: invalid issuer.",
1677 __LINE__,
1678 {"book_offers", "USD", "EUR", "not_a_valid_issuer"},
1680 R"({
1681 "method" : "book_offers",
1682 "params" : [
1683 {
1684 "api_version" : %API_VER%,
1685 "issuer" : "not_a_valid_issuer",
1686 "taker_gets" : {
1687 "currency" : "EUR"
1688 },
1689 "taker_pays" : {
1690 "currency" : "USD"
1691 }
1692 }
1693 ]
1694 })"},
1695 {"book_offers: invalid text ledger index.",
1696 __LINE__,
1697 {"book_offers",
1698 "USD",
1699 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1700 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1701 "not_a_ledger"},
1703 R"({
1704 "method" : "book_offers",
1705 "params" : [
1706 {
1707 "api_version" : %API_VER%,
1708 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1709 "ledger_index" : 0,
1710 "taker_gets" : {
1711 "currency" : "EUR",
1712 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1713 },
1714 "taker_pays" : {
1715 "currency" : "USD"
1716 }
1717 }
1718 ]
1719 })"},
1720 {// Note: this really shouldn't throw, but does at the moment.
1721 "book_offers: non-numeric limit.",
1722 __LINE__,
1723 {
1724 "book_offers",
1725 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1726 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1727 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1728 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1729 "not_a_number",
1730 },
1732 R"({
1733 "method" : "book_offers",
1734 "params" : [
1735 {
1736 "error" : "invalidParams",
1737 "error_code" : 31,
1738 "error_message" : "Invalid field 'limit'."
1739 }
1740 ]
1741 })"},
1742
1743 // can_delete
1744 // ------------------------------------------------------------------
1745 {"can_delete: minimal.",
1746 __LINE__,
1747 {
1748 "can_delete",
1749 },
1751 R"({
1752 "method" : "can_delete",
1753 "params" : [
1754 {
1755 "api_version" : %API_VER%,
1756 }
1757 ]
1758 })"},
1759 {"can_delete: ledger index.",
1760 __LINE__,
1761 {
1762 "can_delete",
1763 "4294967295",
1764 },
1766 R"({
1767 "method" : "can_delete",
1768 "params" : [
1769 {
1770 "api_version" : %API_VER%,
1771 "can_delete" : 4294967295
1772 }
1773 ]
1774 })"},
1775 {"can_delete: ledger hash.",
1776 __LINE__,
1777 {
1778 "can_delete",
1779 "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210",
1780 },
1782 R"({
1783 "method" : "can_delete",
1784 "params" : [
1785 {
1786 "api_version" : %API_VER%,
1787 "can_delete" : "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210"
1788 }
1789 ]
1790 })"},
1791 {"can_delete: always.",
1792 __LINE__,
1793 {
1794 "can_delete",
1795 "always",
1796 },
1798 R"({
1799 "method" : "can_delete",
1800 "params" : [
1801 {
1802 "api_version" : %API_VER%,
1803 "can_delete" : "always"
1804 }
1805 ]
1806 })"},
1807 {"can_delete: never.",
1808 __LINE__,
1809 {
1810 "can_delete",
1811 "never",
1812 },
1814 R"({
1815 "method" : "can_delete",
1816 "params" : [
1817 {
1818 "api_version" : %API_VER%,
1819 "can_delete" : "never"
1820 }
1821 ]
1822 })"},
1823 {"can_delete: now.",
1824 __LINE__,
1825 {
1826 "can_delete",
1827 "now",
1828 },
1830 R"({
1831 "method" : "can_delete",
1832 "params" : [
1833 {
1834 "api_version" : %API_VER%,
1835 "can_delete" : "now"
1836 }
1837 ]
1838 })"},
1839 {"can_delete: too many arguments.",
1840 __LINE__,
1841 {"can_delete", "always", "never"},
1843 R"({
1844 "method" : "can_delete",
1845 "params" : [
1846 {
1847 "error" : "badSyntax",
1848 "error_code" : 1,
1849 "error_message" : "Syntax error."
1850 }
1851 ]
1852 })"},
1853 {"can_delete: invalid argument.",
1854 __LINE__,
1855 {"can_delete", "invalid"},
1857 R"({
1858 "method" : "can_delete",
1859 "params" : [
1860 {
1861 "api_version" : %API_VER%,
1862 "can_delete" : "invalid"
1863 }
1864 ]
1865 })"},
1866 {// Note: this should return an error but not throw.
1867 "can_delete: ledger index > 32 bits.",
1868 __LINE__,
1869 {
1870 "can_delete",
1871 "4294967296",
1872 },
1874 R"()"},
1875 {// Note: this really shouldn't throw since it's a legitimate ledger hash.
1876 "can_delete: ledger hash with no alphas.",
1877 __LINE__,
1878 {
1879 "can_delete",
1880 "0123456701234567012345670123456701234567012345670123456701234567",
1881 },
1883 R"()"},
1884
1885 // channel_authorize
1886 // -----------------------------------------------------------
1887 {"channel_authorize: minimal.",
1888 __LINE__,
1889 {"channel_authorize",
1890 "secret_can_be_anything",
1891 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
1892 "18446744073709551615"},
1894 R"({
1895 "method" : "channel_authorize",
1896 "params" : [
1897 {
1898 "api_version" : %API_VER%,
1899 "amount" : "18446744073709551615",
1900 "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
1901 "secret" : "secret_can_be_anything"
1902 }
1903 ]
1904 })"},
1905 {"channel_authorize: too few arguments.",
1906 __LINE__,
1907 {
1908 "channel_authorize",
1909 "secret_can_be_anything",
1910 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
1911 },
1913 R"({
1914 "method" : "channel_authorize",
1915 "params" : [
1916 {
1917 "error" : "badSyntax",
1918 "error_code" : 1,
1919 "error_message" : "Syntax error."
1920 }
1921 ]
1922 })"},
1923 {"channel_authorize: too many arguments.",
1924 __LINE__,
1925 {"channel_authorize",
1926 "secp256k1",
1927 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
1928 "2000",
1929 "whatever",
1930 "whenever"},
1932 R"({
1933 "method" : "channel_authorize",
1934 "params" : [
1935 {
1936 "error" : "badSyntax",
1937 "error_code" : 1,
1938 "error_message" : "Syntax error."
1939 }
1940 ]
1941 })"},
1942 {"channel_authorize: bad key type.",
1943 __LINE__,
1944 {"channel_authorize",
1945 "secp257k1",
1946 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
1947 "2000",
1948 "whatever"},
1950 R"({
1951 "method" : "channel_authorize",
1952 "params" : [
1953 {
1954 "error" : "badKeyType",
1955 "error_code" : 1,
1956 "error_message" : "Bad key type."
1957 }
1958 ]
1959 })"},
1960 {"channel_authorize: channel_id too short.",
1961 __LINE__,
1962 {"channel_authorize",
1963 "secret_can_be_anything",
1964 "123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
1965 "2000"},
1967 R"({
1968 "method" : "channel_authorize",
1969 "params" : [
1970 {
1971 "error" : "channelMalformed",
1972 "error_code" : 43,
1973 "error_message" : "Payment channel is malformed."
1974 }
1975 ]
1976 })"},
1977 {"channel_authorize: channel_id too long.",
1978 __LINE__,
1979 {"channel_authorize",
1980 "secret_can_be_anything",
1981 "10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
1982 "2000"},
1984 R"({
1985 "method" : "channel_authorize",
1986 "params" : [
1987 {
1988 "error" : "channelMalformed",
1989 "error_code" : 43,
1990 "error_message" : "Payment channel is malformed."
1991 }
1992 ]
1993 })"},
1994 {"channel_authorize: channel_id not hex.",
1995 __LINE__,
1996 {"channel_authorize",
1997 "secret_can_be_anything",
1998 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEZ",
1999 "2000"},
2001 R"({
2002 "method" : "channel_authorize",
2003 "params" : [
2004 {
2005 "error" : "channelMalformed",
2006 "error_code" : 43,
2007 "error_message" : "Payment channel is malformed."
2008 }
2009 ]
2010 })"},
2011 {"channel_authorize: negative amount.",
2012 __LINE__,
2013 {"channel_authorize",
2014 "secret_can_be_anything",
2015 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2016 "-1"},
2018 R"({
2019 "method" : "channel_authorize",
2020 "params" : [
2021 {
2022 "error" : "channelAmtMalformed",
2023 "error_code" : 44,
2024 "error_message" : "Payment channel amount is malformed."
2025 }
2026 ]
2027 })"},
2028 {"channel_authorize: amount > 64 bits.",
2029 __LINE__,
2030 {"channel_authorize",
2031 "secret_can_be_anything",
2032 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2033 "18446744073709551616"},
2035 R"({
2036 "method" : "channel_authorize",
2037 "params" : [
2038 {
2039 "error" : "channelAmtMalformed",
2040 "error_code" : 44,
2041 "error_message" : "Payment channel amount is malformed."
2042 }
2043 ]
2044 })"},
2045
2046 // channel_verify
2047 // --------------------------------------------------------------
2048 {"channel_verify: public key.",
2049 __LINE__,
2050 {"channel_verify",
2051 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2052 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2053 "0",
2054 "DEADBEEF"},
2056 R"({
2057 "method" : "channel_verify",
2058 "params" : [
2059 {
2060 "api_version" : %API_VER%,
2061 "amount" : "0",
2062 "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2063 "public_key" : "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2064 "signature" : "DEADBEEF"
2065 }
2066 ]
2067 })"},
2068 {"channel_verify: public key hex.",
2069 __LINE__,
2070 {"channel_verify",
2071 "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2072 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2073 "18446744073709551615",
2074 "DEADBEEF"},
2076 R"({
2077 "method" : "channel_verify",
2078 "params" : [
2079 {
2080 "api_version" : %API_VER%,
2081 "amount" : "18446744073709551615",
2082 "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2083 "public_key" : "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2084 "signature" : "DEADBEEF"
2085 }
2086 ]
2087 })"},
2088 {"channel_verify: too few arguments.",
2089 __LINE__,
2090 {"channel_verify",
2091 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2092 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
2094 R"({
2095 "method" : "channel_verify",
2096 "params" : [
2097 {
2098 "error" : "badSyntax",
2099 "error_code" : 1,
2100 "error_message" : "Syntax error."
2101 }
2102 ]
2103 })"},
2104 {"channel_verify: too many arguments.",
2105 __LINE__,
2106 {"channel_verify",
2107 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2108 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2109 "2000",
2110 "DEADBEEF",
2111 "Whatever"},
2113 R"({
2114 "method" : "channel_verify",
2115 "params" : [
2116 {
2117 "error" : "badSyntax",
2118 "error_code" : 1,
2119 "error_message" : "Syntax error."
2120 }
2121 ]
2122 })"},
2123 {"channel_verify: malformed public key.",
2124 __LINE__,
2125 {"channel_verify",
2126 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9GoV",
2127 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2128 "2000",
2129 "DEADBEEF"},
2131 R"({
2132 "method" : "channel_verify",
2133 "params" : [
2134 {
2135 "error" : "publicMalformed",
2136 "error_code" : 60,
2137 "error_message" : "Public key is malformed."
2138 }
2139 ]
2140 })"},
2141 {"channel_verify: malformed hex public key.",
2142 __LINE__,
2143 {"channel_verify",
2144 "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F",
2145 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2146 "2000",
2147 "DEADBEEF"},
2149 R"({
2150 "method" : "channel_verify",
2151 "params" : [
2152 {
2153 "error" : "publicMalformed",
2154 "error_code" : 60,
2155 "error_message" : "Public key is malformed."
2156 }
2157 ]
2158 })"},
2159 {"channel_verify: invalid channel id.",
2160 __LINE__,
2161 {"channel_verify",
2162 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2163 "10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2164 "2000",
2165 "DEADBEEF"},
2167 R"({
2168 "method" : "channel_verify",
2169 "params" : [
2170 {
2171 "error" : "channelMalformed",
2172 "error_code" : 43,
2173 "error_message" : "Payment channel is malformed."
2174 }
2175 ]
2176 })"},
2177 {"channel_verify: short channel id.",
2178 __LINE__,
2179 {"channel_verify",
2180 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2181 "123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2182 "2000",
2183 "DEADBEEF"},
2185 R"({
2186 "method" : "channel_verify",
2187 "params" : [
2188 {
2189 "error" : "channelMalformed",
2190 "error_code" : 43,
2191 "error_message" : "Payment channel is malformed."
2192 }
2193 ]
2194 })"},
2195 {"channel_verify: amount too small.",
2196 __LINE__,
2197 {"channel_verify",
2198 "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2199 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2200 "-1",
2201 "DEADBEEF"},
2203 R"({
2204 "method" : "channel_verify",
2205 "params" : [
2206 {
2207 "error" : "channelAmtMalformed",
2208 "error_code" : 44,
2209 "error_message" : "Payment channel amount is malformed."
2210 }
2211 ]
2212 })"},
2213 {"channel_verify: amount too large.",
2214 __LINE__,
2215 {"channel_verify",
2216 "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2217 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2218 "18446744073709551616",
2219 "DEADBEEF"},
2221 R"({
2222 "method" : "channel_verify",
2223 "params" : [
2224 {
2225 "error" : "channelAmtMalformed",
2226 "error_code" : 44,
2227 "error_message" : "Payment channel amount is malformed."
2228 }
2229 ]
2230 })"},
2231 {"channel_verify: non-hex signature.",
2232 __LINE__,
2233 {"channel_verify",
2234 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2235 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2236 "40000000",
2237 "ThisIsNotHexadecimal"},
2239 R"({
2240 "method" : "channel_verify",
2241 "params" : [
2242 {
2243 "api_version" : %API_VER%,
2244 "amount" : "40000000",
2245 "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2246 "public_key" : "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2247 "signature" : "ThisIsNotHexadecimal"
2248 }
2249 ]
2250 })"},
2251
2252 // connect
2253 // ---------------------------------------------------------------------
2254 {"connect: minimal.",
2255 __LINE__,
2256 {
2257 "connect",
2258 "ThereIsNoCheckingOnTheIPFormat",
2259 },
2261 R"({
2262 "method" : "connect",
2263 "params" : [
2264 {
2265 "api_version" : %API_VER%,
2266 "ip" : "ThereIsNoCheckingOnTheIPFormat"
2267 }
2268 ]
2269 })"},
2270 {"connect: ip and port.",
2271 __LINE__,
2272 {"connect", "ThereIsNoCheckingOnTheIPFormat", "6561"},
2274 R"({
2275 "method" : "connect",
2276 "params" : [
2277 {
2278 "api_version" : %API_VER%,
2279 "ip" : "ThereIsNoCheckingOnTheIPFormat",
2280 "port" : 6561
2281 }
2282 ]
2283 })"},
2284 {"connect: too few arguments.",
2285 __LINE__,
2286 {
2287 "connect",
2288 },
2290 R"({
2291 "method" : "connect",
2292 "params" : [
2293 {
2294 "error" : "badSyntax",
2295 "error_code" : 1,
2296 "error_message" : "Syntax error."
2297 }
2298 ]
2299 })"},
2300 {"connect: too many arguments.",
2301 __LINE__,
2302 {"connect", "ThereIsNoCheckingOnTheIPFormat", "6561", "extra"},
2304 R"({
2305 "method" : "connect",
2306 "params" : [
2307 {
2308 "error" : "badSyntax",
2309 "error_code" : 1,
2310 "error_message" : "Syntax error."
2311 }
2312 ]
2313 })"},
2314 {// Note: this should return an error but not throw.
2315 "connect: port too small.",
2316 __LINE__,
2317 {
2318 "connect",
2319 "ThereIsNoCheckingOnTheIPFormat",
2320 "-1",
2321 },
2323 R"()"},
2324 {// Note: this should return an error but not throw.
2325 "connect: port too large.",
2326 __LINE__,
2327 {
2328 "connect",
2329 "ThereIsNoCheckingOnTheIPFormat",
2330 "4294967296",
2331 },
2333 R"()"},
2334
2335 // consensus_info
2336 // --------------------------------------------------------------
2337 {"consensus_info: minimal.",
2338 __LINE__,
2339 {
2340 "consensus_info",
2341 },
2343 R"({
2344 "method" : "consensus_info",
2345 "params" : [
2346 {
2347 "api_version" : %API_VER%
2348 }
2349 ]
2350 })"},
2351 {"consensus_info: too many arguments.",
2352 __LINE__,
2353 {"consensus_info", "whatever"},
2355 R"({
2356 "method" : "consensus_info",
2357 "params" : [
2358 {
2359 "error" : "badSyntax",
2360 "error_code" : 1,
2361 "error_message" : "Syntax error."
2362 }
2363 ]
2364 })"},
2365
2366 // deposit_authorized
2367 // ----------------------------------------------------------
2368 {"deposit_authorized: minimal.",
2369 __LINE__,
2370 {
2371 "deposit_authorized",
2372 "source_account_NotValidated",
2373 "destination_account_NotValidated",
2374 },
2376 R"({
2377 "method" : "deposit_authorized",
2378 "params" : [
2379 {
2380 "api_version" : %API_VER%,
2381 "destination_account" : "destination_account_NotValidated",
2382 "source_account" : "source_account_NotValidated"
2383 }
2384 ]
2385 })"},
2386 {"deposit_authorized: with text ledger index.",
2387 __LINE__,
2388 {"deposit_authorized",
2389 "source_account_NotValidated",
2390 "destination_account_NotValidated",
2391 "validated"},
2393 R"({
2394 "method" : "deposit_authorized",
2395 "params" : [
2396 {
2397 "api_version" : %API_VER%,
2398 "destination_account" : "destination_account_NotValidated",
2399 "ledger_index" : "validated",
2400 "source_account" : "source_account_NotValidated"
2401 }
2402 ]
2403 })"},
2404 {"deposit_authorized: with ledger index.",
2405 __LINE__,
2406 {"deposit_authorized",
2407 "source_account_NotValidated",
2408 "destination_account_NotValidated",
2409 "4294967295",
2410 "cred1",
2411 "cred2",
2412 "cred3",
2413 "cred4",
2414 "cred5",
2415 "cred6",
2416 "cred7",
2417 "cred8"},
2419 R"({
2420 "method" : "deposit_authorized",
2421 "params" : [
2422 {
2423 "api_version" : %API_VER%,
2424 "destination_account" : "destination_account_NotValidated",
2425 "ledger_index" : 4294967295,
2426 "source_account" : "source_account_NotValidated",
2427 "credentials": ["cred1", "cred2", "cred3", "cred4", "cred5", "cred6", "cred7", "cred8"]
2428 }
2429 ]
2430 })"},
2431 {"deposit_authorized: with ledger hash.",
2432 __LINE__,
2433 {"deposit_authorized",
2434 "source_account_NotValidated",
2435 "destination_account_NotValidated",
2436 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
2438 R"({
2439 "method" : "deposit_authorized",
2440 "params" : [
2441 {
2442 "api_version" : %API_VER%,
2443 "destination_account" : "destination_account_NotValidated",
2444 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
2445 "source_account" : "source_account_NotValidated"
2446 }
2447 ]
2448 })"},
2449 {"deposit_authorized: too few arguments.",
2450 __LINE__,
2451 {
2452 "deposit_authorized",
2453 "source_account_NotValidated",
2454 },
2456 R"({
2457 "method" : "deposit_authorized",
2458 "params" : [
2459 {
2460 "error" : "badSyntax",
2461 "error_code" : 1,
2462 "error_message" : "Syntax error."
2463 }
2464 ]
2465 })"},
2466 {"deposit_authorized: too many arguments.",
2467 __LINE__,
2468 {"deposit_authorized",
2469 "source_account_NotValidated",
2470 "destination_account_NotValidated",
2471 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
2472 "cred1",
2473 "cred2",
2474 "cred3",
2475 "cred4",
2476 "cred5",
2477 "cred6",
2478 "cred7",
2479 "cred8",
2480 "too_much"},
2482 R"({
2483 "method" : "deposit_authorized",
2484 "params" : [
2485 {
2486 "error" : "badSyntax",
2487 "error_code" : 1,
2488 "error_message" : "Syntax error."
2489 }
2490 ]
2491 })"},
2492 {"deposit_authorized: invalid ledger selection.",
2493 __LINE__,
2494 {
2495 "deposit_authorized",
2496 "source_account_NotValidated",
2497 "destination_account_NotValidated",
2498 "NotALedger",
2499 },
2501 R"({
2502 "method" : "deposit_authorized",
2503 "params" : [
2504 {
2505 "api_version" : %API_VER%,
2506 "destination_account" : "destination_account_NotValidated",
2507 "ledger_index" : 0,
2508 "source_account" : "source_account_NotValidated"
2509 }
2510 ]
2511 })"},
2512
2513 // feature
2514 // ---------------------------------------------------------------------
2515 {"feature: minimal.",
2516 __LINE__,
2517 {
2518 "feature",
2519 },
2521 R"({
2522 "method" : "feature",
2523 "params" : [
2524 {
2525 "api_version" : %API_VER%,
2526 }
2527 ]
2528 })"},
2529 {"feature: with name.",
2530 __LINE__,
2531 {"feature", "featureNameOrHexIsNotValidated"},
2533 R"({
2534 "method" : "feature",
2535 "params" : [
2536 {
2537 "api_version" : %API_VER%,
2538 "feature" : "featureNameOrHexIsNotValidated"
2539 }
2540 ]
2541 })"},
2542 {"feature: accept.",
2543 __LINE__,
2544 {"feature",
2545 "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA98"
2546 "76543210",
2547 "accept"},
2549 R"({
2550 "method" : "feature",
2551 "params" : [
2552 {
2553 "api_version" : %API_VER%,
2554 "feature" : "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210",
2555 "vetoed" : false
2556 }
2557 ]
2558 })"},
2559 {"feature: reject.",
2560 __LINE__,
2561 {"feature", "0", "reject"},
2563 R"({
2564 "method" : "feature",
2565 "params" : [
2566 {
2567 "api_version" : %API_VER%,
2568 "feature" : "0",
2569 "vetoed" : true
2570 }
2571 ]
2572 })"},
2573 {"feature: too many arguments.",
2574 __LINE__,
2575 {"feature", "featureNameOrHexIsNotValidated", "accept", "anotherArg"},
2577 R"({
2578 "method" : "feature",
2579 "params" : [
2580 {
2581 "error" : "badSyntax",
2582 "error_code" : 1,
2583 "error_message" : "Syntax error."
2584 }
2585 ]
2586 })"},
2587 {"feature: neither accept nor reject.",
2588 __LINE__,
2589 {
2590 "feature",
2591 "featureNameOrHexIsNotValidated",
2592 "veto",
2593 },
2595 R"({
2596 "method" : "feature",
2597 "params" : [
2598 {
2599 "error" : "invalidParams",
2600 "error_code" : 31,
2601 "error_message" : "Invalid parameters."
2602 }
2603 ]
2604 })"},
2605
2606 // fetch_info
2607 // ------------------------------------------------------------------
2608 {"fetch_info: minimal.",
2609 __LINE__,
2610 {
2611 "fetch_info",
2612 },
2614 R"({
2615 "method" : "fetch_info",
2616 "params" : [
2617 {
2618 "api_version" : %API_VER%,
2619 }
2620 ]
2621 })"},
2622 {"fetch_info: clear.",
2623 __LINE__,
2624 {"fetch_info", "clear"},
2626 R"({
2627 "method" : "fetch_info",
2628 "params" : [
2629 {
2630 "api_version" : %API_VER%,
2631 "clear" : true
2632 }
2633 ]
2634 })"},
2635 {"fetch_info: too many arguments.",
2636 __LINE__,
2637 {"fetch_info", "clear", "other"},
2639 R"({
2640 "method" : "fetch_info",
2641 "params" : [
2642 {
2643 "error" : "badSyntax",
2644 "error_code" : 1,
2645 "error_message" : "Syntax error."
2646 }
2647 ]
2648 })"},
2649 {"fetch_info: other trailing argument.",
2650 __LINE__,
2651 {"fetch_info", "too"},
2653 R"({
2654 "method" : "fetch_info",
2655 "params" : [
2656 {
2657 "api_version" : %API_VER%,
2658 "too" : true
2659 }
2660 ]
2661 })"},
2662
2663 // gateway_balances
2664 // ------------------------------------------------------------
2665 {"gateway_balances: minimal.",
2666 __LINE__,
2667 {"gateway_balances", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
2669 R"({
2670 "method" : "gateway_balances",
2671 "params" : [
2672 {
2673 "api_version" : %API_VER%,
2674 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2675 }
2676 ]
2677 })"},
2678 {"gateway_balances: with ledger index.",
2679 __LINE__,
2680 {"gateway_balances", "890765", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
2682 R"({
2683 "method" : "gateway_balances",
2684 "params" : [
2685 {
2686 "api_version" : %API_VER%,
2687 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2688 "ledger_index" : "890765"
2689 }
2690 ]
2691 })"},
2692 {"gateway_balances: with text ledger index.",
2693 __LINE__,
2694 {"gateway_balances", "current", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
2696 R"({
2697 "method" : "gateway_balances",
2698 "params" : [
2699 {
2700 "api_version" : %API_VER%,
2701 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2702 "ledger_index" : "current"
2703 }
2704 ]
2705 })"},
2706 {"gateway_balances: with 64 character ledger hash.",
2707 __LINE__,
2708 {"gateway_balances",
2709 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
2710 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
2712 R"({
2713 "method" : "gateway_balances",
2714 "params" : [
2715 {
2716 "api_version" : %API_VER%,
2717 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2718 "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
2719 }
2720 ]
2721 })"},
2722 {"gateway_balances: 1 hotwallet.",
2723 __LINE__,
2724 {"gateway_balances", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "hotwallet_is_not_validated"},
2726 R"({
2727 "method" : "gateway_balances",
2728 "params" : [
2729 {
2730 "api_version" : %API_VER%,
2731 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2732 "hotwallet" : [ "hotwallet_is_not_validated" ]
2733 }
2734 ]
2735 })"},
2736 {"gateway_balances: 3 hotwallets.",
2737 __LINE__,
2738 {
2739 "gateway_balances",
2740 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
2741 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2742 "hotwallet_is_not_validated_1",
2743 "hotwallet_is_not_validated_2",
2744 "hotwallet_is_not_validated_3",
2745 },
2747 R"({
2748 "method" : "gateway_balances",
2749 "params" : [
2750 {
2751 "api_version" : %API_VER%,
2752 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2753 "hotwallet" : [
2754 "hotwallet_is_not_validated_1",
2755 "hotwallet_is_not_validated_2",
2756 "hotwallet_is_not_validated_3"
2757 ],
2758 "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
2759 }
2760 ]
2761 })"},
2762 {"gateway_balances: too few arguments.",
2763 __LINE__,
2764 {
2765 "gateway_balances",
2766 },
2768 R"({
2769 "method" : "gateway_balances",
2770 "params" : [
2771 {
2772 "error" : "badSyntax",
2773 "error_code" : 1,
2774 "error_message" : "Syntax error."
2775 }
2776 ]
2777 })"},
2778 {"gateway_balances: empty first argument.",
2779 __LINE__,
2780 {"gateway_balances", ""},
2782 R"({
2783 "method" : "gateway_balances",
2784 "params" : [
2785 {
2786 "error" : "invalidParams",
2787 "error_code" : 31,
2788 "error_message" : "Invalid first parameter"
2789 }
2790 ]
2791 })"},
2792 {"gateway_balances: with ledger index but no gateway.",
2793 __LINE__,
2794 {
2795 "gateway_balances",
2796 "890765",
2797 },
2799 R"({
2800 "method" : "gateway_balances",
2801 "params" : [
2802 {
2803 "error" : "invalidParams",
2804 "error_code" : 31,
2805 "error_message" : "Invalid hotwallet"
2806 }
2807 ]
2808 })"},
2809 {"gateway_balances: with text ledger index but no gateway.",
2810 __LINE__,
2811 {
2812 "gateway_balances",
2813 "current",
2814 },
2816 R"({
2817 "method" : "gateway_balances",
2818 "params" : [
2819 {
2820 "error" : "invalidParams",
2821 "error_code" : 31,
2822 "error_message" : "Invalid hotwallet"
2823 }
2824 ]
2825 })"},
2826 {"gateway_balances: with 64 character ledger hash but no gateway.",
2827 __LINE__,
2828 {
2829 "gateway_balances",
2830 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
2831 },
2833 R"({
2834 "method" : "gateway_balances",
2835 "params" : [
2836 {
2837 "error" : "invalidParams",
2838 "error_code" : 31,
2839 "error_message" : "Invalid hotwallet"
2840 }
2841 ]
2842 })"},
2843
2844 // get_counts
2845 // ------------------------------------------------------------------
2846 {"get_counts: minimal.",
2847 __LINE__,
2848 {
2849 "get_counts",
2850 },
2852 R"({
2853 "method" : "get_counts",
2854 "params" : [
2855 {
2856 "api_version" : %API_VER%,
2857 }
2858 ]
2859 })"},
2860 {"get_counts: with maximum count.",
2861 __LINE__,
2862 {"get_counts", "100"},
2864 R"({
2865 "method" : "get_counts",
2866 "params" : [
2867 {
2868 "api_version" : %API_VER%,
2869 "min_count" : 100
2870 }
2871 ]
2872 })"},
2873 {"get_counts: too many arguments.",
2874 __LINE__,
2875 {"get_counts", "100", "whatever"},
2877 R"({
2878 "method" : "get_counts",
2879 "params" : [
2880 {
2881 "error" : "badSyntax",
2882 "error_code" : 1,
2883 "error_message" : "Syntax error."
2884 }
2885 ]
2886 })"},
2887 {"get_counts: count too small.",
2888 __LINE__,
2889 {
2890 "get_counts",
2891 "-1",
2892 },
2894 R"()"},
2895 {"get_counts: count too large.",
2896 __LINE__,
2897 {"get_counts", "4294967296"},
2899 R"()"},
2900
2901 // json
2902 // ------------------------------------------------------------------------
2903 {"json: minimal.",
2904 __LINE__,
2905 {
2906 "json",
2907 "command",
2908 R"({"json_argument":true})",
2909 },
2911 R"({
2912 "method" : "command",
2913 "params" : [
2914 {
2915 "api_version" : %API_VER%,
2916 "json_argument" : true,
2917 "method" : "command"
2918 }
2919 ]
2920 })"},
2921 {"json: null object.",
2922 __LINE__,
2923 {
2924 "json",
2925 "command",
2926 R"({})",
2927 },
2929 R"({
2930 "method" : "command",
2931 "params" : [
2932 {
2933 "api_version" : %API_VER%,
2934 "method" : "command"
2935 }
2936 ]
2937 })"},
2938 {"json: too few arguments.",
2939 __LINE__,
2940 {"json", "command"},
2942 R"({
2943 "method" : "json",
2944 "params" : [
2945 {
2946 "error" : "badSyntax",
2947 "error_code" : 1,
2948 "error_message" : "Syntax error."
2949 }
2950 ]
2951 })"},
2952 {"json: too many arguments.",
2953 __LINE__,
2954 {"json", "command", R"({"json_argument":true})", "extra"},
2956 R"({
2957 "method" : "json",
2958 "params" : [
2959 {
2960 "error" : "badSyntax",
2961 "error_code" : 1,
2962 "error_message" : "Syntax error."
2963 }
2964 ]
2965 })"},
2966 {"json: array, not object.",
2967 __LINE__,
2968 {
2969 "json",
2970 "command",
2971 R"(["arg1","arg2"])",
2972 },
2974 R"({
2975 "method" : "json",
2976 "params" : [
2977 {
2978 "error" : "invalidParams",
2979 "error_code" : 31,
2980 "error_message" : "Invalid parameters."
2981 }
2982 ]
2983 })"},
2984 {"json: invalid json (note closing comma).",
2985 __LINE__,
2986 {
2987 "json",
2988 "command",
2989 R"({"json_argument":true,})",
2990 },
2992 R"({
2993 "method" : "json",
2994 "params" : [
2995 {
2996 "error" : "invalidParams",
2997 "error_code" : 31,
2998 "error_message" : "Invalid parameters."
2999 }
3000 ]
3001 })"},
3002
3003 // json2
3004 // -----------------------------------------------------------------------
3005 {"json2: minimal object.",
3006 __LINE__,
3007 {
3008 "json2",
3009 R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1"})",
3010 },
3012 R"({
3013 "id" : "A1",
3014 "jsonrpc" : "2.0",
3015 "method" : "call_1",
3016 "params" : [
3017 {
3018 "api_version" : %API_VER%,
3019 "id" : "A1",
3020 "jsonrpc" : "2.0",
3021 "method" : "call_1",
3022 "ripplerpc" : "2.0"
3023 }
3024 ],
3025 "ripplerpc" : "2.0"
3026 })"},
3027 {"json2: object with nested params.",
3028 __LINE__,
3029 {
3030 "json2",
3031 R"({
3032 "jsonrpc" : "2.0",
3033 "ripplerpc" : "2.0",
3034 "id" : "A1",
3035 "method" : "call_1",
3036 "params" : [{"inner_arg" : "yup"}]
3037 })",
3038 },
3040 R"({
3041 "id" : "A1",
3042 "jsonrpc" : "2.0",
3043 "method" : "call_1",
3044 "params" : [
3045 {
3046 "api_version" : %API_VER%,
3047 "0" : {
3048 "inner_arg" : "yup"
3049 },
3050 "id" : "A1",
3051 "jsonrpc" : "2.0",
3052 "method" : "call_1",
3053 "ripplerpc" : "2.0"
3054 }
3055 ],
3056 "ripplerpc" : "2.0"
3057 })"},
3058 {"json2: minimal array.",
3059 __LINE__,
3060 {
3061 "json2",
3062 R"([{"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1"}])",
3063 },
3065 R"({
3066 "method" : "json2",
3067 "params" : [
3068 [
3069 {
3070 "api_version" : %API_VER%,
3071 "id" : "A1",
3072 "jsonrpc" : "2.0",
3073 "method" : "call_1",
3074 "ripplerpc" : "2.0"
3075 }
3076 ]
3077 ]
3078 })"},
3079 {"json2: array with object with nested params.",
3080 __LINE__,
3081 {
3082 "json2",
3083 R"([
3084 {"jsonrpc":"2.0",
3085 "ripplerpc":"2.0",
3086 "id":"A1",
3087 "method":"call_1",
3088 "params" : [{"inner_arg" : "yup"}]}
3089 ])",
3090 },
3092 R"({
3093 "method" : "json2",
3094 "params" : [
3095 [
3096 {
3097 "api_version" : %API_VER%,
3098 "0" : {
3099 "inner_arg" : "yup"
3100 },
3101 "id" : "A1",
3102 "jsonrpc" : "2.0",
3103 "method" : "call_1",
3104 "ripplerpc" : "2.0"
3105 }
3106 ]
3107 ]})"},
3108 {"json2: too few arguments.",
3109 __LINE__,
3110 {
3111 "json2",
3112 },
3114 R"({
3115 "method" : "json2",
3116 "params" : [
3117 {
3118 "error" : "badSyntax",
3119 "error_code" : 1,
3120 "error_message" : "Syntax error."
3121 }
3122 ]
3123 })"},
3124 {"json2: too many arguments.",
3125 __LINE__,
3126 {"json2", R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_this"})", "extra"},
3128 R"({
3129 "method" : "json2",
3130 "params" : [
3131 {
3132 "error" : "badSyntax",
3133 "error_code" : 1,
3134 "error_message" : "Syntax error."
3135 }
3136 ]
3137 })"},
3138 {"json2: malformed json (note extra comma).",
3139 __LINE__,
3140 {
3141 "json2",
3142 R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1",})",
3143 },
3145 R"({
3146 "id" : "A1",
3147 "jsonrpc" : "2.0",
3148 "method" : "json2",
3149 "params" : [
3150 {
3151 "error" : "invalidParams",
3152 "error_code" : 31,
3153 "error_message" : "Invalid parameters.",
3154 "id" : "A1",
3155 "jsonrpc" : "2.0",
3156 "ripplerpc" : "2.0"
3157 }
3158 ],
3159 "ripplerpc" : "2.0"
3160 })"},
3161 {"json2: omit jsonrpc.",
3162 __LINE__,
3163 {
3164 "json2",
3165 R"({"ripplerpc":"2.0","id":"A1","method":"call_1"})",
3166 },
3168 R"({
3169 "id" : "A1",
3170 "method" : "json2",
3171 "params" : [
3172 {
3173 "error" : "invalidParams",
3174 "error_code" : 31,
3175 "error_message" : "Invalid parameters.",
3176 "id" : "A1",
3177 "ripplerpc" : "2.0"
3178 }
3179 ],
3180 "ripplerpc" : "2.0"
3181 })"},
3182 {"json2: wrong jsonrpc version.",
3183 __LINE__,
3184 {
3185 "json2",
3186 R"({"jsonrpc":"2.1","ripplerpc":"2.0","id":"A1","method":"call_1"})",
3187 },
3189 R"({
3190 "id" : "A1",
3191 "jsonrpc" : "2.1",
3192 "method" : "json2",
3193 "params" : [
3194 {
3195 "error" : "invalidParams",
3196 "error_code" : 31,
3197 "error_message" : "Invalid parameters.",
3198 "id" : "A1",
3199 "jsonrpc" : "2.1",
3200 "ripplerpc" : "2.0"
3201 }
3202 ],
3203 "ripplerpc" : "2.0"
3204 })"},
3205 {"json2: omit ripplerpc.",
3206 __LINE__,
3207 {
3208 "json2",
3209 R"({"jsonrpc":"2.0","id":"A1","method":"call_1"})",
3210 },
3212 R"({
3213 "id" : "A1",
3214 "jsonrpc" : "2.0",
3215 "method" : "json2",
3216 "params" : [
3217 {
3218 "error" : "invalidParams",
3219 "error_code" : 31,
3220 "error_message" : "Invalid parameters.",
3221 "id" : "A1",
3222 "jsonrpc" : "2.0"
3223 }
3224 ]
3225 })"},
3226 {"json2: wrong ripplerpc version.",
3227 __LINE__,
3228 {
3229 "json2",
3230 R"({"jsonrpc":"2.0","ripplerpc":"2.00","id":"A1","method":"call_1"})",
3231 },
3233 R"({
3234 "id" : "A1",
3235 "jsonrpc" : "2.0",
3236 "method" : "json2",
3237 "params" : [
3238 {
3239 "error" : "invalidParams",
3240 "error_code" : 31,
3241 "error_message" : "Invalid parameters.",
3242 "id" : "A1",
3243 "jsonrpc" : "2.0",
3244 "ripplerpc" : "2.00"
3245 }
3246 ],
3247 "ripplerpc" : "2.00"
3248 })"},
3249 {"json2: omit id.",
3250 __LINE__,
3251 {
3252 "json2",
3253 R"({"jsonrpc":"2.0","ripplerpc":"2.0","method":"call_1"})",
3254 },
3256 R"({
3257 "jsonrpc" : "2.0",
3258 "method" : "json2",
3259 "params" : [
3260 {
3261 "error" : "invalidParams",
3262 "error_code" : 31,
3263 "error_message" : "Invalid parameters.",
3264 "jsonrpc" : "2.0",
3265 "ripplerpc" : "2.0"
3266 }
3267 ],
3268 "ripplerpc" : "2.0"
3269 })"},
3270 {"json2: omit method.",
3271 __LINE__,
3272 {
3273 "json2",
3274 R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1"})",
3275 },
3277 R"({
3278 "id" : "A1",
3279 "jsonrpc" : "2.0",
3280 "method" : "json2",
3281 "params" : [
3282 {
3283 "error" : "invalidParams",
3284 "error_code" : 31,
3285 "error_message" : "Invalid parameters.",
3286 "id" : "A1",
3287 "jsonrpc" : "2.0",
3288 "ripplerpc" : "2.0"
3289 }
3290 ],
3291 "ripplerpc" : "2.0"
3292 })"},
3293 {"json2: empty outer array.",
3294 __LINE__,
3295 {
3296 "json2",
3297 R"([])",
3298 },
3300 R"({
3301 "method" : "json2",
3302 "params" : [
3303 {
3304 "error" : "invalidParams",
3305 "error_code" : 31,
3306 "error_message" : "Invalid parameters."
3307 }
3308 ]
3309 })"},
3310 {"json2: empty inner array.",
3311 __LINE__,
3312 {
3313 "json2",
3314 R"([{"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1",[]}])",
3315 },
3317 R"({
3318 "method" : "json2",
3319 "params" : [
3320 {
3321 "error" : "invalidParams",
3322 "error_code" : 31,
3323 "error_message" : "Invalid parameters."
3324 }
3325 ]
3326 })"},
3327 {"json2: array with non-json2 object.",
3328 __LINE__,
3329 {
3330 "json2",
3331 R"([
3332 {"jsonrpc" : "2.1",
3333 "ripplerpc" : "2.0",
3334 "id" : "A1",
3335 "method" : "call_1"
3336 }
3337 ])",
3338 },
3340 R"({
3341 "method" : "json2",
3342 "params" : [
3343 {
3344 "error" : "invalidParams",
3345 "error_code" : 31,
3346 "error_message" : "Invalid parameters."
3347 }
3348 ]
3349 })"},
3350 {"json2: non-object or -array inner params member.",
3351 __LINE__,
3352 {
3353 "json2",
3354 R"({
3355 "jsonrpc" : "2.0",
3356 "ripplerpc" : "2.0",
3357 "id" : "A1",
3358 "method" : "call_1",
3359 "params" : true
3360 })",
3361 },
3363 R"({
3364 "id" : "A1",
3365 "jsonrpc" : "2.0",
3366 "method" : "json2",
3367 "params" : [
3368 {
3369 "error" : "invalidParams",
3370 "error_code" : 31,
3371 "error_message" : "Invalid parameters.",
3372 "id" : "A1",
3373 "jsonrpc" : "2.0",
3374 "ripplerpc" : "2.0"
3375 }
3376 ],
3377 "ripplerpc" : "2.0"
3378 })"},
3379
3380 // ledger
3381 // ----------------------------------------------------------------------
3382 {"ledger: minimal.",
3383 __LINE__,
3384 {"ledger"},
3386 R"({
3387 "method" : "ledger",
3388 "params" : [
3389 {
3390 "api_version" : %API_VER%,
3391 }
3392 ]
3393 })"},
3394 {"ledger: ledger index.",
3395 __LINE__,
3396 {"ledger", "4294967295"},
3398 R"({
3399 "method" : "ledger",
3400 "params" : [
3401 {
3402 "api_version" : %API_VER%,
3403 "ledger_index" : 4294967295
3404 }
3405 ]
3406 })"},
3407 {"ledger: text ledger index.",
3408 __LINE__,
3409 {"ledger", "validated"},
3411 R"({
3412 "method" : "ledger",
3413 "params" : [
3414 {
3415 "api_version" : %API_VER%,
3416 "ledger_index" : "validated"
3417 }
3418 ]
3419 })"},
3420 {"ledger: ledger hash.",
3421 __LINE__,
3422 {"ledger", "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
3424 R"({
3425 "method" : "ledger",
3426 "params" : [
3427 {
3428 "api_version" : %API_VER%,
3429 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
3430 }
3431 ]
3432 })"},
3433 {"ledger: full.",
3434 __LINE__,
3435 {"ledger", "current", "full"},
3437 R"({
3438 "method" : "ledger",
3439 "params" : [
3440 {
3441 "api_version" : %API_VER%,
3442 "full" : true,
3443 "ledger_index" : "current"
3444 }
3445 ]
3446 })"},
3447 {"ledger: tx.",
3448 __LINE__,
3449 {"ledger", "closed", "tx"},
3451 R"({
3452 "method" : "ledger",
3453 "params" : [
3454 {
3455 "api_version" : %API_VER%,
3456 "expand" : true,
3457 "ledger_index" : "closed",
3458 "transactions" : true
3459 }
3460 ]
3461 })"},
3462 {"ledger: too many arguments.",
3463 __LINE__,
3464 {"ledger", "4294967295", "spare"},
3466 R"({
3467 "method" : "ledger",
3468 "params" : [
3469 {
3470 "api_version" : %API_VER%,
3471 "ledger_index" : 4294967295
3472 }
3473 ]
3474 })"},
3475 {"ledger: ledger index too small.",
3476 __LINE__,
3477 {"ledger", "-1"},
3479 R"({
3480 "method" : "ledger",
3481 "params" : [
3482 {
3483 "api_version" : %API_VER%,
3484 "ledger_index" : 0
3485 }
3486 ]
3487 })"},
3488 {"ledger: ledger index too big.",
3489 __LINE__,
3490 {"ledger", "4294967296"},
3492 R"({
3493 "method" : "ledger",
3494 "params" : [
3495 {
3496 "api_version" : %API_VER%,
3497 "ledger_index" : 0
3498 }
3499 ]
3500 })"},
3501 {"ledger: invalid ledger text.",
3502 __LINE__,
3503 {"ledger", "latest"},
3505 R"({
3506 "method" : "ledger",
3507 "params" : [
3508 {
3509 "api_version" : %API_VER%,
3510 "ledger_index" : 0
3511 }
3512 ]
3513 })"},
3514 {"ledger: unsupported final argument.",
3515 __LINE__,
3516 {"ledger", "current", "expand"},
3518 R"({
3519 "method" : "ledger",
3520 "params" : [
3521 {
3522 "api_version" : %API_VER%,
3523 "ledger_index" : "current"
3524 }
3525 ]
3526 })"},
3527
3528 // ledger_closed
3529 // ---------------------------------------------------------------
3530 {"ledger_closed: minimal.",
3531 __LINE__,
3532 {"ledger_closed"},
3534 R"({
3535 "method" : "ledger_closed",
3536 "params" : [
3537 {
3538 "api_version" : %API_VER%,
3539 }
3540 ]
3541 })"},
3542 {"ledger_closed: too many arguments.",
3543 __LINE__,
3544 {"ledger_closed", "today"},
3546 R"({
3547 "method" : "ledger_closed",
3548 "params" : [
3549 {
3550 "error" : "badSyntax",
3551 "error_code" : 1,
3552 "error_message" : "Syntax error."
3553 }
3554 ]
3555 })"},
3556
3557 // ledger_current
3558 // --------------------------------------------------------------
3559 {"ledger_current: minimal.",
3560 __LINE__,
3561 {"ledger_current"},
3563 R"({
3564 "method" : "ledger_current",
3565 "params" : [
3566 {
3567 "api_version" : %API_VER%,
3568 }
3569 ]
3570 })"},
3571 {"ledger_current: too many arguments.",
3572 __LINE__,
3573 {"ledger_current", "today"},
3575 R"({
3576 "method" : "ledger_current",
3577 "params" : [
3578 {
3579 "error" : "badSyntax",
3580 "error_code" : 1,
3581 "error_message" : "Syntax error."
3582 }
3583 ]
3584 })"},
3585
3586 // ledger_header
3587 // ---------------------------------------------------------------
3588 {"ledger_header: ledger index.",
3589 __LINE__,
3590 {"ledger_header", "4294967295"},
3592 R"({
3593 "method" : "ledger_header",
3594 "params" : [
3595 {
3596 "api_version" : %API_VER%,
3597 "ledger_index" : 4294967295
3598 }
3599 ]
3600 })"},
3601 {"ledger_header: ledger hash.",
3602 __LINE__,
3603 {"ledger_header", "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
3605 R"({
3606 "method" : "ledger_header",
3607 "params" : [
3608 {
3609 "api_version" : %API_VER%,
3610 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
3611 }
3612 ]
3613 })"},
3614 {"ledger_header: too few arguments.",
3615 __LINE__,
3616 {
3617 "ledger_header",
3618 },
3620 R"({
3621 "method" : "ledger_header",
3622 "params" : [
3623 {
3624 "error" : "badSyntax",
3625 "error_code" : 1,
3626 "error_message" : "Syntax error."
3627 }
3628 ]
3629 })"},
3630 {"ledger_header: too many arguments.",
3631 __LINE__,
3632 {"ledger_header", "4294967295", "spare"},
3634 R"({
3635 "method" : "ledger_header",
3636 "params" : [
3637 {
3638 "error" : "badSyntax",
3639 "error_code" : 1,
3640 "error_message" : "Syntax error."
3641 }
3642 ]
3643 })"},
3644 {"ledger_header: text ledger index.",
3645 __LINE__,
3646 {"ledger_header", "current"},
3648 R"({
3649 "method" : "ledger_header",
3650 "params" : [
3651 {
3652 "api_version" : %API_VER%,
3653 "ledger_index" : 0
3654 }
3655 ]
3656 })"},
3657 {"ledger_header: ledger index too small.",
3658 __LINE__,
3659 {"ledger_header", "-1"},
3661 R"({
3662 "method" : "ledger_header",
3663 "params" : [
3664 {
3665 "api_version" : %API_VER%,
3666 "ledger_index" : 0
3667 }
3668 ]
3669 })"},
3670 {"ledger_header: ledger index too big.",
3671 __LINE__,
3672 {"ledger_header", "4294967296"},
3674 R"({
3675 "method" : "ledger_header",
3676 "params" : [
3677 {
3678 "api_version" : %API_VER%,
3679 "ledger_index" : 0
3680 }
3681 ]
3682 })"},
3683
3684 // ledger_request
3685 // --------------------------------------------------------------
3686 {"ledger_request: ledger index.",
3687 __LINE__,
3688 {"ledger_request", "4294967295"},
3690 R"({
3691 "method" : "ledger_request",
3692 "params" : [
3693 {
3694 "api_version" : %API_VER%,
3695 "ledger_index" : 4294967295
3696 }
3697 ]
3698 })"},
3699 {"ledger_request: ledger hash.",
3700 __LINE__,
3701 {"ledger_request", "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
3703 R"({
3704 "method" : "ledger_request",
3705 "params" : [
3706 {
3707 "api_version" : %API_VER%,
3708 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
3709 }
3710 ]
3711 })"},
3712 {"ledger_request: too few arguments.",
3713 __LINE__,
3714 {
3715 "ledger_request",
3716 },
3718 R"({
3719 "method" : "ledger_request",
3720 "params" : [
3721 {
3722 "error" : "badSyntax",
3723 "error_code" : 1,
3724 "error_message" : "Syntax error."
3725 }
3726 ]
3727 })"},
3728 {"ledger_request: too many arguments.",
3729 __LINE__,
3730 {"ledger_request", "4294967295", "spare"},
3732 R"({
3733 "method" : "ledger_request",
3734 "params" : [
3735 {
3736 "error" : "badSyntax",
3737 "error_code" : 1,
3738 "error_message" : "Syntax error."
3739 }
3740 ]
3741 })"},
3742 {"ledger_request: text ledger index.",
3743 __LINE__,
3744 {"ledger_request", "current"},
3746 R"({
3747 "method" : "ledger_request",
3748 "params" : [
3749 {
3750 "api_version" : %API_VER%,
3751 "ledger_index" : 0
3752 }
3753 ]
3754 })"},
3755 {"ledger_request: ledger index too small.",
3756 __LINE__,
3757 {"ledger_request", "-1"},
3759 R"({
3760 "method" : "ledger_request",
3761 "params" : [
3762 {
3763 "api_version" : %API_VER%,
3764 "ledger_index" : 0
3765 }
3766 ]
3767 })"},
3768 {"ledger_request: ledger index too big.",
3769 __LINE__,
3770 {"ledger_request", "4294967296"},
3772 R"({
3773 "method" : "ledger_request",
3774 "params" : [
3775 {
3776 "api_version" : %API_VER%,
3777 "ledger_index" : 0
3778 }
3779 ]
3780 })"},
3781
3782 // log_level
3783 // -------------------------------------------------------------------
3784 {"log_level: minimal.",
3785 __LINE__,
3786 {
3787 "log_level",
3788 },
3790 R"({
3791 "method" : "log_level",
3792 "params" : [
3793 {
3794 "api_version" : %API_VER%,
3795 }
3796 ]
3797 })"},
3798 {"log_level: fatal.",
3799 __LINE__,
3800 {"log_level", "fatal"},
3802 R"({
3803 "method" : "log_level",
3804 "params" : [
3805 {
3806 "api_version" : %API_VER%,
3807 "severity" : "fatal"
3808 }
3809 ]
3810 })"},
3811 {"log_level: error.",
3812 __LINE__,
3813 {"log_level", "error"},
3815 R"({
3816 "method" : "log_level",
3817 "params" : [
3818 {
3819 "api_version" : %API_VER%,
3820 "severity" : "error"
3821 }
3822 ]
3823 })"},
3824 {"log_level: warn.",
3825 __LINE__,
3826 {"log_level", "warn"},
3828 R"({
3829 "method" : "log_level",
3830 "params" : [
3831 {
3832 "api_version" : %API_VER%,
3833 "severity" : "warn"
3834 }
3835 ]
3836 })"},
3837 {"log_level: debug.",
3838 __LINE__,
3839 {"log_level", "debug"},
3841 R"({
3842 "method" : "log_level",
3843 "params" : [
3844 {
3845 "api_version" : %API_VER%,
3846 "severity" : "debug"
3847 }
3848 ]
3849 })"},
3850 {"log_level: trace.",
3851 __LINE__,
3852 {"log_level", "trace"},
3854 R"({
3855 "method" : "log_level",
3856 "params" : [
3857 {
3858 "api_version" : %API_VER%,
3859 "severity" : "trace"
3860 }
3861 ]
3862 })"},
3863 {"log_level: base partition.",
3864 __LINE__,
3865 {"log_level", "base", "trace"},
3867 R"({
3868 "method" : "log_level",
3869 "params" : [
3870 {
3871 "api_version" : %API_VER%,
3872 "partition" : "base",
3873 "severity" : "trace"
3874 }
3875 ]
3876 })"},
3877 {"log_level: partition_name.",
3878 __LINE__,
3879 {"log_level", "partition_name", "fatal"},
3881 R"({
3882 "method" : "log_level",
3883 "params" : [
3884 {
3885 "api_version" : %API_VER%,
3886 "partition" : "partition_name",
3887 "severity" : "fatal"
3888 }
3889 ]
3890 })"},
3891 {"log_level: too many arguments.",
3892 __LINE__,
3893 {"log_level", "partition_name", "fatal", "extra"},
3895 R"({
3896 "method" : "log_level",
3897 "params" : [
3898 {
3899 "error" : "badSyntax",
3900 "error_code" : 1,
3901 "error_message" : "Syntax error."
3902 }
3903 ]
3904 })"},
3905 {"log_level: invalid severity.",
3906 __LINE__,
3907 {"log_level", "err"},
3909 R"({
3910 "method" : "log_level",
3911 "params" : [
3912 {
3913 "api_version" : %API_VER%,
3914 "severity" : "err"
3915 }
3916 ]
3917 })"},
3918 {"log_level: swap partition name and severity.",
3919 __LINE__,
3920 {
3921 "log_level",
3922 "fatal",
3923 "partition_name",
3924 },
3926 R"({
3927 "method" : "log_level",
3928 "params" : [
3929 {
3930 "api_version" : %API_VER%,
3931 "partition" : "fatal",
3932 "severity" : "partition_name"
3933 }
3934 ]
3935 })"},
3936
3937 // logrotate
3938 // -------------------------------------------------------------------
3939 {"logrotate: minimal.",
3940 __LINE__,
3941 {
3942 "logrotate",
3943 },
3945 R"({
3946 "method" : "logrotate",
3947 "params" : [
3948 {
3949 "api_version" : %API_VER%,
3950 }
3951 ]
3952 })"},
3953 {"logrotate: too many arguments.",
3954 __LINE__,
3955 {"logrotate", "extra"},
3957 R"({
3958 "method" : "logrotate",
3959 "params" : [
3960 {
3961 "error" : "badSyntax",
3962 "error_code" : 1,
3963 "error_message" : "Syntax error."
3964 }
3965 ]
3966 })"},
3967
3968 // owner_info
3969 // ------------------------------------------------------------------
3970 {"owner_info: minimal.",
3971 __LINE__,
3972 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
3974 R"({
3975 "method" : "owner_info",
3976 "params" : [
3977 {
3978 "api_version" : %API_VER%,
3979 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
3980 }
3981 ]
3982 })"},
3983 {"owner_info: with numeric ledger index.",
3984 __LINE__,
3985 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "987654321"},
3987 R"({
3988 "method" : "owner_info",
3989 "params" : [
3990 {
3991 "api_version" : %API_VER%,
3992 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3993 "ledger_index" : 987654321
3994 }
3995 ]
3996 })"},
3997 {"owner_info: with text ledger index.",
3998 __LINE__,
3999 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
4001 R"({
4002 "method" : "owner_info",
4003 "params" : [
4004 {
4005 "api_version" : %API_VER%,
4006 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4007 "ledger_index" : "validated"
4008 }
4009 ]
4010 })"},
4011 {"owner_info: with ledger hash.",
4012 __LINE__,
4013 {"owner_info",
4014 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4015 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
4017 R"({
4018 "method" : "owner_info",
4019 "params" : [
4020 {
4021 "api_version" : %API_VER%,
4022 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4023 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
4024 }
4025 ]
4026 })"},
4027 {"owner_info: with ledger index.",
4028 __LINE__,
4029 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
4031 R"({
4032 "method" : "owner_info",
4033 "params" : [
4034 {
4035 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4036 "api_version" : %API_VER%,
4037 "ledger_index" : "validated"
4038 }
4039 ]
4040 })"},
4041 {"owner_info: too few arguments.",
4042 __LINE__,
4043 {
4044 "owner_info",
4045 },
4047 R"({
4048 "method" : "owner_info",
4049 "params" : [
4050 {
4051 "error" : "badSyntax",
4052 "error_code" : 1,
4053 "error_message" : "Syntax error."
4054 }
4055 ]
4056 })"},
4057 {"owner_info: too many arguments.",
4058 __LINE__,
4059 {
4060 "owner_info",
4061 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4062 "current",
4063 "extra1",
4064 "extra2",
4065 },
4067 R"({
4068 "method" : "owner_info",
4069 "params" : [
4070 {
4071 "error" : "badSyntax",
4072 "error_code" : 1,
4073 "error_message" : "Syntax error."
4074 }
4075 ]
4076 })"},
4077 {
4078 "owner_info: invalid accountID.",
4079 __LINE__,
4080 {
4081 "owner_info",
4082 "", // Note: very few values are detected as bad!
4083 },
4085 R"({
4086 "method" : "owner_info",
4087 "params" : [
4088 {
4089 "error" : "actMalformed",
4090 "error_code" : 35,
4091 "error_message" : "Account malformed."
4092 }
4093 ]
4094 })",
4095 },
4096 {
4097 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
4098 // cannot currently occur because jvParseLedger() always returns true.
4099 "owner_info: invalid ledger selection.",
4100 __LINE__,
4101 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
4103 R"({
4104 "method" : "owner_info",
4105 "params" : [
4106 {
4107 "api_version" : %API_VER%,
4108 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4109 "ledger_index" : 0
4110 }
4111 ]
4112 })",
4113 },
4114 {
4115 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
4116 // cannot currently occur because jvParseLedger() always returns true.
4117 "owner_info: invalid ledger selection.",
4118 __LINE__,
4119 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
4121 R"({
4122 "method" : "owner_info",
4123 "params" : [
4124 {
4125 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4126 "api_version" : %API_VER%,
4127 "ledger_index" : 0
4128 }
4129 ]
4130 })",
4131 },
4132
4133 // peers
4134 // -----------------------------------------------------------------------
4135 {"peers: minimal.",
4136 __LINE__,
4137 {
4138 "peers",
4139 },
4141 R"({
4142 "method" : "peers",
4143 "params" : [
4144 {
4145 "api_version" : %API_VER%,
4146 }
4147 ]
4148 })"},
4149 {"peers: too many arguments.",
4150 __LINE__,
4151 {"peers", "extra"},
4153 R"({
4154 "method" : "peers",
4155 "params" : [
4156 {
4157 "error" : "badSyntax",
4158 "error_code" : 1,
4159 "error_message" : "Syntax error."
4160 }
4161 ]
4162 })"},
4163
4164 // peer_reservations_add
4165 // -------------------------------------------------------
4166 {"peer_reservations_add: minimal.",
4167 __LINE__,
4168 {"peer_reservations_add", "public_key_string"},
4170 R"({
4171 "method" : "peer_reservations_add",
4172 "params" : [
4173 {
4174 "api_version" : %API_VER%,
4175 "public_key" : "public_key_string"
4176 }
4177 ]
4178 })"},
4179 {"peer_reservations_add: with description.",
4180 __LINE__,
4181 {"peer_reservations_add", "public_key_string", "public_key_description"},
4183 R"({
4184 "method" : "peer_reservations_add",
4185 "params" : [
4186 {
4187 "api_version" : %API_VER%,
4188 "description" : "public_key_description",
4189 "public_key" : "public_key_string"
4190 }
4191 ]
4192 })"},
4193 {"peer_reservations_add: too few arguments.",
4194 __LINE__,
4195 {"peer_reservations_add"},
4197 R"({
4198 "method" : "peer_reservations_add",
4199 "params" : [
4200 {
4201 "error" : "badSyntax",
4202 "error_code" : 1,
4203 "error_message" : "Syntax error."
4204 }
4205 ]
4206 })"},
4207 {"peer_reservations_add: too many arguments.",
4208 __LINE__,
4209 {"peer_reservations_add", "public_key_string", "public_key_description", "spare"},
4211 R"({
4212 "method" : "peer_reservations_add",
4213 "params" : [
4214 {
4215 "error" : "badSyntax",
4216 "error_code" : 1,
4217 "error_message" : "Syntax error."
4218 }
4219 ]
4220 })"},
4221
4222 // peer_reservations_del
4223 // -------------------------------------------------------
4224 {"peer_reservations_del: minimal.",
4225 __LINE__,
4226 {"peer_reservations_del", "public_key_string"},
4228 R"({
4229 "method" : "peer_reservations_del",
4230 "params" : [
4231 {
4232 "api_version" : %API_VER%,
4233 "public_key" : "public_key_string"
4234 }
4235 ]
4236 })"},
4237 {"peer_reservations_del: too few arguments.",
4238 __LINE__,
4239 {"peer_reservations_del"},
4241 R"({
4242 "method" : "peer_reservations_del",
4243 "params" : [
4244 {
4245 "error" : "badSyntax",
4246 "error_code" : 1,
4247 "error_message" : "Syntax error."
4248 }
4249 ]
4250 })"},
4251 {"peer_reservations_del: too many arguments.",
4252 __LINE__,
4253 {"peer_reservations_del", "public_key_string", "public_key_description", "spare"},
4255 R"({
4256 "method" : "peer_reservations_del",
4257 "params" : [
4258 {
4259 "error" : "badSyntax",
4260 "error_code" : 1,
4261 "error_message" : "Syntax error."
4262 }
4263 ]
4264 })"},
4265
4266 // ping
4267 // ------------------------------------------------------------------------
4268 {"ping: minimal.",
4269 __LINE__,
4270 {
4271 "ping",
4272 },
4274 R"({
4275 "method" : "ping",
4276 "params" : [
4277 {
4278 "api_version" : %API_VER%,
4279 }
4280 ]
4281 })"},
4282 {"ping: too many arguments.",
4283 __LINE__,
4284 {"ping", "extra"},
4286 R"({
4287 "method" : "ping",
4288 "params" : [
4289 {
4290 "error" : "badSyntax",
4291 "error_code" : 1,
4292 "error_message" : "Syntax error."
4293 }
4294 ]
4295 })"},
4296
4297 // print
4298 // -----------------------------------------------------------------------
4299 {"print: minimal.",
4300 __LINE__,
4301 {
4302 "print",
4303 },
4305 R"({
4306 "method" : "print",
4307 "params" : [
4308 {
4309 "api_version" : %API_VER%,
4310 }
4311 ]
4312 })"},
4313 {// The docs indicate that no arguments are allowed. So should this error?
4314 "print: extra argument.",
4315 __LINE__,
4316 {"print", "extra"},
4318 R"({
4319 "method" : "print",
4320 "params" : [
4321 {
4322 "api_version" : %API_VER%,
4323 "params" : [ "extra" ]
4324 }
4325 ]
4326 })"},
4327 {"print: too many arguments.",
4328 __LINE__,
4329 {"print", "extra1", "extra2"},
4331 R"({
4332 "method" : "print",
4333 "params" : [
4334 {
4335 "error" : "badSyntax",
4336 "error_code" : 1,
4337 "error_message" : "Syntax error."
4338 }
4339 ]
4340 })"},
4341
4342 // random
4343 // ----------------------------------------------------------------------
4344 {"random: minimal.",
4345 __LINE__,
4346 {
4347 "random",
4348 },
4350 R"({
4351 "method" : "random",
4352 "params" : [
4353 {
4354 "api_version" : %API_VER%,
4355 }
4356 ]
4357 })"},
4358 {"random: too many arguments.",
4359 __LINE__,
4360 {"random", "extra"},
4362 R"({
4363 "method" : "random",
4364 "params" : [
4365 {
4366 "error" : "badSyntax",
4367 "error_code" : 1,
4368 "error_message" : "Syntax error."
4369 }
4370 ]
4371 })"},
4372
4373 // ripple_path_find
4374 // ------------------------------------------------------------
4375 {"ripple_path_find: minimal.",
4376 __LINE__,
4377 {
4378 "ripple_path_find",
4379 R"({"json_argument":true})",
4380 },
4382 R"({
4383 "method" : "ripple_path_find",
4384 "params" : [
4385 {
4386 "api_version" : %API_VER%,
4387 "json_argument" : true
4388 }
4389 ]
4390 })"},
4391 {"ripple_path_find: ledger index.",
4392 __LINE__,
4393 {"ripple_path_find", R"({"json_argument":true})", "4294967295"},
4395 R"({
4396 "method" : "ripple_path_find",
4397 "params" : [
4398 {
4399 "api_version" : %API_VER%,
4400 "json_argument" : true,
4401 "ledger_index" : 4294967295
4402 }
4403 ]
4404 })"},
4405 {"ripple_path_find: text ledger index.",
4406 __LINE__,
4407 {"ripple_path_find", R"({"json_argument":true})", "closed"},
4409 R"({
4410 "method" : "ripple_path_find",
4411 "params" : [
4412 {
4413 "api_version" : %API_VER%,
4414 "json_argument" : true,
4415 "ledger_index" : "closed"
4416 }
4417 ]
4418 })"},
4419 {"ripple_path_find: ledger hash.",
4420 __LINE__,
4421 {"ripple_path_find",
4422 R"({"json_argument":true})",
4423 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"},
4425 R"({
4426 "method" : "ripple_path_find",
4427 "params" : [
4428 {
4429 "api_version" : %API_VER%,
4430 "json_argument" : true,
4431 "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
4432 }
4433 ]
4434 })"},
4435
4436 {"ripple_path_find: too few arguments.",
4437 __LINE__,
4438 {
4439 "ripple_path_find",
4440 },
4442 R"({
4443 "method" : "ripple_path_find",
4444 "params" : [
4445 {
4446 "error" : "badSyntax",
4447 "error_code" : 1,
4448 "error_message" : "Syntax error."
4449 }
4450 ]
4451 })"},
4452 {"ripple_path_find: too many arguments.",
4453 __LINE__,
4454 {"ripple_path_find", R"({"json_argument":true})", "current", "extra"},
4456 R"({
4457 "method" : "ripple_path_find",
4458 "params" : [
4459 {
4460 "error" : "badSyntax",
4461 "error_code" : 1,
4462 "error_message" : "Syntax error."
4463 }
4464 ]
4465 })"},
4466 {"ripple_path_find: invalid json (note extra comma).",
4467 __LINE__,
4468 {
4469 "ripple_path_find",
4470 R"({"json_argument":true,})",
4471 },
4473 R"({
4474 "method" : "ripple_path_find",
4475 "params" : [
4476 {
4477 "error" : "invalidParams",
4478 "error_code" : 31,
4479 "error_message" : "Invalid parameters."
4480 }
4481 ]
4482 })"},
4483 {"ripple_path_find: ledger index too small.",
4484 __LINE__,
4485 {"ripple_path_find", R"({"json_argument":true})", "-1"},
4487 R"({
4488 "method" : "ripple_path_find",
4489 "params" : [
4490 {
4491 "api_version" : %API_VER%,
4492 "json_argument" : true,
4493 "ledger_index" : 0
4494 }
4495 ]
4496 })"},
4497 {"ripple_path_find: ledger index too big.",
4498 __LINE__,
4499 {"ripple_path_find", R"({"json_argument":true})", "4294967296"},
4501 R"({
4502 "method" : "ripple_path_find",
4503 "params" : [
4504 {
4505 "api_version" : %API_VER%,
4506 "json_argument" : true,
4507 "ledger_index" : 0
4508 }
4509 ]
4510 })"},
4511 {"ripple_path_find: invalid text ledger index.",
4512 __LINE__,
4513 {"ripple_path_find", R"({"json_argument":true})", "cur"},
4515 R"({
4516 "method" : "ripple_path_find",
4517 "params" : [
4518 {
4519 "api_version" : %API_VER%,
4520 "json_argument" : true,
4521 "ledger_index" : 0
4522 }
4523 ]
4524 })"},
4525
4526 // sign
4527 // ------------------------------------------------------------------------
4528 {"sign: minimal.",
4529 __LINE__,
4530 {
4531 "sign",
4532 "my_secret",
4533 R"({"json_argument":true})",
4534 },
4536 R"({
4537 "method" : "sign",
4538 "params" : [
4539 {
4540 "api_version" : %API_VER%,
4541 "secret" : "my_secret",
4542 "tx_json" : {
4543 "json_argument" : true
4544 }
4545 }
4546 ]
4547 })"},
4548 {"sign: offline.",
4549 __LINE__,
4550 {"sign", "my_secret", R"({"json_argument":true})", "offline"},
4552 R"({
4553 "method" : "sign",
4554 "params" : [
4555 {
4556 "api_version" : %API_VER%,
4557 "offline" : true,
4558 "secret" : "my_secret",
4559 "tx_json" : {
4560 "json_argument" : true
4561 }
4562 }
4563 ]
4564 })"},
4565 {"sign: too few arguments.",
4566 __LINE__,
4567 {"sign", "contents_of_blob"},
4569 R"({
4570 "method" : "sign",
4571 "params" : [
4572 {
4573 "error" : "badSyntax",
4574 "error_code" : 1,
4575 "error_message" : "Syntax error."
4576 }
4577 ]
4578 })"},
4579 {"sign: offline flag with signature_target.",
4580 __LINE__,
4581 {"sign", "my_secret", R"({"json_argument":true})", "offline", "extra"},
4583 R"({
4584 "method" : "sign",
4585 "params" : [
4586 {
4587 "api_version" : %API_VER%,
4588 "offline" : true,
4589 "secret" : "my_secret",
4590 "signature_target" : "extra",
4591 "tx_json" :
4592 {
4593 "json_argument" : true
4594 }
4595 }
4596 ]
4597 })"},
4598 {"sign: too many arguments.",
4599 __LINE__,
4600 {"sign",
4601 "my_secret",
4602 R"({"json_argument":true})",
4603 "offline",
4604 "CounterpartySignature",
4605 "extra"},
4607 R"({
4608 "method" : "sign",
4609 "params" : [
4610 {
4611 "error" : "badSyntax",
4612 "error_code" : 1,
4613 "error_message" : "Syntax error."
4614 }
4615 ]
4616 })"},
4617 {"sign: invalid JSON (note extra comma).",
4618 __LINE__,
4619 {
4620 "sign",
4621 "my_secret",
4622 R"({"json_argument":true,})",
4623 },
4625 R"({
4626 "method" : "sign",
4627 "params" : [
4628 {
4629 "error" : "invalidParams",
4630 "error_code" : 31,
4631 "error_message" : "Invalid parameters."
4632 }
4633 ]
4634 })"},
4635 {"sign: misspelled offline flag interpreted as signature_target.",
4636 __LINE__,
4637 {"sign", "my_secret", R"({"json_argument":true})", "offlin"},
4639 R"({
4640 "method" : "sign",
4641 "params" : [
4642 {
4643 "api_version" : %API_VER%,
4644 "secret" : "my_secret",
4645 "signature_target" : "offlin",
4646 "tx_json" :
4647 {
4648 "json_argument" : true
4649 }
4650 }
4651 ]
4652 })"},
4653
4654 // sign_for
4655 // --------------------------------------------------------------------
4656 {"sign_for: minimal.",
4657 __LINE__,
4658 {
4659 "sign_for",
4660 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4661 "my_secret",
4662 R"({"json_argument":true})",
4663 },
4665 R"({
4666 "method" : "sign_for",
4667 "params" : [
4668 {
4669 "api_version" : %API_VER%,
4670 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4671 "secret" : "my_secret",
4672 "tx_json" : {
4673 "json_argument" : true
4674 }
4675 }
4676 ]
4677 })"},
4678 {"sign_for: offline.",
4679 __LINE__,
4680 {"sign_for",
4681 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4682 "my_secret",
4683 R"({"json_argument":true})",
4684 "offline"},
4686 R"({
4687 "method" : "sign_for",
4688 "params" : [
4689 {
4690 "api_version" : %API_VER%,
4691 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4692 "offline" : true,
4693 "secret" : "my_secret",
4694 "tx_json" : {
4695 "json_argument" : true
4696 }
4697 }
4698 ]
4699 })"},
4700 {"sign_for: too few arguments.",
4701 __LINE__,
4702 {
4703 "sign_for",
4704 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4705 "my_secret",
4706 },
4708 R"({
4709 "method" : "sign_for",
4710 "params" : [
4711 {
4712 "error" : "badSyntax",
4713 "error_code" : 1,
4714 "error_message" : "Syntax error."
4715 }
4716 ]
4717 })"},
4718 {"sign_for: too many arguments.",
4719 __LINE__,
4720 {"sign_for",
4721 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4722 "my_secret",
4723 R"({"json_argument":true})",
4724 "offline",
4725 "extra"},
4727 R"({
4728 "method" : "sign_for",
4729 "params" : [
4730 {
4731 "error" : "badSyntax",
4732 "error_code" : 1,
4733 "error_message" : "Syntax error."
4734 }
4735 ]
4736 })"},
4737 {"sign_for: invalid json (note extra comma).",
4738 __LINE__,
4739 {
4740 "sign_for",
4741 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4742 "my_secret",
4743 R"({"json_argument":true,})",
4744 },
4746 R"({
4747 "method" : "sign_for",
4748 "params" : [
4749 {
4750 "error" : "invalidParams",
4751 "error_code" : 31,
4752 "error_message" : "Invalid parameters."
4753 }
4754 ]
4755 })"},
4756 {"sign_for: invalid final argument.",
4757 __LINE__,
4758 {"sign_for",
4759 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4760 "my_secret",
4761 R"({"json_argument":true})",
4762 "ofline"},
4764 R"({
4765 "method" : "sign_for",
4766 "params" : [
4767 {
4768 "error" : "invalidParams",
4769 "error_code" : 31,
4770 "error_message" : "Invalid parameters."
4771 }
4772 ]
4773 })"},
4774
4775 // submit
4776 // ----------------------------------------------------------------------
4777 {"submit: blob.",
4778 __LINE__,
4779 {"submit", "the blob is unvalidated and may be any length..."},
4781 R"({
4782 "method" : "submit",
4783 "params" : [
4784 {
4785 "api_version" : %API_VER%,
4786 "tx_blob" : "the blob is unvalidated and may be any length..."
4787 }
4788 ]
4789 })"},
4790 {"submit: json.",
4791 __LINE__,
4792 {
4793 "submit",
4794 "my_secret",
4795 R"({"json_argument":true})",
4796 },
4798 R"({
4799 "method" : "submit",
4800 "params" : [
4801 {
4802 "api_version" : %API_VER%,
4803 "secret" : "my_secret",
4804 "tx_json" : {
4805 "json_argument" : true
4806 }
4807 }
4808 ]
4809 })"},
4810 {"submit: too few arguments.",
4811 __LINE__,
4812 {
4813 "submit",
4814 },
4816 R"({
4817 "method" : "submit",
4818 "params" : [
4819 {
4820 "error" : "badSyntax",
4821 "error_code" : 1,
4822 "error_message" : "Syntax error."
4823 }
4824 ]
4825 })"},
4826 {// Note: I believe this _ought_ to be detected as too many arguments.
4827 "submit: four arguments.",
4828 __LINE__,
4829 {"submit", "my_secret", R"({"json_argument":true})", "offline"},
4831 R"({
4832 "method" : "submit",
4833 "params" : [
4834 {
4835 "api_version" : %API_VER%,
4836 "offline" : true,
4837 "secret" : "my_secret",
4838 "tx_json" : {
4839 "json_argument" : true
4840 }
4841 }
4842 ]
4843 })"},
4844 {"submit: offline flag with signature_target.",
4845 __LINE__,
4846 {"submit", "my_secret", R"({"json_argument":true})", "offline", "extra"},
4848 R"({
4849 "method" : "submit",
4850 "params" : [
4851 {
4852 "api_version" : %API_VER%,
4853 "offline" : true,
4854 "secret" : "my_secret",
4855 "signature_target" : "extra",
4856 "tx_json" :
4857 {
4858 "json_argument" : true
4859 }
4860 }
4861 ]
4862 })"},
4863 {"submit: too many arguments.",
4864 __LINE__,
4865 {"submit",
4866 "my_secret",
4867 R"({"json_argument":true})",
4868 "offline",
4869 "CounterpartySignature",
4870 "extra"},
4872 R"({
4873 "method" : "submit",
4874 "params" : [
4875 {
4876 "error" : "badSyntax",
4877 "error_code" : 1,
4878 "error_message" : "Syntax error."
4879 }
4880 ]
4881 })"},
4882 {"submit: invalid json (note extra comma).",
4883 __LINE__,
4884 {
4885 "submit",
4886 "my_secret",
4887 R"({"json_argument":true,})",
4888 },
4890 R"({
4891 "method" : "submit",
4892 "params" : [
4893 {
4894 "error" : "invalidParams",
4895 "error_code" : 31,
4896 "error_message" : "Invalid parameters."
4897 }
4898 ]
4899 })"},
4900 {"submit: misspelled offline flag interpreted as signature_target.",
4901 __LINE__,
4902 {"submit", "my_secret", R"({"json_argument":true})", "offlne"},
4904 R"({
4905 "method" : "submit",
4906 "params" : [
4907 {
4908 "api_version" : %API_VER%,
4909 "secret" : "my_secret",
4910 "signature_target" : "offlne",
4911 "tx_json" :
4912 {
4913 "json_argument" : true
4914 }
4915 }
4916 ]
4917 })"},
4918
4919 // submit_multisigned
4920 // ----------------------------------------------------------
4921 {"submit_multisigned: json.",
4922 __LINE__,
4923 {
4924 "submit_multisigned",
4925 R"({"json_argument":true})",
4926 },
4928 R"({
4929 "method" : "submit_multisigned",
4930 "params" : [
4931 {
4932 "api_version" : %API_VER%,
4933 "tx_json" : {
4934 "json_argument" : true
4935 }
4936 }
4937 ]
4938 })"},
4939 {"submit_multisigned: too few arguments.",
4940 __LINE__,
4941 {
4942 "submit_multisigned",
4943 },
4945 R"({
4946 "method" : "submit_multisigned",
4947 "params" : [
4948 {
4949 "error" : "badSyntax",
4950 "error_code" : 1,
4951 "error_message" : "Syntax error."
4952 }
4953 ]
4954 })"},
4955 {"submit_multisigned: too many arguments.",
4956 __LINE__,
4957 {"submit_multisigned", R"({"json_argument":true})", "extra"},
4959 R"({
4960 "method" : "submit_multisigned",
4961 "params" : [
4962 {
4963 "error" : "badSyntax",
4964 "error_code" : 1,
4965 "error_message" : "Syntax error."
4966 }
4967 ]
4968 })"},
4969 {"submit_multisigned: invalid json (note extra comma).",
4970 __LINE__,
4971 {
4972 "submit_multisigned",
4973 R"({"json_argument":true,})",
4974 },
4976 R"({
4977 "method" : "submit_multisigned",
4978 "params" : [
4979 {
4980 "error" : "invalidParams",
4981 "error_code" : 31,
4982 "error_message" : "Invalid parameters."
4983 }
4984 }
4985 ]
4986 })"},
4987
4988 // server_info
4989 // -----------------------------------------------------------------
4990 {"server_info: minimal.",
4991 __LINE__,
4992 {
4993 "server_info",
4994 },
4996 R"({
4997 "method" : "server_info",
4998 "params" : [
4999 {
5000 "api_version" : %API_VER%,
5001 }
5002 ]
5003 })"},
5004 {"server_info: counters.",
5005 __LINE__,
5006 {"server_info", "counters"},
5008 R"({
5009 "method" : "server_info",
5010 "params" : [
5011 {
5012 "api_version" : %API_VER%,
5013 "counters" : true
5014 }
5015 ]
5016 })"},
5017 {"server_info: too many arguments.",
5018 __LINE__,
5019 {"server_info", "counters", "extra"},
5021 R"({
5022 "method" : "server_info",
5023 "params" : [
5024 {
5025 "error" : "badSyntax",
5026 "error_code" : 1,
5027 "error_message" : "Syntax error."
5028 }
5029 ]
5030 })"},
5031 {"server_info: non-counters argument.",
5032 __LINE__,
5033 {"server_info", "counter"},
5035 R"({
5036 "method" : "server_info",
5037 "params" : [
5038 {
5039 "api_version" : %API_VER%,
5040 }
5041 ]
5042 })"},
5043
5044 // server_state
5045 // ----------------------------------------------------------------
5046 {"server_state: minimal.",
5047 __LINE__,
5048 {
5049 "server_state",
5050 },
5052 R"({
5053 "method" : "server_state",
5054 "params" : [
5055 {
5056 "api_version" : %API_VER%,
5057 }
5058 ]
5059 })"},
5060 {"server_state: counters.",
5061 __LINE__,
5062 {"server_state", "counters"},
5064 R"({
5065 "method" : "server_state",
5066 "params" : [
5067 {
5068 "api_version" : %API_VER%,
5069 "counters" : true
5070 }
5071 ]
5072 })"},
5073 {"server_state: too many arguments.",
5074 __LINE__,
5075 {"server_state", "counters", "extra"},
5077 R"({
5078 "method" : "server_state",
5079 "params" : [
5080 {
5081 "error" : "badSyntax",
5082 "error_code" : 1,
5083 "error_message" : "Syntax error."
5084 }
5085 ]
5086 })"},
5087 {"server_state: non-counters argument.",
5088 __LINE__,
5089 {"server_state", "counter"},
5091 R"({
5092 "method" : "server_state",
5093 "params" : [
5094 {
5095 "api_version" : %API_VER%,
5096 }
5097 ]
5098 })"},
5099
5100 // stop
5101 // ------------------------------------------------------------------------
5102 {"stop: minimal.",
5103 __LINE__,
5104 {
5105 "stop",
5106 },
5108 R"({
5109 "method" : "stop",
5110 "params" : [
5111 {
5112 "api_version" : %API_VER%,
5113 }
5114 ]
5115 })"},
5116 {"stop: too many arguments.",
5117 __LINE__,
5118 {"stop", "extra"},
5120 R"({
5121 "method" : "stop",
5122 "params" : [
5123 {
5124 "error" : "badSyntax",
5125 "error_code" : 1,
5126 "error_message" : "Syntax error."
5127 }
5128 ]
5129 })"},
5130
5131 // transaction_entry
5132 // -----------------------------------------------------------
5133 {"transaction_entry: ledger index.",
5134 __LINE__,
5135 {"transaction_entry",
5136 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5137 "4294967295"},
5139 R"({
5140 "method" : "transaction_entry",
5141 "params" : [
5142 {
5143 "api_version" : %API_VER%,
5144 "ledger_index" : 4294967295,
5145 "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5146 }
5147 ]
5148 })"},
5149 {"transaction_entry: text ledger index.",
5150 __LINE__,
5151 {"transaction_entry",
5152 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5153 "current"},
5155 R"({
5156 "method" : "transaction_entry",
5157 "params" : [
5158 {
5159 "api_version" : %API_VER%,
5160 "ledger_index" : "current",
5161 "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5162 }
5163 ]
5164 })"},
5165 {"transaction_entry: ledger hash.",
5166 __LINE__,
5167 {"transaction_entry",
5168 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5169 "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210"},
5171 R"({
5172 "method" : "transaction_entry",
5173 "params" : [
5174 {
5175 "api_version" : %API_VER%,
5176 "ledger_hash" : "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210",
5177 "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5178 }
5179 ]
5180 })"},
5181 {"transaction_entry: too few arguments.",
5182 __LINE__,
5183 {
5184 "transaction_entry",
5185 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5186 },
5188 R"({
5189 "method" : "transaction_entry",
5190 "params" : [
5191 {
5192 "error" : "badSyntax",
5193 "error_code" : 1,
5194 "error_message" : "Syntax error."
5195 }
5196 ]
5197 })"},
5198 {"transaction_entry: too many arguments.",
5199 __LINE__,
5200 {"transaction_entry",
5201 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5202 "validated",
5203 "extra"},
5205 R"({
5206 "method" : "transaction_entry",
5207 "params" : [
5208 {
5209 "error" : "badSyntax",
5210 "error_code" : 1,
5211 "error_message" : "Syntax error."
5212 }
5213 ]
5214 })"},
5215 {"transaction_entry: short tx_hash.",
5216 __LINE__,
5217 {
5218 "transaction_entry",
5219 "123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5220 "validated",
5221 },
5223 R"({
5224 "method" : "transaction_entry",
5225 "params" : [
5226 {
5227 "error" : "invalidParams",
5228 "error_code" : 31,
5229 "error_message" : "Invalid parameters."
5230 }
5231 ]
5232 })"},
5233 {"transaction_entry: long tx_hash.",
5234 __LINE__,
5235 {
5236 "transaction_entry",
5237 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUVW",
5238 "validated",
5239 },
5241 R"({
5242 "method" : "transaction_entry",
5243 "params" : [
5244 {
5245 "error" : "invalidParams",
5246 "error_code" : 31,
5247 "error_message" : "Invalid parameters."
5248 }
5249 ]
5250 })"},
5251 {"transaction_entry: small ledger index.",
5252 __LINE__,
5253 {
5254 "transaction_entry",
5255 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5256 "0",
5257 },
5259 R"({
5260 "method" : "transaction_entry",
5261 "params" : [
5262 {
5263 "error" : "invalidParams",
5264 "error_code" : 31,
5265 "error_message" : "Invalid parameters."
5266 }
5267 ]
5268 })"},
5269 {"transaction_entry: large ledger index.",
5270 __LINE__,
5271 {
5272 "transaction_entry",
5273 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5274 "4294967296",
5275 },
5277 R"({
5278 "method" : "transaction_entry",
5279 "params" : [
5280 {
5281 "error" : "invalidParams",
5282 "error_code" : 31,
5283 "error_message" : "Invalid parameters."
5284 }
5285 ]
5286 })"},
5287 {"transaction_entry: short ledger hash.",
5288 __LINE__,
5289 {
5290 "transaction_entry",
5291 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5292 "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA987654321",
5293 },
5295 R"({
5296 "method" : "transaction_entry",
5297 "params" : [
5298 {
5299 "error" : "invalidParams",
5300 "error_code" : 31,
5301 "error_message" : "Invalid parameters."
5302 }
5303 ]
5304 })"},
5305 {"transaction_entry: long ledger hash.",
5306 __LINE__,
5307 {
5308 "transaction_entry",
5309 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5310 "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210Z",
5311 },
5313 R"({
5314 "method" : "transaction_entry",
5315 "params" : [
5316 {
5317 "error" : "invalidParams",
5318 "error_code" : 31,
5319 "error_message" : "Invalid parameters."
5320 }
5321 ]
5322 })"},
5323
5324 // tx
5325 // --------------------------------------------------------------------------
5326 {"tx: ctid. minimal",
5327 __LINE__,
5328 {"tx", "FFFFFFFFFFFFFFFF", "1", "2"},
5330 R"({
5331 "method" : "tx",
5332 "params" : [
5333 {
5334 "api_version" : %API_VER%,
5335 "ctid" : "FFFFFFFFFFFFFFFF",
5336 "max_ledger" : "2",
5337 "min_ledger" : "1"
5338 }
5339 ]
5340 })"},
5341 {"tx: ctid. binary",
5342 __LINE__,
5343 {"tx", "FFFFFFFFFFFFFFFF", "binary", "1", "2"},
5345 R"({
5346 "method" : "tx",
5347 "params" : [
5348 {
5349 "api_version" : %API_VER%,
5350 "binary" : true,
5351 "ctid" : "FFFFFFFFFFFFFFFF",
5352 "max_ledger" : "2",
5353 "min_ledger" : "1"
5354 }
5355 ]
5356 })"},
5357 {"tx: minimal.",
5358 __LINE__,
5359 {"tx", "transaction_hash_is_not_validated"},
5361 R"({
5362 "method" : "tx",
5363 "params" : [
5364 {
5365 "api_version" : %API_VER%,
5366 "transaction" : "transaction_hash_is_not_validated"
5367 }
5368 ]
5369 })"},
5370 {"tx: binary.",
5371 __LINE__,
5372 {"tx", "transaction_hash_is_not_validated", "binary"},
5374 R"({
5375 "method" : "tx",
5376 "params" : [
5377 {
5378 "api_version" : %API_VER%,
5379 "binary" : true,
5380 "transaction" : "transaction_hash_is_not_validated"
5381 }
5382 ]
5383 })"},
5384 {"tx: too few arguments.",
5385 __LINE__,
5386 {
5387 "tx",
5388 },
5390 R"({
5391 "method" : "tx",
5392 "params" : [
5393 {
5394 "error" : "badSyntax",
5395 "error_code" : 1,
5396 "error_message" : "Syntax error."
5397 }
5398 ]
5399 })"},
5400 {"tx: too many arguments.",
5401 __LINE__,
5402 {"tx", "transaction_hash_is_not_validated", "binary", "1", "2", "extra"},
5404 R"({
5405 "method" : "tx",
5406 "params" : [
5407 {
5408 "error" : "badSyntax",
5409 "error_code" : 1,
5410 "error_message" : "Syntax error."
5411 }
5412 ]
5413 })"},
5414 {"tx: invalid final argument is apparently ignored.",
5415 __LINE__,
5416 {"tx", "transaction_hash_is_not_validated", "bin"},
5418 R"({
5419 "method" : "tx",
5420 "params" : [
5421 {
5422 "api_version" : %API_VER%,
5423 "transaction" : "transaction_hash_is_not_validated"
5424 }
5425 ]
5426 })"},
5427
5428 // tx_history
5429 // ------------------------------------------------------------------
5430 {"tx_history: minimal.",
5431 __LINE__,
5432 {"tx_history", "0"},
5434 R"({
5435 "method" : "tx_history",
5436 "params" : [
5437 {
5438 "api_version" : %API_VER%,
5439 "start" : 0
5440 }
5441 ]
5442 })"},
5443 {"tx_history: too few arguments.",
5444 __LINE__,
5445 {
5446 "tx_history",
5447 },
5449 R"({
5450 "method" : "tx_history",
5451 "params" : [
5452 {
5453 "error" : "badSyntax",
5454 "error_code" : 1,
5455 "error_message" : "Syntax error."
5456 }
5457 ]
5458 })"},
5459 {"tx_history: too many arguments.",
5460 __LINE__,
5461 {"tx_history", "0", "1"},
5463 R"({
5464 "method" : "tx_history",
5465 "params" : [
5466 {
5467 "error" : "badSyntax",
5468 "error_code" : 1,
5469 "error_message" : "Syntax error."
5470 }
5471 ]
5472 })"},
5473 {
5474 // Note: this really shouldn't throw, but does at the moment.
5475 "tx_history: start too small.",
5476 __LINE__,
5477 {"tx_history", "-1"},
5479 R"()",
5480 },
5481 {
5482 // Note: this really shouldn't throw, but does at the moment.
5483 "tx_history: start too big.",
5484 __LINE__,
5485 {"tx_history", "4294967296"},
5487 R"()",
5488 },
5489 {
5490 // Note: this really shouldn't throw, but does at the moment.
5491 "tx_history: start not integer.",
5492 __LINE__,
5493 {"tx_history", "beginning"},
5495 R"()",
5496 },
5497
5498 // unl_list
5499 // --------------------------------------------------------------------
5500 {"unl_list: minimal.",
5501 __LINE__,
5502 {
5503 "unl_list",
5504 },
5506 R"({
5507 "method" : "unl_list",
5508 "params" : [
5509 {
5510 "api_version" : %API_VER%,
5511 }
5512 ]
5513 })"},
5514 {"unl_list: too many arguments.",
5515 __LINE__,
5516 {"unl_list", "extra"},
5518 R"({
5519 "method" : "unl_list",
5520 "params" : [
5521 {
5522 "error" : "badSyntax",
5523 "error_code" : 1,
5524 "error_message" : "Syntax error."
5525 }
5526 ]
5527 })"},
5528
5529 // validation_create
5530 // -----------------------------------------------------------
5531 {"validation_create: minimal.",
5532 __LINE__,
5533 {
5534 "validation_create",
5535 },
5537 R"({
5538 "method" : "validation_create",
5539 "params" : [
5540 {
5541 "api_version" : %API_VER%,
5542 }
5543 ]
5544 })"},
5545 {"validation_create: with secret.",
5546 __LINE__,
5547 {"validation_create", "the form of the secret is not validated"},
5549 R"({
5550 "method" : "validation_create",
5551 "params" : [
5552 {
5553 "api_version" : %API_VER%,
5554 "secret" : "the form of the secret is not validated"
5555 }
5556 ]
5557 })"},
5558 {"validation_create: too many arguments.",
5559 __LINE__,
5560 {"validation_create", "the form of the secret is not validated", "extra"},
5562 R"({
5563 "method" : "validation_create",
5564 "params" : [
5565 {
5566 "error" : "badSyntax",
5567 "error_code" : 1,
5568 "error_message" : "Syntax error."
5569 }
5570 ]
5571 })"},
5572
5573 // version
5574 // ---------------------------------------------------------------------
5575 {"version: minimal.",
5576 __LINE__,
5577 {
5578 "version",
5579 },
5581 R"({
5582 "method" : "version",
5583 "params" : [
5584 {
5585 "api_version" : %API_VER%,
5586 }
5587 ]
5588 })"},
5589 {"version: too many arguments.",
5590 __LINE__,
5591 {"version", "extra"},
5593 R"({
5594 "method" : "version",
5595 "params" : [
5596 {
5597 "error" : "badSyntax",
5598 "error_code" : 1,
5599 "error_message" : "Syntax error."
5600 }
5601 ]
5602 })"},
5603
5604 // wallet_propose
5605 // --------------------------------------------------------------
5606 {"wallet_propose: minimal.",
5607 __LINE__,
5608 {
5609 "wallet_propose",
5610 },
5612 R"({
5613 "method" : "wallet_propose",
5614 "params" : [
5615 {
5616 "api_version" : %API_VER%,
5617 }
5618 ]
5619 })"},
5620 {"wallet_propose: with passphrase.",
5621 __LINE__,
5622 {"wallet_propose", "the form of the passphrase is not validated"},
5624 R"({
5625 "method" : "wallet_propose",
5626 "params" : [
5627 {
5628 "api_version" : %API_VER%,
5629 "passphrase" : "the form of the passphrase is not validated"
5630 }
5631 ]
5632 })"},
5633 {"wallet_propose: too many arguments.",
5634 __LINE__,
5635 {"wallet_propose", "the form of the passphrase is not validated", "extra"},
5637 R"({
5638 "method" : "wallet_propose",
5639 "params" : [
5640 {
5641 "error" : "badSyntax",
5642 "error_code" : 1,
5643 "error_message" : "Syntax error."
5644 }
5645 ]
5646 })"},
5647
5648 // internal
5649 // --------------------------------------------------------------------
5650 {"internal: minimal.",
5651 __LINE__,
5652 {"internal", "command_name"},
5654 R"({
5655 "method" : "internal",
5656 "params" : [
5657 {
5658 "api_version" : %API_VER%,
5659 "internal_command" : "command_name",
5660 "params" : []
5661 }
5662 ]
5663 })"},
5664 {"internal: with parameters.",
5665 __LINE__,
5666 {"internal", "command_name", "string_arg", "1", "-1", "4294967296", "3.14159"},
5668 R"({
5669 "method" : "internal",
5670 "params" : [
5671 {
5672 "api_version" : %API_VER%,
5673 "internal_command" : "command_name",
5674 "params" : [ "string_arg", "1", "-1", "4294967296", "3.14159" ]
5675 }
5676 ]
5677 })"},
5678 {"internal: too few arguments.",
5679 __LINE__,
5680 {
5681 "internal",
5682 },
5684 R"({
5685 "method" : "internal",
5686 "params" : [
5687 {
5688 "error" : "badSyntax",
5689 "error_code" : 1,
5690 "error_message" : "Syntax error."
5691 }
5692 ]
5693 })"},
5694
5695 // path_find
5696 // -------------------------------------------------------------------
5697 {"path_find: minimal.",
5698 __LINE__,
5699 {
5700 "path_find",
5701 },
5703 R"({
5704 "method" : "path_find",
5705 "params" : [
5706 {
5707 "error" : "noEvents",
5708 "error_code" : 7,
5709 "error_message" : "Current transport does not support events."
5710 }
5711 ]
5712 })"},
5713 {"path_find: with arguments.",
5714 __LINE__,
5715 {"path_find", "string_arg", "1", "-1", "4294967296", "3.14159"},
5717 R"({
5718 "method" : "path_find",
5719 "params" : [
5720 {
5721 "error" : "noEvents",
5722 "error_code" : 7,
5723 "error_message" : "Current transport does not support events."
5724 }
5725 ]
5726 })"},
5727
5728 // subscribe
5729 // -------------------------------------------------------------------
5730 {"subscribe: minimal.",
5731 __LINE__,
5732 {
5733 "subscribe",
5734 },
5736 R"({
5737 "method" : "subscribe",
5738 "params" : [
5739 {
5740 "error" : "noEvents",
5741 "error_code" : 7,
5742 "error_message" : "Current transport does not support events."
5743 }
5744 ]
5745 })"},
5746 {"subscribe: with arguments.",
5747 __LINE__,
5748 {"subscribe", "string_arg", "1", "-1", "4294967296", "3.14159"},
5750 R"({
5751 "method" : "subscribe",
5752 "params" : [
5753 {
5754 "error" : "noEvents",
5755 "error_code" : 7,
5756 "error_message" : "Current transport does not support events."
5757 }
5758 ]
5759 })"},
5760
5761 // unsubscribe
5762 // -----------------------------------------------------------------
5763 {"unsubscribe: minimal.",
5764 __LINE__,
5765 {
5766 "unsubscribe",
5767 },
5769 R"({
5770 "method" : "unsubscribe",
5771 "params" : [
5772 {
5773 "error" : "noEvents",
5774 "error_code" : 7,
5775 "error_message" : "Current transport does not support events."
5776 }
5777 ]
5778 })"},
5779 {"unsubscribe: with arguments.",
5780 __LINE__,
5781 {"unsubscribe", "string_arg", "1", "-1", "4294967296", "3.14159"},
5783 R"({
5784 "method" : "unsubscribe",
5785 "params" : [
5786 {
5787 "error" : "noEvents",
5788 "error_code" : 7,
5789 "error_message" : "Current transport does not support events."
5790 }
5791 ]
5792 })"},
5793
5794 // unknown_command
5795 // -------------------------------------------------------------
5796 {"unknown_command: minimal.",
5797 __LINE__,
5798 {
5799 "unknown_command",
5800 },
5802 R"({
5803 "method" : "unknown_command",
5804 "params" : [
5805 {
5806 "api_version" : %API_VER%,
5807 }
5808 ]
5809 })"},
5810 {"unknown_command: with arguments.",
5811 __LINE__,
5812 {"unknown_command", "string_arg", "1", "-1", "4294967296", "3.14159"},
5814 R"({
5815 "method" : "unknown_command",
5816 "params" : [
5817 {
5818 "api_version" : %API_VER%,
5819 "params" : [ "string_arg", "1", "-1", "4294967296", "3.14159" ]
5820 }
5821 ]
5822 })"},
5823};
5824
5826updateAPIVersionString(char const* const req, unsigned apiVersion)
5827{
5828 std::string const version_str = std::to_string(apiVersion);
5829 static auto const place_holder = "%API_VER%";
5830 std::string jr(req);
5831 boost::replace_all(jr, place_holder, version_str);
5832 return jr;
5833}
5834
5836makeNetworkConfig(uint32_t networkID)
5837{
5838 using namespace test::jtx;
5839 return envconfig([&](std::unique_ptr<Config> cfg) {
5840 cfg->NETWORK_ID = networkID;
5841 return cfg;
5842 });
5843}
5844
5846{
5847public:
5848 void
5849 testRPCCall(unsigned apiVersion)
5850 {
5851 testcase << "RPCCall API version " << apiVersion;
5852 if (!BEAST_EXPECT(
5853 apiVersion >= RPC::apiMinimumSupportedVersion &&
5854 apiVersion <= RPC::apiMaximumValidVersion))
5855 return;
5856
5857 test::jtx::Env const env(*this, makeNetworkConfig(11111)); // Used only for its Journal.
5858
5859 // For each RPCCall test.
5860 for (RPCCallTestData const& rpcCallTest : rpcCallTestArray)
5861 {
5862 if (!BEAST_EXPECT(!rpcCallTest.exp.empty()))
5863 break;
5864
5865 std::vector<std::string> const args{rpcCallTest.args.begin(), rpcCallTest.args.end()};
5866
5867 char const* const expVersioned =
5868 (apiVersion - RPC::apiMinimumSupportedVersion) < rpcCallTest.exp.size()
5869 ? rpcCallTest.exp[apiVersion - RPC::apiMinimumSupportedVersion]
5870 : rpcCallTest.exp.back();
5871
5872 // Note that, over the long term, none of these tests should
5873 // throw. But, for the moment, some of them do. So handle it.
5874 Json::Value got;
5875 try
5876 {
5877 got = jtx::cmdToJSONRPC(args, env.journal, apiVersion);
5878 }
5879 catch (std::bad_cast const&)
5880 {
5881 if ((rpcCallTest.throwsWhat == RPCCallTestData::bad_cast) &&
5882 (std::strlen(expVersioned) == 0))
5883 {
5884 pass();
5885 }
5886 else
5887 {
5888 fail(rpcCallTest.description, __FILE__, rpcCallTest.line);
5889 }
5890 // Try the next test.
5891 continue;
5892 }
5893
5894 Json::Value exp;
5895 Json::Reader{}.parse(updateAPIVersionString(expVersioned, apiVersion), exp);
5896
5897 // Lambda to remove the "params[0u]:error_code" field if present.
5898 // Error codes are not expected to be stable between releases.
5899 auto rmErrorCode = [](Json::Value& json) {
5900 if (json.isMember(jss::params) && json[jss::params].isArray() &&
5901 json[jss::params].size() > 0 && json[jss::params][0u].isObject())
5902 {
5903 json[jss::params][0u].removeMember(jss::error_code);
5904 }
5905 };
5906 rmErrorCode(got);
5907 rmErrorCode(exp);
5908
5909 // Pass if we didn't expect a throw and we got what we expected.
5910 if ((rpcCallTest.throwsWhat == RPCCallTestData::no_exception) && (got == exp))
5911 {
5912 pass();
5913 }
5914 else
5915 {
5916 fail(rpcCallTest.description, __FILE__, rpcCallTest.line);
5917 }
5918 }
5919 }
5920
5921 void
5922 run() override
5923 {
5925 }
5926};
5927
5928BEAST_DEFINE_TESTSUITE(RPCCall, rpc, xrpl);
5929
5930} // namespace test
5931} // namespace xrpl
T begin(T... args)
T bind_front(T... args)
Unserialize a JSON document into a Value.
Definition json_reader.h:17
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Represents a JSON value.
Definition json_value.h:130
A testsuite class.
Definition suite.h:51
void pass()
Record a successful test condition.
Definition suite.h:497
testcase_t testcase
Memberspace for declaring test cases.
Definition suite.h:150
void fail(String const &reason, char const *file, int line)
Record a failure.
Definition suite.h:519
void run() override
Runs the suite.
void testRPCCall(unsigned apiVersion)
A transaction testing environment.
Definition Env.h:122
beast::Journal const journal
Definition Env.h:163
Inject raw JSON.
Definition jtx_json.h:13
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition rpc.h:15
static constexpr auto apiMinimumSupportedVersion
Definition ApiVersion.h:41
static constexpr auto apiMaximumValidVersion
Definition ApiVersion.h:46
Json::Value cmdToJSONRPC(std::vector< std::string > const &args, beast::Journal j, unsigned int apiVersion)
Given a rippled unit test rpc command, return the corresponding JSON.
Definition utility.cpp:66
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:34
std::unique_ptr< Config > makeNetworkConfig(uint32_t networkID)
static RPCCallTestData const rpcCallTestArray[]
std::string updateAPIVersionString(char const *const req, unsigned apiVersion)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
void forAllApiVersions(Fn const &fn, Args &&... args)
Definition ApiVersion.h:149
T strlen(T... args)
std::vector< char const * > exp
RPCCallTestData & operator=(RPCCallTestData &&)=delete
RPCCallTestData(char const *description_, int line_, std::initializer_list< char const * > const &args_, Exception throwsWhat_, std::initializer_list< char const * > exp_)
RPCCallTestData(char const *description_, int line_, std::initializer_list< char const * > const &args_, Exception throwsWhat_, char const *exp_)
char const *const description
std::vector< char const * > const args
RPCCallTestData(RPCCallTestData &&)=delete
RPCCallTestData & operator=(RPCCallTestData const &)=delete
RPCCallTestData(RPCCallTestData const &)=delete
T to_string(T... args)