xrpld
Loading...
Searching...
No Matches
RPCCall_test.cpp
1#include <test/jtx/Env.h>
2#include <test/jtx/envconfig.h>
3#include <test/jtx/utility.h>
4
5#include <xrpld/core/Config.h>
6#include <xrpld/rpc/MethodNames.h>
7#include <xrpld/rpc/RPCCall.h>
8#include <xrpld/rpc/detail/Handler.h>
9
10#include <xrpl/beast/unit_test/suite.h>
11#include <xrpl/json/json_reader.h>
12#include <xrpl/json/json_value.h>
13#include <xrpl/protocol/ApiVersion.h>
14#include <xrpl/protocol/jss.h>
15
16#include <boost/algorithm/string/replace.hpp>
17
18#include <algorithm>
19#include <array>
20#include <cstdint>
21#include <cstring>
22#include <initializer_list>
23#include <memory>
24#include <string>
25#include <string_view>
26#include <typeinfo>
27#include <vector>
28
29namespace xrpl::test {
30
32{
33 char const* const description;
34 int const line;
35 // List of passed arguments.
37
38 // If it throws, what does it throw?
39 enum class Exception { NoException = 0, BadCast };
41
42 // Expected JSON response.
44
54
64
65 RPCCallTestData() = delete;
69 operator=(RPCCallTestData const&) = delete;
72};
73
75 // account_channels
76 // ------------------------------------------------------------
77 {
78 "account_channels: minimal.",
79 __LINE__,
80 {"account_channels", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
82 R"({
83 "method" : "account_channels",
84 "params" : [
85 {
86 "api_version" : %API_VER%,
87 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
88 }
89 ]
90 })",
91 },
92 {
93 "account_channels: account and ledger hash.",
94 __LINE__,
95 {
96 "account_channels",
97 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
98 "rD5MbavGfiSC5m7mkxy1FANuT7s3HxqpoF",
99 },
101 R"({
102 "method" : "account_channels",
103 "params" : [
104 {
105 "api_version" : %API_VER%,
106 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
107 "destination_account" : "rD5MbavGfiSC5m7mkxy1FANuT7s3HxqpoF"
108 }
109 ]
110 })",
111 },
112 {
113 "account_channels: account and ledger index.",
114 __LINE__,
115 {
116 "account_channels",
117 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
118 "r9emE59aTWb85t64dAebKrxYMBTpzK5yR7",
119 },
121 R"({
122 "method" : "account_channels",
123 "params" : [
124 {
125 "api_version" : %API_VER%,
126 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
127 "destination_account" : "r9emE59aTWb85t64dAebKrxYMBTpzK5yR7"
128 }
129 ]
130 })",
131 },
132 {
133 "account_channels: two accounts.",
134 __LINE__,
135 {
136 "account_channels",
137 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
138 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
139 },
141 R"({
142 "method" : "account_channels",
143 "params" : [
144 {
145 "api_version" : %API_VER%,
146 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
147 "destination_account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
148 }
149 ]
150 })",
151 },
152 {
153 "account_channels: two accounts and ledger hash.",
154 __LINE__,
155 {
156 "account_channels",
157 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
158 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
159 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
160 },
162 R"({
163 "method" : "account_channels",
164 "params" : [
165 {
166 "api_version" : %API_VER%,
167 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
168 "destination_account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
169 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
170 }
171 ]
172 })",
173 },
174 {
175 "account_channels: two accounts and ledger index.",
176 __LINE__,
177 {
178 "account_channels",
179 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
180 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
181 "90210",
182 },
184 R"({
185 "method" : "account_channels",
186 "params" : [
187 {
188 "api_version" : %API_VER%,
189 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
190 "destination_account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
191 "ledger_index" : 90210
192 }
193 ]
194 })",
195 },
196 {
197 "account_channels: too few arguments.",
198 __LINE__,
199 {
200 "account_channels",
201 },
203 R"({
204 "method" : "account_channels",
205 "params" : [
206 {
207 "error" : "badSyntax",
208 "error_code" : 1,
209 "error_message" : "Syntax error."
210 }
211 ]
212 })",
213 },
214 {
215 "account_channels: too many arguments.",
216 __LINE__,
217 {
218 "account_channels",
219 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
220 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
221 "current",
222 "extra",
223 },
225 R"({
226 "method" : "account_channels",
227 "params" : [
228 {
229 "error" : "badSyntax",
230 "error_code" : 1,
231 "error_message" : "Syntax error."
232 }
233 ]
234 })",
235 },
236 {
237 "account_channels: invalid accountID.",
238 __LINE__,
239 {
240 "account_channels",
241 "", // Note: very few values are detected as bad!
242 },
244 R"({
245 "method" : "account_channels",
246 "params" : [
247 {
248 "error" : "actMalformed",
249 "error_code" : 35,
250 "error_message" : "Account malformed."
251 }
252 ]
253 })",
254 },
255
256 // account_currencies
257 // ----------------------------------------------------------
258 {
259 "account_currencies: minimal 1.",
260 __LINE__,
261 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
263 R"({
264 "method" : "account_currencies",
265 "params" : [
266 {
267 "api_version" : %API_VER%,
268 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
269 }
270 ]
271 })",
272 },
273 {
274 "account_currencies: minimal 2.",
275 __LINE__,
276 {"account_currencies", "racb4o3DrdYxuCfyVa6vsLb7vgju9RFbBr"},
278 R"({
279 "method" : "account_currencies",
280 "params" : [
281 {
282 "api_version" : %API_VER%,
283 "account" : "racb4o3DrdYxuCfyVa6vsLb7vgju9RFbBr"
284 }
285 ]
286 })",
287 },
288 {
289 "account_currencies: ledger index.",
290 __LINE__,
291 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "42"},
293 R"({
294 "method" : "account_currencies",
295 "params" : [
296 {
297 "api_version" : %API_VER%,
298 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
299 "ledger_index" : 42
300 }
301 ]
302 })",
303 },
304 {
305 "account_currencies: validated ledger.",
306 __LINE__,
307 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
309 R"({
310 "method" : "account_currencies",
311 "params" : [
312 {
313 "api_version" : %API_VER%,
314 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
315 "ledger_index" : "validated"
316 }
317 ]
318 })",
319 },
320 {
321 "account_currencies: current ledger.",
322 __LINE__,
323 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "current"},
325 R"({
326 "method" : "account_currencies",
327 "params" : [
328 {
329 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
330 "api_version" : %API_VER%,
331 "ledger_index" : "current"
332 }
333 ]
334 })",
335 },
336 {
337 "account_currencies: too few arguments.",
338 __LINE__,
339 {
340 "account_currencies",
341 },
343 R"({
344 "method" : "account_currencies",
345 "params" : [
346 {
347 "error" : "badSyntax",
348 "error_code" : 1,
349 "error_message" : "Syntax error."
350 }
351 ]
352 })",
353 },
354 {
355 "account_currencies: too many arguments.",
356 __LINE__,
357 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "current", "spare1", "spare2"},
359 R"({
360 "method" : "account_currencies",
361 "params" : [
362 {
363 "error" : "badSyntax",
364 "error_code" : 1,
365 "error_message" : "Syntax error."
366 }
367 ]
368 })",
369 },
370 {
371 "account_currencies: invalid second argument.",
372 __LINE__,
373 {"account_currencies", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "yup"},
375 R"({
376 "method" : "account_currencies",
377 "params" : [
378 {
379 "api_version" : %API_VER%,
380 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
381 "ledger_index" : 0
382 }
383 ]
384 })",
385 },
386 {
387 "account_currencies: invalid accountID.",
388 __LINE__,
389 {
390 "account_currencies",
391 "", // Note: very few values are detected as bad!
392 },
394 R"({
395 "method" : "account_currencies",
396 "params" : [
397 {
398 "error" : "actMalformed",
399 "error_code" : 35,
400 "error_message" : "Account malformed."
401 }
402 ]
403 })",
404 },
405
406 // account_info
407 // ----------------------------------------------------------------
408 {
409 "account_info: minimal.",
410 __LINE__,
411 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
413 R"({
414 "method" : "account_info",
415 "params" : [
416 {
417 "api_version" : %API_VER%,
418 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
419 }
420 ]
421 })",
422 },
423 {
424 "account_info: with numeric ledger index.",
425 __LINE__,
426 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "77777"},
428 R"({
429 "method" : "account_info",
430 "params" : [
431 {
432 "api_version" : %API_VER%,
433 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
434 "ledger_index" : 77777
435 }
436 ]
437 })",
438 },
439 {
440 "account_info: with text ledger index.",
441 __LINE__,
442 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "closed"},
444 R"({
445 "method" : "account_info",
446 "params" : [
447 {
448 "api_version" : %API_VER%,
449 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
450 "ledger_index" : "closed"
451 }
452 ]
453 })",
454 },
455 {
456 "account_info: with ledger hash.",
457 __LINE__,
458 {
459 "account_info",
460 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
461 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
462 },
464 R"({
465 "method" : "account_info",
466 "params" : [
467 {
468 "api_version" : %API_VER%,
469 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
470 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
471 }
472 ]
473 })",
474 },
475 {
476 "account_info: with ledger index.",
477 __LINE__,
478 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
480 R"({
481 "method" : "account_info",
482 "params" : [
483 {
484 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
485 "api_version" : %API_VER%,
486 "ledger_index" : "validated"
487 }
488 ]
489 })",
490 },
491 {
492 "account_info: too few arguments.",
493 __LINE__,
494 {
495 "account_info",
496 },
498 R"({
499 "method" : "account_info",
500 "params" : [
501 {
502 "error" : "badSyntax",
503 "error_code" : 1,
504 "error_message" : "Syntax error."
505 }
506 ]
507 })",
508 },
509 {
510 "account_info: too many arguments.",
511 __LINE__,
512 {"account_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "current", "extra1", "extra2"},
514 R"({
515 "method" : "account_info",
516 "params" : [
517 {
518 "error" : "badSyntax",
519 "error_code" : 1,
520 "error_message" : "Syntax error."
521 }
522 ]
523 })",
524 },
525 {
526 "account_info: invalid accountID.",
527 __LINE__,
528 {
529 "account_info",
530 "", // Note: very few values are detected as bad!
531 },
533 R"({
534 "method" : "account_info",
535 "params" : [
536 {
537 "error" : "actMalformed",
538 "error_code" : 35,
539 "error_message" : "Account malformed."
540 }
541 ]
542 })",
543 },
544
545 // account_lines
546 // ---------------------------------------------------------------
547 {
548 "account_lines: minimal.",
549 __LINE__,
550 {"account_lines", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
552 R"({
553 "method" : "account_lines",
554 "params" : [
555 {
556 "api_version" : %API_VER%,
557 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
558 }
559 ]
560 })",
561 },
562 {
563 "account_lines: peer.",
564 __LINE__,
565 {
566 "account_lines",
567 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
568 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
569 },
571 R"({
572 "method" : "account_lines",
573 "params" : [
574 {
575 "api_version" : %API_VER%,
576 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
577 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
578 }
579 ]
580 })",
581 },
582 {
583 "account_lines: peer and numeric ledger index.",
584 __LINE__,
585 {
586 "account_lines",
587 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
588 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
589 "888888888",
590 },
592 R"({
593 "method" : "account_lines",
594 "params" : [
595 {
596 "api_version" : %API_VER%,
597 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
598 "ledger_index" : 888888888,
599 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
600 }
601 ]
602 })",
603 },
604 {
605 "account_lines: peer and text ledger index.",
606 __LINE__,
607 {
608 "account_lines",
609 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
610 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
611 "closed",
612 },
614 R"({
615 "method" : "account_lines",
616 "params" : [
617 {
618 "api_version" : %API_VER%,
619 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
620 "ledger_index" : "closed",
621 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
622 }
623 ]
624 })",
625 },
626 {
627 "account_lines: peer and ledger hash.",
628 __LINE__,
629 {
630 "account_lines",
631 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
632 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
633 "FFFFEEEEDDDDCCCCBBBBAAAA9999888877776666555544443333222211110000",
634 },
636 R"({
637 "method" : "account_lines",
638 "params" : [
639 {
640 "api_version" : %API_VER%,
641 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
642 "ledger_hash" : "FFFFEEEEDDDDCCCCBBBBAAAA9999888877776666555544443333222211110000",
643 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
644 }
645 ]
646 })",
647 },
648 {
649 "account_lines: too few arguments.",
650 __LINE__,
651 {
652 "account_lines",
653 },
655 R"({
656 "method" : "account_lines",
657 "params" : [
658 {
659 "error" : "badSyntax",
660 "error_code" : 1,
661 "error_message" : "Syntax error."
662 }
663 ]
664 })",
665 },
666 {
667 // Note: I believe this _ought_ to be detected as too many arguments.
668 "account_lines: four arguments.",
669 __LINE__,
670 {
671 "account_lines",
672 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
673 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
674 "12345678",
675 "current",
676 },
678 R"({
679 "method" : "account_lines",
680 "params" : [
681 {
682 "api_version" : %API_VER%,
683 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
684 "ledger_index" : 12345678,
685 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
686 }
687 ]
688 })",
689 },
690 {
691 // Note: I believe this _ought_ to be detected as too many arguments.
692 "account_lines: five arguments.",
693 __LINE__,
694 {
695 "account_lines",
696 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
697 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
698 "12345678",
699 "current",
700 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
701 },
703 R"({
704 "method" : "account_lines",
705 "params" : [
706 {
707 "api_version" : %API_VER%,
708 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
709 "ledger_index" : 12345678,
710 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
711 }
712 ]
713 })",
714 },
715 {
716 "account_lines: too many arguments.",
717 __LINE__,
718 {
719 "account_lines",
720 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
721 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
722 "12345678",
723 "current",
724 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
725 "validated",
726 },
728 R"({
729 "method" : "account_lines",
730 "params" : [
731 {
732 "error" : "badSyntax",
733 "error_code" : 1,
734 "error_message" : "Syntax error."
735 }
736 ]
737 })",
738 },
739 {
740 "account_lines: first invalid accountID.",
741 __LINE__,
742 {
743 "account_lines",
744 "", // Note: very few values are detected as bad!
745 },
747 R"({
748 "method" : "account_lines",
749 "params" : [
750 {
751 "error" : "actMalformed",
752 "error_code" : 35,
753 "error_message" : "Account malformed."
754 }
755 ]
756 })",
757 },
758 {
759 "account_lines: second invalid accountID.",
760 __LINE__,
761 {
762 "account_lines",
763 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
764 "", // Note: very few values are detected as bad!
765 },
767 R"({
768 "method" : "account_lines",
769 "params" : [
770 {
771 "api_version" : %API_VER%,
772 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
773 }
774 ]
775 })",
776 },
777 {
778 "account_lines: invalid ledger selector.",
779 __LINE__,
780 {
781 "account_lines",
782 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
783 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
784 "not_a_ledger",
785 },
787 R"({
788 "method" : "account_lines",
789 "params" : [
790 {
791 "api_version" : %API_VER%,
792 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
793 "ledger_index" : 0,
794 "peer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
795 }
796 ]
797 })",
798 },
799
800 // account_objects
801 // -------------------------------------------------------------
802 {
803 "account_objects: minimal.",
804 __LINE__,
805 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
807 R"({
808 "method" : "account_objects",
809 "params" : [
810 {
811 "api_version" : %API_VER%,
812 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
813 }
814 ]
815 })",
816 },
817 {
818 "account_objects: with numeric ledger index.",
819 __LINE__,
820 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "77777"},
822 R"({
823 "method" : "account_objects",
824 "params" : [
825 {
826 "api_version" : %API_VER%,
827 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
828 "ledger_index" : 77777
829 }
830 ]
831 })",
832 },
833 {
834 "account_objects: with text ledger index.",
835 __LINE__,
836 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "closed"},
838 R"({
839 "method" : "account_objects",
840 "params" : [
841 {
842 "api_version" : %API_VER%,
843 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
844 "ledger_index" : "closed"
845 }
846 ]
847 })",
848 },
849 {
850 "account_objects: with ledger hash.",
851 __LINE__,
852 {
853 "account_objects",
854 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
855 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
856 },
858 R"({
859 "method" : "account_objects",
860 "params" : [
861 {
862 "api_version" : %API_VER%,
863 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
864 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
865 }
866 ]
867 })",
868 },
869 {
870 "account_objects: with ledger index.",
871 __LINE__,
872 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
874 R"({
875 "method" : "account_objects",
876 "params" : [
877 {
878 "api_version" : %API_VER%,
879 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
880 "ledger_index" : "validated"
881 }
882 ]
883 })",
884 },
885 {
886 "account_objects: too few arguments.",
887 __LINE__,
888 {
889 "account_objects",
890 },
892 R"({
893 "method" : "account_objects",
894 "params" : [
895 {
896 "error" : "badSyntax",
897 "error_code" : 1,
898 "error_message" : "Syntax error."
899 }
900 ]
901 })",
902 },
903 {
904 // Note: I believe this _ought_ to be detected as too many arguments.
905 "account_objects: four arguments.",
906 __LINE__,
907 {
908 "account_objects",
909 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
910 "current",
911 "extra1",
912 "extra2",
913 },
915 R"({
916 "method" : "account_objects",
917 "params" : [
918 {
919 "api_version" : %API_VER%,
920 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
921 }
922 ]
923 })",
924 },
925 {
926 // Note: I believe this _ought_ to be detected as too many arguments.
927 "account_objects: five arguments.",
928 __LINE__,
929 {
930 "account_objects",
931 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
932 "current",
933 "extra1",
934 "extra2",
935 "extra3",
936 },
938 R"({
939 "method" : "account_objects",
940 "params" : [
941 {
942 "api_version" : %API_VER%,
943 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
944 }
945 ]
946 })",
947 },
948 {
949 "account_objects: too many arguments.",
950 __LINE__,
951 {
952 "account_objects",
953 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
954 "current",
955 "extra1",
956 "extra2",
957 "extra3",
958 "extra4",
959 },
961 R"({
962 "method" : "account_objects",
963 "params" : [
964 {
965 "error" : "badSyntax",
966 "error_code" : 1,
967 "error_message" : "Syntax error."
968 }
969 ]
970 })",
971 },
972 {
973 "account_objects: invalid accountID.",
974 __LINE__,
975 {
976 "account_objects",
977 "", // Note: very few values are detected as bad!
978 },
980 R"({
981 "method" : "account_objects",
982 "params" : [
983 {
984 "error" : "actMalformed",
985 "error_code" : 35,
986 "error_message" : "Account malformed."
987 }
988 ]
989 })",
990 },
991 {
992 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
993 // cannot currently occur because jvParseLedger() always returns true.
994 "account_objects: invalid ledger selection 1.",
995 __LINE__,
996 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
998 R"({
999 "method" : "account_objects",
1000 "params" : [
1001 {
1002 "api_version" : %API_VER%,
1003 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1004 "ledger_index" : 0
1005 }
1006 ]
1007 })",
1008 },
1009 {
1010 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
1011 // cannot currently occur because jvParseLedger() always returns true.
1012 "account_objects: invalid ledger selection 2.",
1013 __LINE__,
1014 {"account_objects", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
1016 R"({
1017 "method" : "account_objects",
1018 "params" : [
1019 {
1020 "api_version" : %API_VER%,
1021 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1022 "ledger_index" : 0
1023 }
1024 ]
1025 })",
1026 },
1027
1028 // account_offers
1029 // --------------------------------------------------------------
1030 {
1031 "account_offers: minimal.",
1032 __LINE__,
1033 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
1035 R"({
1036 "method" : "account_offers",
1037 "params" : [
1038 {
1039 "api_version" : %API_VER%,
1040 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1041 }
1042 ]
1043 })",
1044 },
1045 {
1046 "account_offers: with numeric ledger index.",
1047 __LINE__,
1048 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "987654321"},
1050 R"({
1051 "method" : "account_offers",
1052 "params" : [
1053 {
1054 "api_version" : %API_VER%,
1055 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1056 "ledger_index" : 987654321
1057 }
1058 ]
1059 })",
1060 },
1061 {
1062 "account_offers: with text ledger index.",
1063 __LINE__,
1064 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
1066 R"({
1067 "method" : "account_offers",
1068 "params" : [
1069 {
1070 "api_version" : %API_VER%,
1071 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1072 "ledger_index" : "validated"
1073 }
1074 ]
1075 })",
1076 },
1077 {
1078 "account_offers: with ledger hash.",
1079 __LINE__,
1080 {
1081 "account_offers",
1082 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1083 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
1084 },
1086 R"({
1087 "method" : "account_offers",
1088 "params" : [
1089 {
1090 "api_version" : %API_VER%,
1091 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1092 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
1093 }
1094 ]
1095 })",
1096 },
1097 {
1098 "account_offers: with ledger index.",
1099 __LINE__,
1100 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
1102 R"({
1103 "method" : "account_offers",
1104 "params" : [
1105 {
1106 "api_version" : %API_VER%,
1107 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1108 "ledger_index" : "validated"
1109 }
1110 ]
1111 })",
1112 },
1113 {
1114 "account_offers: too few arguments.",
1115 __LINE__,
1116 {
1117 "account_offers",
1118 },
1120 R"({
1121 "method" : "account_offers",
1122 "params" : [
1123 {
1124 "error" : "badSyntax",
1125 "error_code" : 1,
1126 "error_message" : "Syntax error."
1127 }
1128 ]
1129 })",
1130 },
1131 {
1132 // Note: I believe this _ought_ to be detected as too many arguments.
1133 "account_offers: four arguments.",
1134 __LINE__,
1135 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "current", "extra"},
1137 R"({
1138 "method" : "account_offers",
1139 "params" : [
1140 {
1141 "api_version" : %API_VER%,
1142 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1143 }
1144 ]
1145 })",
1146 },
1147 {
1148 "account_offers: too many arguments.",
1149 __LINE__,
1150 {
1151 "account_offers",
1152 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1153 "current",
1154 "extra1",
1155 "extra2",
1156 "extra3",
1157 },
1159 R"({
1160 "method" : "account_offers",
1161 "params" : [
1162 {
1163 "error" : "badSyntax",
1164 "error_code" : 1,
1165 "error_message" : "Syntax error."
1166 }
1167 ]
1168 })",
1169 },
1170 {
1171 "account_offers: invalid accountID.",
1172 __LINE__,
1173 {
1174 "account_offers",
1175 "", // Note: very few values are detected as bad!
1176 },
1178 R"({
1179 "method" : "account_offers",
1180 "params" : [
1181 {
1182 "error" : "actMalformed",
1183 "error_code" : 35,
1184 "error_message" : "Account malformed."
1185 }
1186 ]
1187 })",
1188 },
1189 {
1190 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
1191 // cannot currently occur because jvParseLedger() always returns true.
1192 "account_offers: invalid ledger selection 1.",
1193 __LINE__,
1194 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
1196 R"({
1197 "method" : "account_offers",
1198 "params" : [
1199 {
1200 "api_version" : %API_VER%,
1201 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1202 "ledger_index" : 0
1203 }
1204 ]
1205 })",
1206 },
1207 {
1208 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
1209 // cannot currently occur because jvParseLedger() always returns true.
1210 "account_offers: invalid ledger selection 2.",
1211 __LINE__,
1212 {"account_offers", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
1214 R"({
1215 "method" : "account_offers",
1216 "params" : [
1217 {
1218 "api_version" : %API_VER%,
1219 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1220 "ledger_index" : 0
1221 }
1222 ]
1223 })",
1224 },
1225
1226 // account_tx
1227 // ------------------------------------------------------------------
1228 {
1229 "account_tx: minimal.",
1230 __LINE__,
1231 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
1233 R"({
1234 "method" : "account_tx",
1235 "params" : [
1236 {
1237 "api_version" : %API_VER%,
1238 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1239 }
1240 ]
1241 })",
1242 },
1243 {
1244 "account_tx: ledger_index .",
1245 __LINE__,
1246 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "444"},
1248 R"({
1249 "method" : "account_tx",
1250 "params" : [
1251 {
1252 "api_version" : %API_VER%,
1253 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1254 "ledger_index" : 444
1255 }
1256 ]
1257 })",
1258 },
1259 {
1260 "account_tx: ledger_index plus trailing params.",
1261 __LINE__,
1262 {
1263 "account_tx",
1264 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1265 "707",
1266 "descending",
1267 "binary",
1268 "count",
1269 },
1271 R"({
1272 "method" : "account_tx",
1273 "params" : [
1274 {
1275 "api_version" : %API_VER%,
1276 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1277 "count" : true,
1278 "binary" : true,
1279 "descending" : true,
1280 "ledger_index" : 707
1281 }
1282 ]
1283 })",
1284 },
1285 {
1286 "account_tx: ledger_index_min and _max.",
1287 __LINE__,
1288 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "-1"},
1290 R"({
1291 "method" : "account_tx",
1292 "params" : [
1293 {
1294 "api_version" : %API_VER%,
1295 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1296 "ledger_index_max" : -1,
1297 "ledger_index_min" : -1
1298 }
1299 ]
1300 })",
1301 },
1302 {
1303 "account_tx: ledger_index_min and _max plus trailing params.",
1304 __LINE__,
1305 {
1306 "account_tx",
1307 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1308 "-1",
1309 "413",
1310 "binary",
1311 "count",
1312 "descending",
1313 },
1315 R"({
1316 "method" : "account_tx",
1317 "params" : [
1318 {
1319 "api_version" : %API_VER%,
1320 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1321 "binary" : true,
1322 "count" : true,
1323 "descending" : true,
1324 "ledger_index_max" : 413,
1325 "ledger_index_min" : -1
1326 }
1327 ]
1328 })",
1329 },
1330 {
1331 "account_tx: ledger_index_min and _max plus limit.",
1332 __LINE__,
1333 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "247", "-1", "300"},
1335 R"({
1336 "method" : "account_tx",
1337 "params" : [
1338 {
1339 "api_version" : %API_VER%,
1340 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1341 "ledger_index_max" : -1,
1342 "ledger_index_min" : 247,
1343 "limit" : 300
1344 }
1345 ]
1346 })",
1347 },
1348 {
1349 "account_tx: ledger_index_min and _max, limit, trailing args.",
1350 __LINE__,
1351 {
1352 "account_tx",
1353 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1354 "247",
1355 "-1",
1356 "300",
1357 "count",
1358 "descending",
1359 "binary",
1360 },
1362 R"({
1363 "method" : "account_tx",
1364 "params" : [
1365 {
1366 "api_version" : %API_VER%,
1367 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1368 "binary" : true,
1369 "count" : true,
1370 "descending" : true,
1371 "ledger_index_max" : -1,
1372 "ledger_index_min" : 247,
1373 "limit" : 300
1374 }
1375 ]
1376 })",
1377 },
1378 {
1379 "account_tx: ledger_index_min and _max plus limit and offset.",
1380 __LINE__,
1381 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "589", "590", "67", "45"},
1383 R"({
1384 "method" : "account_tx",
1385 "params" : [
1386 {
1387 "api_version" : %API_VER%,
1388 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1389 "ledger_index_max" : 590,
1390 "ledger_index_min" : 589,
1391 "limit" : 67,
1392 "offset" : 45
1393 }
1394 ]
1395 })",
1396 },
1397 {
1398 "account_tx: ledger_index_min and _max, limit, offset, trailing.",
1399 __LINE__,
1400 {
1401 "account_tx",
1402 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1403 "589",
1404 "590",
1405 "67",
1406 "45",
1407 "descending",
1408 "count",
1409 },
1411 R"({
1412 "method" : "account_tx",
1413 "params" : [
1414 {
1415 "api_version" : %API_VER%,
1416 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1417 "count" : true,
1418 "descending" : true,
1419 "ledger_index_max" : 590,
1420 "ledger_index_min" : 589,
1421 "limit" : 67,
1422 "offset" : 45
1423 }
1424 ]
1425 })",
1426 },
1427 {
1428 "account_tx: too few arguments.",
1429 __LINE__,
1430 {
1431 "account_tx",
1432 },
1434 R"({
1435 "method" : "account_tx",
1436 "params" : [
1437 {
1438 "error" : "badSyntax",
1439 "error_code" : 1,
1440 "error_message" : "Syntax error."
1441 }
1442 ]
1443 })",
1444 },
1445 {
1446 "account_tx: too many arguments.",
1447 __LINE__,
1448 {
1449 "account_tx",
1450 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1451 "589",
1452 "590",
1453 "67",
1454 "45",
1455 "extra",
1456 "descending",
1457 "count",
1458 "binary",
1459 },
1461 R"({
1462 "method" : "account_tx",
1463 "params" : [
1464 {
1465 "error" : "badSyntax",
1466 "error_code" : 1,
1467 "error_message" : "Syntax error."
1468 }
1469 ]
1470 })",
1471 },
1472 {
1473 "account_tx: invalid accountID.",
1474 __LINE__,
1475 {"account_tx", "rHb9CJAWyB4rj9!VRWn96DkukG4bwdtyTh"},
1477 R"({
1478 "method" : "account_tx",
1479 "params" : [
1480 {
1481 "error" : "actMalformed",
1482 "error_code" : 35,
1483 "error_message" : "Account malformed."
1484 }
1485 ]
1486 })",
1487 },
1488 {
1489 // Note: not currently detected as bad input.
1490 "account_tx: invalid ledger.",
1491 __LINE__,
1492 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-478.7"},
1494 R"({
1495 "method" : "account_tx",
1496 "params" : [
1497 {
1498 "api_version" : %API_VER%,
1499 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1500 "ledger_index" : 0
1501 }
1502 ]
1503 })",
1504 },
1505 {
1506 "account_tx: max less than min.",
1507 __LINE__,
1508 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "580", "579"},
1510 {
1511 R"({
1512 "method" : "account_tx",
1513 "params" : [
1514 {
1515 "error" : "lgrIdxsInvalid",
1516 "error_code" : 55,
1517 "error_message" : "Ledger indexes invalid."
1518 }
1519 ]
1520 })",
1521 R"({
1522 "method" : "account_tx",
1523 "params" : [
1524 {
1525 "error" : "notSynced",
1526 "error_code" : 55,
1527 "error_message" : "Not synced to the network."
1528 }
1529 ]
1530 })",
1531 },
1532 },
1533 {
1534 // Note: this really shouldn't throw, but does at the moment.
1535 "account_tx: non-integer min.",
1536 __LINE__,
1537 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Binary", "-1"},
1539 R"()",
1540 },
1541 {
1542 // Note: this really shouldn't throw, but does at the moment.
1543 "account_tx: non-integer max.",
1544 __LINE__,
1545 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "counts"},
1547 R"()",
1548 },
1549 {
1550 // Note: this really shouldn't throw, but does at the moment.
1551 "account_tx: non-integer offset.",
1552 __LINE__,
1553 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "-1", "decending"},
1555 R"()",
1556 },
1557 {
1558 // Note: this really shouldn't throw, but does at the moment.
1559 "account_tx: non-integer limit.",
1560 __LINE__,
1561 {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "-1", "300", "false"},
1563 R"()",
1564 },
1565 {
1566 // Note: this really shouldn't throw, but does at the moment.
1567 "account_tx: RIPD-1570.",
1568 __LINE__,
1569 {
1570 "account_tx",
1571 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1572 "-1",
1573 "-1",
1574 "2",
1575 "false",
1576 "false",
1577 "false",
1578 },
1580 R"()",
1581 },
1582
1583 // book_offers
1584 // -----------------------------------------------------------------
1585 {
1586 "book_offers: minimal no issuer.",
1587 __LINE__,
1588 {
1589 "book_offers",
1590 "USD",
1591 "EUR",
1592 },
1594 R"({
1595 "method" : "book_offers",
1596 "params" : [
1597 {
1598 "api_version" : %API_VER%,
1599 "taker_gets" : {
1600 "currency" : "EUR"
1601 },
1602 "taker_pays" : {
1603 "currency" : "USD"
1604 }
1605 }
1606 ]
1607 })",
1608 },
1609 {
1610 "book_offers: minimal with currency/issuer",
1611 __LINE__,
1612 {
1613 "book_offers",
1614 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1615 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1616 },
1618 R"({
1619 "method" : "book_offers",
1620 "params" : [
1621 {
1622 "api_version" : %API_VER%,
1623 "taker_gets" : {
1624 "currency" : "EUR",
1625 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1626 },
1627 "taker_pays" : {
1628 "currency" : "USD",
1629 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1630 }
1631 }
1632 ]
1633 })",
1634 },
1635 {
1636 // Note: documentation suggests that "issuer" is the wrong type.
1637 // Should it be "taker" instead?
1638 "book_offers: add issuer.",
1639 __LINE__,
1640 {"book_offers", "USD", "EUR", "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"},
1642 R"({
1643 "method" : "book_offers",
1644 "params" : [
1645 {
1646 "api_version" : %API_VER%,
1647 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1648 "taker_gets" : {
1649 "currency" : "EUR"
1650 },
1651 "taker_pays" : {
1652 "currency" : "USD"
1653 }
1654 }
1655 ]
1656 })",
1657 },
1658 {
1659 "book_offers: add issuer and numeric ledger index.",
1660 __LINE__,
1661 {
1662 "book_offers",
1663 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1664 "EUR",
1665 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1666 "666",
1667 },
1669 R"({
1670 "method" : "book_offers",
1671 "params" : [
1672 {
1673 "api_version" : %API_VER%,
1674 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1675 "ledger_index" : 666,
1676 "taker_gets" : {
1677 "currency" : "EUR"
1678 },
1679 "taker_pays" : {
1680 "currency" : "USD",
1681 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1682 }
1683 }
1684 ]
1685 })",
1686 },
1687 {
1688 "book_offers: add issuer and text ledger index.",
1689 __LINE__,
1690 {
1691 "book_offers",
1692 "USD",
1693 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1694 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1695 "current",
1696 },
1698 R"({
1699 "method" : "book_offers",
1700 "params" : [
1701 {
1702 "api_version" : %API_VER%,
1703 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1704 "ledger_index" : "current",
1705 "taker_gets" : {
1706 "currency" : "EUR",
1707 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1708 },
1709 "taker_pays" : {
1710 "currency" : "USD"
1711 }
1712 }
1713 ]
1714 })",
1715 },
1716 {
1717 "book_offers: add issuer and ledger hash.",
1718 __LINE__,
1719 {
1720 "book_offers",
1721 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1722 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1723 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1724 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1725 },
1727 R"({
1728 "method" : "book_offers",
1729 "params" : [
1730 {
1731 "api_version" : %API_VER%,
1732 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1733 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1734 "taker_gets" : {
1735 "currency" : "EUR",
1736 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1737 },
1738 "taker_pays" : {
1739 "currency" : "USD",
1740 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1741 }
1742 }
1743 ]
1744 })",
1745 },
1746 {
1747 "book_offers: issuer, ledger hash, and limit.",
1748 __LINE__,
1749 {
1750 "book_offers",
1751 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1752 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1753 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1754 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1755 "200",
1756 },
1758 R"({
1759 "method" : "book_offers",
1760 "params" : [
1761 {
1762 "api_version" : %API_VER%,
1763 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1764 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1765 "limit" : 200,
1766 "taker_gets" : {
1767 "currency" : "EUR",
1768 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1769 },
1770 "taker_pays" : {
1771 "currency" : "USD",
1772 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1773 }
1774 }
1775 ]
1776 })",
1777 },
1778 {
1779 // Note: parser supports "marker", but the docs don't cover it.
1780 "book_offers: issuer, ledger hash, limit, and marker.",
1781 __LINE__,
1782 {
1783 "book_offers",
1784 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1785 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1786 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1787 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1788 "200",
1789 "0",
1790 "MyMarker",
1791 },
1793 R"({
1794 "method" : "book_offers",
1795 "params" : [
1796 {
1797 "api_version" : %API_VER%,
1798 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1799 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1800 "limit" : 200,
1801 "marker" : "MyMarker",
1802 "taker_gets" : {
1803 "currency" : "EUR",
1804 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1805 },
1806 "taker_pays" : {
1807 "currency" : "USD",
1808 "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1809 }
1810 }
1811 ]
1812 })",
1813 },
1814 {
1815 "book_offers: too few arguments.",
1816 __LINE__,
1817 {
1818 "book_offers",
1819 },
1821 R"({
1822 "method" : "book_offers",
1823 "params" : [
1824 {
1825 "error" : "badSyntax",
1826 "error_code" : 1,
1827 "error_message" : "Syntax error."
1828 }
1829 ]
1830 })",
1831 },
1832 {
1833 "book_offers: too many arguments.",
1834 __LINE__,
1835 {
1836 "book_offers",
1837 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1838 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1839 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1840 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1841 "200",
1842 "0",
1843 "MyMarker",
1844 "extra",
1845 },
1847 R"({
1848 "method" : "book_offers",
1849 "params" : [
1850 {
1851 "error" : "badSyntax",
1852 "error_code" : 1,
1853 "error_message" : "Syntax error."
1854 }
1855 ]
1856 })",
1857 },
1858
1859 {
1860 "book_offers: taker pays no currency.",
1861 __LINE__,
1862 {
1863 "book_offers",
1864 "/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1865 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1866 },
1868 R"({
1869 "method" : "book_offers",
1870 "params" : [
1871 {
1872 "error" : "invalidParams",
1873 "error_code" : 31,
1874 "error_message" : "Invalid currency/issuer '/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'"
1875 }
1876 ]
1877 })",
1878 },
1879 {
1880 "book_offers: taker gets no currency.",
1881 __LINE__,
1882 {
1883 "book_offers",
1884 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1885 "/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1886 },
1888 R"({
1889 "method" : "book_offers",
1890 "params" : [
1891 {
1892 "error" : "invalidParams",
1893 "error_code" : 31,
1894 "error_message" : "Invalid currency/issuer '/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA'"
1895 }
1896 ]
1897 })",
1898 },
1899 {
1900 "book_offers: invalid issuer.",
1901 __LINE__,
1902 {"book_offers", "USD", "EUR", "not_a_valid_issuer"},
1904 R"({
1905 "method" : "book_offers",
1906 "params" : [
1907 {
1908 "api_version" : %API_VER%,
1909 "issuer" : "not_a_valid_issuer",
1910 "taker_gets" : {
1911 "currency" : "EUR"
1912 },
1913 "taker_pays" : {
1914 "currency" : "USD"
1915 }
1916 }
1917 ]
1918 })",
1919 },
1920 {
1921 "book_offers: invalid text ledger index.",
1922 __LINE__,
1923 {
1924 "book_offers",
1925 "USD",
1926 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1927 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1928 "not_a_ledger",
1929 },
1931 R"({
1932 "method" : "book_offers",
1933 "params" : [
1934 {
1935 "api_version" : %API_VER%,
1936 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1937 "ledger_index" : 0,
1938 "taker_gets" : {
1939 "currency" : "EUR",
1940 "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1941 },
1942 "taker_pays" : {
1943 "currency" : "USD"
1944 }
1945 }
1946 ]
1947 })",
1948 },
1949 {
1950 // Note: this really shouldn't throw, but does at the moment.
1951 "book_offers: non-numeric limit.",
1952 __LINE__,
1953 {
1954 "book_offers",
1955 "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1956 "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1957 "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1958 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1959 "not_a_number",
1960 },
1962 R"({
1963 "method" : "book_offers",
1964 "params" : [
1965 {
1966 "error" : "invalidParams",
1967 "error_code" : 31,
1968 "error_message" : "Invalid field 'limit'."
1969 }
1970 ]
1971 })",
1972 },
1973
1974 // can_delete
1975 // ------------------------------------------------------------------
1976 {
1977 "can_delete: minimal.",
1978 __LINE__,
1979 {
1980 "can_delete",
1981 },
1983 R"({
1984 "method" : "can_delete",
1985 "params" : [
1986 {
1987 "api_version" : %API_VER%,
1988 }
1989 ]
1990 })",
1991 },
1992 {
1993 "can_delete: ledger index.",
1994 __LINE__,
1995 {
1996 "can_delete",
1997 "4294967295",
1998 },
2000 R"({
2001 "method" : "can_delete",
2002 "params" : [
2003 {
2004 "api_version" : %API_VER%,
2005 "can_delete" : 4294967295
2006 }
2007 ]
2008 })",
2009 },
2010 {
2011 "can_delete: ledger hash.",
2012 __LINE__,
2013 {
2014 "can_delete",
2015 "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210",
2016 },
2018 R"({
2019 "method" : "can_delete",
2020 "params" : [
2021 {
2022 "api_version" : %API_VER%,
2023 "can_delete" : "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210"
2024 }
2025 ]
2026 })",
2027 },
2028 {
2029 "can_delete: always.",
2030 __LINE__,
2031 {
2032 "can_delete",
2033 "always",
2034 },
2036 R"({
2037 "method" : "can_delete",
2038 "params" : [
2039 {
2040 "api_version" : %API_VER%,
2041 "can_delete" : "always"
2042 }
2043 ]
2044 })",
2045 },
2046 {
2047 "can_delete: never.",
2048 __LINE__,
2049 {
2050 "can_delete",
2051 "never",
2052 },
2054 R"({
2055 "method" : "can_delete",
2056 "params" : [
2057 {
2058 "api_version" : %API_VER%,
2059 "can_delete" : "never"
2060 }
2061 ]
2062 })",
2063 },
2064 {
2065 "can_delete: now.",
2066 __LINE__,
2067 {
2068 "can_delete",
2069 "now",
2070 },
2072 R"({
2073 "method" : "can_delete",
2074 "params" : [
2075 {
2076 "api_version" : %API_VER%,
2077 "can_delete" : "now"
2078 }
2079 ]
2080 })",
2081 },
2082 {
2083 "can_delete: too many arguments.",
2084 __LINE__,
2085 {"can_delete", "always", "never"},
2087 R"({
2088 "method" : "can_delete",
2089 "params" : [
2090 {
2091 "error" : "badSyntax",
2092 "error_code" : 1,
2093 "error_message" : "Syntax error."
2094 }
2095 ]
2096 })",
2097 },
2098 {
2099 "can_delete: invalid argument.",
2100 __LINE__,
2101 {"can_delete", "invalid"},
2103 R"({
2104 "method" : "can_delete",
2105 "params" : [
2106 {
2107 "api_version" : %API_VER%,
2108 "can_delete" : "invalid"
2109 }
2110 ]
2111 })",
2112 },
2113 {
2114 // Note: this should return an error but not throw.
2115 "can_delete: ledger index > 32 bits.",
2116 __LINE__,
2117 {
2118 "can_delete",
2119 "4294967296",
2120 },
2122 R"()",
2123 },
2124 {
2125 // Note: this really shouldn't throw since it's a legitimate ledger hash.
2126 "can_delete: ledger hash with no alphas.",
2127 __LINE__,
2128 {
2129 "can_delete",
2130 "0123456701234567012345670123456701234567012345670123456701234567",
2131 },
2133 R"()",
2134 },
2135
2136 // channel_authorize
2137 // -----------------------------------------------------------
2138 {
2139 "channel_authorize: minimal.",
2140 __LINE__,
2141 {
2142 "channel_authorize",
2143 "secret_can_be_anything",
2144 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2145 "18446744073709551615",
2146 },
2148 R"({
2149 "method" : "channel_authorize",
2150 "params" : [
2151 {
2152 "api_version" : %API_VER%,
2153 "amount" : "18446744073709551615",
2154 "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2155 "secret" : "secret_can_be_anything"
2156 }
2157 ]
2158 })",
2159 },
2160 {
2161 "channel_authorize: too few arguments.",
2162 __LINE__,
2163 {
2164 "channel_authorize",
2165 "secret_can_be_anything",
2166 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2167 },
2169 R"({
2170 "method" : "channel_authorize",
2171 "params" : [
2172 {
2173 "error" : "badSyntax",
2174 "error_code" : 1,
2175 "error_message" : "Syntax error."
2176 }
2177 ]
2178 })",
2179 },
2180 {
2181 "channel_authorize: too many arguments.",
2182 __LINE__,
2183 {
2184 "channel_authorize",
2185 "secp256k1",
2186 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2187 "2000",
2188 "whatever",
2189 "whenever",
2190 },
2192 R"({
2193 "method" : "channel_authorize",
2194 "params" : [
2195 {
2196 "error" : "badSyntax",
2197 "error_code" : 1,
2198 "error_message" : "Syntax error."
2199 }
2200 ]
2201 })",
2202 },
2203 {
2204 "channel_authorize: bad key type.",
2205 __LINE__,
2206 {
2207 "channel_authorize",
2208 "secp257k1",
2209 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2210 "2000",
2211 "whatever",
2212 },
2214 R"({
2215 "method" : "channel_authorize",
2216 "params" : [
2217 {
2218 "error" : "badKeyType",
2219 "error_code" : 1,
2220 "error_message" : "Bad key type."
2221 }
2222 ]
2223 })",
2224 },
2225 {
2226 "channel_authorize: channel_id too short.",
2227 __LINE__,
2228 {
2229 "channel_authorize",
2230 "secret_can_be_anything",
2231 "123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2232 "2000",
2233 },
2235 R"({
2236 "method" : "channel_authorize",
2237 "params" : [
2238 {
2239 "error" : "channelMalformed",
2240 "error_code" : 43,
2241 "error_message" : "Payment channel is malformed."
2242 }
2243 ]
2244 })",
2245 },
2246 {
2247 "channel_authorize: channel_id too long.",
2248 __LINE__,
2249 {
2250 "channel_authorize",
2251 "secret_can_be_anything",
2252 "10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2253 "2000",
2254 },
2256 R"({
2257 "method" : "channel_authorize",
2258 "params" : [
2259 {
2260 "error" : "channelMalformed",
2261 "error_code" : 43,
2262 "error_message" : "Payment channel is malformed."
2263 }
2264 ]
2265 })",
2266 },
2267 {
2268 "channel_authorize: channel_id not hex.",
2269 __LINE__,
2270 {
2271 "channel_authorize",
2272 "secret_can_be_anything",
2273 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEZ",
2274 "2000",
2275 },
2277 R"({
2278 "method" : "channel_authorize",
2279 "params" : [
2280 {
2281 "error" : "channelMalformed",
2282 "error_code" : 43,
2283 "error_message" : "Payment channel is malformed."
2284 }
2285 ]
2286 })",
2287 },
2288 {
2289 "channel_authorize: negative amount.",
2290 __LINE__,
2291 {
2292 "channel_authorize",
2293 "secret_can_be_anything",
2294 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2295 "-1",
2296 },
2298 R"({
2299 "method" : "channel_authorize",
2300 "params" : [
2301 {
2302 "error" : "channelAmtMalformed",
2303 "error_code" : 44,
2304 "error_message" : "Payment channel amount is malformed."
2305 }
2306 ]
2307 })",
2308 },
2309 {
2310 "channel_authorize: amount > 64 bits.",
2311 __LINE__,
2312 {
2313 "channel_authorize",
2314 "secret_can_be_anything",
2315 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2316 "18446744073709551616",
2317 },
2319 R"({
2320 "method" : "channel_authorize",
2321 "params" : [
2322 {
2323 "error" : "channelAmtMalformed",
2324 "error_code" : 44,
2325 "error_message" : "Payment channel amount is malformed."
2326 }
2327 ]
2328 })",
2329 },
2330
2331 // channel_verify
2332 // --------------------------------------------------------------
2333 {
2334 "channel_verify: public key.",
2335 __LINE__,
2336 {
2337 "channel_verify",
2338 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2339 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2340 "0",
2341 "DEADBEEF",
2342 },
2344 R"({
2345 "method" : "channel_verify",
2346 "params" : [
2347 {
2348 "api_version" : %API_VER%,
2349 "amount" : "0",
2350 "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2351 "public_key" : "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2352 "signature" : "DEADBEEF"
2353 }
2354 ]
2355 })",
2356 },
2357 {
2358 "channel_verify: public key hex.",
2359 __LINE__,
2360 {
2361 "channel_verify",
2362 "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2363 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2364 "18446744073709551615",
2365 "DEADBEEF",
2366 },
2368 R"({
2369 "method" : "channel_verify",
2370 "params" : [
2371 {
2372 "api_version" : %API_VER%,
2373 "amount" : "18446744073709551615",
2374 "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2375 "public_key" : "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2376 "signature" : "DEADBEEF"
2377 }
2378 ]
2379 })",
2380 },
2381 {
2382 "channel_verify: too few arguments.",
2383 __LINE__,
2384 {
2385 "channel_verify",
2386 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2387 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2388 },
2390 R"({
2391 "method" : "channel_verify",
2392 "params" : [
2393 {
2394 "error" : "badSyntax",
2395 "error_code" : 1,
2396 "error_message" : "Syntax error."
2397 }
2398 ]
2399 })",
2400 },
2401 {
2402 "channel_verify: too many arguments.",
2403 __LINE__,
2404 {
2405 "channel_verify",
2406 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2407 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2408 "2000",
2409 "DEADBEEF",
2410 "Whatever",
2411 },
2413 R"({
2414 "method" : "channel_verify",
2415 "params" : [
2416 {
2417 "error" : "badSyntax",
2418 "error_code" : 1,
2419 "error_message" : "Syntax error."
2420 }
2421 ]
2422 })",
2423 },
2424 {
2425 "channel_verify: malformed public key.",
2426 __LINE__,
2427 {
2428 "channel_verify",
2429 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9GoV",
2430 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2431 "2000",
2432 "DEADBEEF",
2433 },
2435 R"({
2436 "method" : "channel_verify",
2437 "params" : [
2438 {
2439 "error" : "publicMalformed",
2440 "error_code" : 60,
2441 "error_message" : "Public key is malformed."
2442 }
2443 ]
2444 })",
2445 },
2446 {
2447 "channel_verify: malformed hex public key.",
2448 __LINE__,
2449 {
2450 "channel_verify",
2451 "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F",
2452 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2453 "2000",
2454 "DEADBEEF",
2455 },
2457 R"({
2458 "method" : "channel_verify",
2459 "params" : [
2460 {
2461 "error" : "publicMalformed",
2462 "error_code" : 60,
2463 "error_message" : "Public key is malformed."
2464 }
2465 ]
2466 })",
2467 },
2468 {
2469 "channel_verify: invalid channel id.",
2470 __LINE__,
2471 {
2472 "channel_verify",
2473 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2474 "10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2475 "2000",
2476 "DEADBEEF",
2477 },
2479 R"({
2480 "method" : "channel_verify",
2481 "params" : [
2482 {
2483 "error" : "channelMalformed",
2484 "error_code" : 43,
2485 "error_message" : "Payment channel is malformed."
2486 }
2487 ]
2488 })",
2489 },
2490 {
2491 "channel_verify: short channel id.",
2492 __LINE__,
2493 {
2494 "channel_verify",
2495 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2496 "123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2497 "2000",
2498 "DEADBEEF",
2499 },
2501 R"({
2502 "method" : "channel_verify",
2503 "params" : [
2504 {
2505 "error" : "channelMalformed",
2506 "error_code" : 43,
2507 "error_message" : "Payment channel is malformed."
2508 }
2509 ]
2510 })",
2511 },
2512 {
2513 "channel_verify: amount too small.",
2514 __LINE__,
2515 {
2516 "channel_verify",
2517 "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2518 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2519 "-1",
2520 "DEADBEEF",
2521 },
2523 R"({
2524 "method" : "channel_verify",
2525 "params" : [
2526 {
2527 "error" : "channelAmtMalformed",
2528 "error_code" : 44,
2529 "error_message" : "Payment channel amount is malformed."
2530 }
2531 ]
2532 })",
2533 },
2534 {
2535 "channel_verify: amount too large.",
2536 __LINE__,
2537 {
2538 "channel_verify",
2539 "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2540 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2541 "18446744073709551616",
2542 "DEADBEEF",
2543 },
2545 R"({
2546 "method" : "channel_verify",
2547 "params" : [
2548 {
2549 "error" : "channelAmtMalformed",
2550 "error_code" : 44,
2551 "error_message" : "Payment channel amount is malformed."
2552 }
2553 ]
2554 })",
2555 },
2556 {
2557 "channel_verify: non-hex signature.",
2558 __LINE__,
2559 {
2560 "channel_verify",
2561 "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2562 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2563 "40000000",
2564 "ThisIsNotHexadecimal",
2565 },
2567 R"({
2568 "method" : "channel_verify",
2569 "params" : [
2570 {
2571 "api_version" : %API_VER%,
2572 "amount" : "40000000",
2573 "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2574 "public_key" : "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2575 "signature" : "ThisIsNotHexadecimal"
2576 }
2577 ]
2578 })",
2579 },
2580
2581 // connect
2582 // ---------------------------------------------------------------------
2583 {
2584 "connect: minimal.",
2585 __LINE__,
2586 {
2587 "connect",
2588 "ThereIsNoCheckingOnTheIPFormat",
2589 },
2591 R"({
2592 "method" : "connect",
2593 "params" : [
2594 {
2595 "api_version" : %API_VER%,
2596 "ip" : "ThereIsNoCheckingOnTheIPFormat"
2597 }
2598 ]
2599 })",
2600 },
2601 {
2602 "connect: ip and port.",
2603 __LINE__,
2604 {"connect", "ThereIsNoCheckingOnTheIPFormat", "6561"},
2606 R"({
2607 "method" : "connect",
2608 "params" : [
2609 {
2610 "api_version" : %API_VER%,
2611 "ip" : "ThereIsNoCheckingOnTheIPFormat",
2612 "port" : 6561
2613 }
2614 ]
2615 })",
2616 },
2617 {
2618 "connect: too few arguments.",
2619 __LINE__,
2620 {
2621 "connect",
2622 },
2624 R"({
2625 "method" : "connect",
2626 "params" : [
2627 {
2628 "error" : "badSyntax",
2629 "error_code" : 1,
2630 "error_message" : "Syntax error."
2631 }
2632 ]
2633 })",
2634 },
2635 {
2636 "connect: too many arguments.",
2637 __LINE__,
2638 {"connect", "ThereIsNoCheckingOnTheIPFormat", "6561", "extra"},
2640 R"({
2641 "method" : "connect",
2642 "params" : [
2643 {
2644 "error" : "badSyntax",
2645 "error_code" : 1,
2646 "error_message" : "Syntax error."
2647 }
2648 ]
2649 })",
2650 },
2651 {
2652 // Note: this should return an error but not throw.
2653 "connect: port too small.",
2654 __LINE__,
2655 {
2656 "connect",
2657 "ThereIsNoCheckingOnTheIPFormat",
2658 "-1",
2659 },
2661 R"()",
2662 },
2663 {
2664 // Note: this should return an error but not throw.
2665 "connect: port too large.",
2666 __LINE__,
2667 {
2668 "connect",
2669 "ThereIsNoCheckingOnTheIPFormat",
2670 "4294967296",
2671 },
2673 R"()",
2674 },
2675
2676 // consensus_info
2677 // --------------------------------------------------------------
2678 {
2679 "consensus_info: minimal.",
2680 __LINE__,
2681 {
2682 "consensus_info",
2683 },
2685 R"({
2686 "method" : "consensus_info",
2687 "params" : [
2688 {
2689 "api_version" : %API_VER%
2690 }
2691 ]
2692 })",
2693 },
2694 {
2695 "consensus_info: too many arguments.",
2696 __LINE__,
2697 {"consensus_info", "whatever"},
2699 R"({
2700 "method" : "consensus_info",
2701 "params" : [
2702 {
2703 "error" : "badSyntax",
2704 "error_code" : 1,
2705 "error_message" : "Syntax error."
2706 }
2707 ]
2708 })",
2709 },
2710
2711 // deposit_authorized
2712 // ----------------------------------------------------------
2713 {
2714 "deposit_authorized: minimal.",
2715 __LINE__,
2716 {
2717 "deposit_authorized",
2718 "source_account_NotValidated",
2719 "destination_account_NotValidated",
2720 },
2722 R"({
2723 "method" : "deposit_authorized",
2724 "params" : [
2725 {
2726 "api_version" : %API_VER%,
2727 "destination_account" : "destination_account_NotValidated",
2728 "source_account" : "source_account_NotValidated"
2729 }
2730 ]
2731 })",
2732 },
2733 {
2734 "deposit_authorized: with text ledger index.",
2735 __LINE__,
2736 {
2737 "deposit_authorized",
2738 "source_account_NotValidated",
2739 "destination_account_NotValidated",
2740 "validated",
2741 },
2743 R"({
2744 "method" : "deposit_authorized",
2745 "params" : [
2746 {
2747 "api_version" : %API_VER%,
2748 "destination_account" : "destination_account_NotValidated",
2749 "ledger_index" : "validated",
2750 "source_account" : "source_account_NotValidated"
2751 }
2752 ]
2753 })",
2754 },
2755 {
2756 "deposit_authorized: with ledger index.",
2757 __LINE__,
2758 {
2759 "deposit_authorized",
2760 "source_account_NotValidated",
2761 "destination_account_NotValidated",
2762 "4294967295",
2763 "cred1",
2764 "cred2",
2765 "cred3",
2766 "cred4",
2767 "cred5",
2768 "cred6",
2769 "cred7",
2770 "cred8",
2771 },
2773 R"({
2774 "method" : "deposit_authorized",
2775 "params" : [
2776 {
2777 "api_version" : %API_VER%,
2778 "destination_account" : "destination_account_NotValidated",
2779 "ledger_index" : 4294967295,
2780 "source_account" : "source_account_NotValidated",
2781 "credentials": ["cred1", "cred2", "cred3", "cred4", "cred5", "cred6", "cred7", "cred8"]
2782 }
2783 ]
2784 })",
2785 },
2786 {
2787 "deposit_authorized: with ledger hash.",
2788 __LINE__,
2789 {
2790 "deposit_authorized",
2791 "source_account_NotValidated",
2792 "destination_account_NotValidated",
2793 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
2794 },
2796 R"({
2797 "method" : "deposit_authorized",
2798 "params" : [
2799 {
2800 "api_version" : %API_VER%,
2801 "destination_account" : "destination_account_NotValidated",
2802 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
2803 "source_account" : "source_account_NotValidated"
2804 }
2805 ]
2806 })",
2807 },
2808 {
2809 "deposit_authorized: too few arguments.",
2810 __LINE__,
2811 {
2812 "deposit_authorized",
2813 "source_account_NotValidated",
2814 },
2816 R"({
2817 "method" : "deposit_authorized",
2818 "params" : [
2819 {
2820 "error" : "badSyntax",
2821 "error_code" : 1,
2822 "error_message" : "Syntax error."
2823 }
2824 ]
2825 })",
2826 },
2827 {
2828 "deposit_authorized: too many arguments.",
2829 __LINE__,
2830 {
2831 "deposit_authorized",
2832 "source_account_NotValidated",
2833 "destination_account_NotValidated",
2834 "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
2835 "cred1",
2836 "cred2",
2837 "cred3",
2838 "cred4",
2839 "cred5",
2840 "cred6",
2841 "cred7",
2842 "cred8",
2843 "too_much",
2844 },
2846 R"({
2847 "method" : "deposit_authorized",
2848 "params" : [
2849 {
2850 "error" : "badSyntax",
2851 "error_code" : 1,
2852 "error_message" : "Syntax error."
2853 }
2854 ]
2855 })",
2856 },
2857 {
2858 "deposit_authorized: invalid ledger selection.",
2859 __LINE__,
2860 {
2861 "deposit_authorized",
2862 "source_account_NotValidated",
2863 "destination_account_NotValidated",
2864 "NotALedger",
2865 },
2867 R"({
2868 "method" : "deposit_authorized",
2869 "params" : [
2870 {
2871 "api_version" : %API_VER%,
2872 "destination_account" : "destination_account_NotValidated",
2873 "ledger_index" : 0,
2874 "source_account" : "source_account_NotValidated"
2875 }
2876 ]
2877 })",
2878 },
2879
2880 // feature
2881 // ---------------------------------------------------------------------
2882 {
2883 "feature: minimal.",
2884 __LINE__,
2885 {
2886 "feature",
2887 },
2889 R"({
2890 "method" : "feature",
2891 "params" : [
2892 {
2893 "api_version" : %API_VER%,
2894 }
2895 ]
2896 })",
2897 },
2898 {
2899 "feature: with name.",
2900 __LINE__,
2901 {"feature", "featureNameOrHexIsNotValidated"},
2903 R"({
2904 "method" : "feature",
2905 "params" : [
2906 {
2907 "api_version" : %API_VER%,
2908 "feature" : "featureNameOrHexIsNotValidated"
2909 }
2910 ]
2911 })",
2912 },
2913 {
2914 "feature: accept.",
2915 __LINE__,
2916 {
2917 "feature",
2918 "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA98"
2919 "76543210",
2920 "accept",
2921 },
2923 R"({
2924 "method" : "feature",
2925 "params" : [
2926 {
2927 "api_version" : %API_VER%,
2928 "feature" : "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210",
2929 "vetoed" : false
2930 }
2931 ]
2932 })",
2933 },
2934 {
2935 "feature: reject.",
2936 __LINE__,
2937 {"feature", "0", "reject"},
2939 R"({
2940 "method" : "feature",
2941 "params" : [
2942 {
2943 "api_version" : %API_VER%,
2944 "feature" : "0",
2945 "vetoed" : true
2946 }
2947 ]
2948 })",
2949 },
2950 {
2951 "feature: too many arguments.",
2952 __LINE__,
2953 {"feature", "featureNameOrHexIsNotValidated", "accept", "anotherArg"},
2955 R"({
2956 "method" : "feature",
2957 "params" : [
2958 {
2959 "error" : "badSyntax",
2960 "error_code" : 1,
2961 "error_message" : "Syntax error."
2962 }
2963 ]
2964 })",
2965 },
2966 {
2967 "feature: neither accept nor reject.",
2968 __LINE__,
2969 {
2970 "feature",
2971 "featureNameOrHexIsNotValidated",
2972 "veto",
2973 },
2975 R"({
2976 "method" : "feature",
2977 "params" : [
2978 {
2979 "error" : "invalidParams",
2980 "error_code" : 31,
2981 "error_message" : "Invalid parameters."
2982 }
2983 ]
2984 })",
2985 },
2986
2987 // fetch_info
2988 // ------------------------------------------------------------------
2989 {
2990 "fetch_info: minimal.",
2991 __LINE__,
2992 {
2993 "fetch_info",
2994 },
2996 R"({
2997 "method" : "fetch_info",
2998 "params" : [
2999 {
3000 "api_version" : %API_VER%,
3001 }
3002 ]
3003 })",
3004 },
3005 {
3006 "fetch_info: clear.",
3007 __LINE__,
3008 {"fetch_info", "clear"},
3010 R"({
3011 "method" : "fetch_info",
3012 "params" : [
3013 {
3014 "api_version" : %API_VER%,
3015 "clear" : true
3016 }
3017 ]
3018 })",
3019 },
3020 {
3021 "fetch_info: too many arguments.",
3022 __LINE__,
3023 {"fetch_info", "clear", "other"},
3025 R"({
3026 "method" : "fetch_info",
3027 "params" : [
3028 {
3029 "error" : "badSyntax",
3030 "error_code" : 1,
3031 "error_message" : "Syntax error."
3032 }
3033 ]
3034 })",
3035 },
3036 {
3037 "fetch_info: other trailing argument.",
3038 __LINE__,
3039 {"fetch_info", "too"},
3041 R"({
3042 "method" : "fetch_info",
3043 "params" : [
3044 {
3045 "api_version" : %API_VER%,
3046 "too" : true
3047 }
3048 ]
3049 })",
3050 },
3051
3052 // gateway_balances
3053 // ------------------------------------------------------------
3054 {
3055 "gateway_balances: minimal.",
3056 __LINE__,
3057 {"gateway_balances", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
3059 R"({
3060 "method" : "gateway_balances",
3061 "params" : [
3062 {
3063 "api_version" : %API_VER%,
3064 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3065 }
3066 ]
3067 })",
3068 },
3069 {
3070 "gateway_balances: with ledger index.",
3071 __LINE__,
3072 {"gateway_balances", "890765", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
3074 R"({
3075 "method" : "gateway_balances",
3076 "params" : [
3077 {
3078 "api_version" : %API_VER%,
3079 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3080 "ledger_index" : "890765"
3081 }
3082 ]
3083 })",
3084 },
3085 {
3086 "gateway_balances: with text ledger index.",
3087 __LINE__,
3088 {"gateway_balances", "current", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
3090 R"({
3091 "method" : "gateway_balances",
3092 "params" : [
3093 {
3094 "api_version" : %API_VER%,
3095 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3096 "ledger_index" : "current"
3097 }
3098 ]
3099 })",
3100 },
3101 {
3102 "gateway_balances: with 64 character ledger hash.",
3103 __LINE__,
3104 {
3105 "gateway_balances",
3106 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
3107 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3108 },
3110 R"({
3111 "method" : "gateway_balances",
3112 "params" : [
3113 {
3114 "api_version" : %API_VER%,
3115 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3116 "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
3117 }
3118 ]
3119 })",
3120 },
3121 {
3122 "gateway_balances: 1 hotwallet.",
3123 __LINE__,
3124 {"gateway_balances", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "hotwallet_is_not_validated"},
3126 R"({
3127 "method" : "gateway_balances",
3128 "params" : [
3129 {
3130 "api_version" : %API_VER%,
3131 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3132 "hotwallet" : [ "hotwallet_is_not_validated" ]
3133 }
3134 ]
3135 })",
3136 },
3137 {
3138 "gateway_balances: 3 hotwallets.",
3139 __LINE__,
3140 {
3141 "gateway_balances",
3142 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
3143 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3144 "hotwallet_is_not_validated_1",
3145 "hotwallet_is_not_validated_2",
3146 "hotwallet_is_not_validated_3",
3147 },
3149 R"({
3150 "method" : "gateway_balances",
3151 "params" : [
3152 {
3153 "api_version" : %API_VER%,
3154 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3155 "hotwallet" : [
3156 "hotwallet_is_not_validated_1",
3157 "hotwallet_is_not_validated_2",
3158 "hotwallet_is_not_validated_3"
3159 ],
3160 "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
3161 }
3162 ]
3163 })",
3164 },
3165 {
3166 "gateway_balances: too few arguments.",
3167 __LINE__,
3168 {
3169 "gateway_balances",
3170 },
3172 R"({
3173 "method" : "gateway_balances",
3174 "params" : [
3175 {
3176 "error" : "badSyntax",
3177 "error_code" : 1,
3178 "error_message" : "Syntax error."
3179 }
3180 ]
3181 })",
3182 },
3183 {
3184 "gateway_balances: empty first argument.",
3185 __LINE__,
3186 {"gateway_balances", ""},
3188 R"({
3189 "method" : "gateway_balances",
3190 "params" : [
3191 {
3192 "error" : "invalidParams",
3193 "error_code" : 31,
3194 "error_message" : "Invalid first parameter"
3195 }
3196 ]
3197 })",
3198 },
3199 {
3200 "gateway_balances: with ledger index but no gateway.",
3201 __LINE__,
3202 {
3203 "gateway_balances",
3204 "890765",
3205 },
3207 R"({
3208 "method" : "gateway_balances",
3209 "params" : [
3210 {
3211 "error" : "invalidParams",
3212 "error_code" : 31,
3213 "error_message" : "Invalid hotwallet"
3214 }
3215 ]
3216 })",
3217 },
3218 {
3219 "gateway_balances: with text ledger index but no gateway.",
3220 __LINE__,
3221 {
3222 "gateway_balances",
3223 "current",
3224 },
3226 R"({
3227 "method" : "gateway_balances",
3228 "params" : [
3229 {
3230 "error" : "invalidParams",
3231 "error_code" : 31,
3232 "error_message" : "Invalid hotwallet"
3233 }
3234 ]
3235 })",
3236 },
3237 {
3238 "gateway_balances: with 64 character ledger hash but no gateway.",
3239 __LINE__,
3240 {
3241 "gateway_balances",
3242 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
3243 },
3245 R"({
3246 "method" : "gateway_balances",
3247 "params" : [
3248 {
3249 "error" : "invalidParams",
3250 "error_code" : 31,
3251 "error_message" : "Invalid hotwallet"
3252 }
3253 ]
3254 })",
3255 },
3256
3257 // get_counts
3258 // ------------------------------------------------------------------
3259 {
3260 "get_counts: minimal.",
3261 __LINE__,
3262 {
3263 "get_counts",
3264 },
3266 R"({
3267 "method" : "get_counts",
3268 "params" : [
3269 {
3270 "api_version" : %API_VER%,
3271 }
3272 ]
3273 })",
3274 },
3275 {
3276 "get_counts: with maximum count.",
3277 __LINE__,
3278 {"get_counts", "100"},
3280 R"({
3281 "method" : "get_counts",
3282 "params" : [
3283 {
3284 "api_version" : %API_VER%,
3285 "min_count" : 100
3286 }
3287 ]
3288 })",
3289 },
3290 {
3291 "get_counts: too many arguments.",
3292 __LINE__,
3293 {"get_counts", "100", "whatever"},
3295 R"({
3296 "method" : "get_counts",
3297 "params" : [
3298 {
3299 "error" : "badSyntax",
3300 "error_code" : 1,
3301 "error_message" : "Syntax error."
3302 }
3303 ]
3304 })",
3305 },
3306 {
3307 "get_counts: count too small.",
3308 __LINE__,
3309 {
3310 "get_counts",
3311 "-1",
3312 },
3314 R"()",
3315 },
3316 {
3317 "get_counts: count too large.",
3318 __LINE__,
3319 {"get_counts", "4294967296"},
3321 R"()",
3322 },
3323
3324 // json
3325 // ------------------------------------------------------------------------
3326 {
3327 "json: minimal.",
3328 __LINE__,
3329 {
3330 "json",
3331 "command",
3332 R"({"json_argument":true})",
3333 },
3335 R"({
3336 "method" : "command",
3337 "params" : [
3338 {
3339 "api_version" : %API_VER%,
3340 "json_argument" : true,
3341 "method" : "command"
3342 }
3343 ]
3344 })",
3345 },
3346 {
3347 "json: null object.",
3348 __LINE__,
3349 {
3350 "json",
3351 "command",
3352 R"({})",
3353 },
3355 R"({
3356 "method" : "command",
3357 "params" : [
3358 {
3359 "api_version" : %API_VER%,
3360 "method" : "command"
3361 }
3362 ]
3363 })",
3364 },
3365 {
3366 "json: too few arguments.",
3367 __LINE__,
3368 {"json", "command"},
3370 R"({
3371 "method" : "json",
3372 "params" : [
3373 {
3374 "error" : "badSyntax",
3375 "error_code" : 1,
3376 "error_message" : "Syntax error."
3377 }
3378 ]
3379 })",
3380 },
3381 {
3382 "json: too many arguments.",
3383 __LINE__,
3384 {"json", "command", R"({"json_argument":true})", "extra"},
3386 R"({
3387 "method" : "json",
3388 "params" : [
3389 {
3390 "error" : "badSyntax",
3391 "error_code" : 1,
3392 "error_message" : "Syntax error."
3393 }
3394 ]
3395 })",
3396 },
3397 {
3398 "json: array, not object.",
3399 __LINE__,
3400 {
3401 "json",
3402 "command",
3403 R"(["arg1","arg2"])",
3404 },
3406 R"({
3407 "method" : "json",
3408 "params" : [
3409 {
3410 "error" : "invalidParams",
3411 "error_code" : 31,
3412 "error_message" : "Invalid parameters."
3413 }
3414 ]
3415 })",
3416 },
3417 {
3418 "json: invalid json (note closing comma).",
3419 __LINE__,
3420 {
3421 "json",
3422 "command",
3423 R"({"json_argument":true,})",
3424 },
3426 R"({
3427 "method" : "json",
3428 "params" : [
3429 {
3430 "error" : "invalidParams",
3431 "error_code" : 31,
3432 "error_message" : "Invalid parameters."
3433 }
3434 ]
3435 })",
3436 },
3437
3438 // json2
3439 // -----------------------------------------------------------------------
3440 {
3441 "json2: minimal object.",
3442 __LINE__,
3443 {
3444 "json2",
3445 R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1"})",
3446 },
3448 R"({
3449 "id" : "A1",
3450 "jsonrpc" : "2.0",
3451 "method" : "call_1",
3452 "params" : [
3453 {
3454 "api_version" : %API_VER%,
3455 "id" : "A1",
3456 "jsonrpc" : "2.0",
3457 "method" : "call_1",
3458 "ripplerpc" : "2.0"
3459 }
3460 ],
3461 "ripplerpc" : "2.0"
3462 })",
3463 },
3464 {
3465 "json2: object with nested params.",
3466 __LINE__,
3467 {
3468 "json2",
3469 R"({
3470 "jsonrpc" : "2.0",
3471 "ripplerpc" : "2.0",
3472 "id" : "A1",
3473 "method" : "call_1",
3474 "params" : [{"inner_arg" : "yup"}]
3475 })",
3476 },
3478 R"({
3479 "id" : "A1",
3480 "jsonrpc" : "2.0",
3481 "method" : "call_1",
3482 "params" : [
3483 {
3484 "api_version" : %API_VER%,
3485 "0" : {
3486 "inner_arg" : "yup"
3487 },
3488 "id" : "A1",
3489 "jsonrpc" : "2.0",
3490 "method" : "call_1",
3491 "ripplerpc" : "2.0"
3492 }
3493 ],
3494 "ripplerpc" : "2.0"
3495 })",
3496 },
3497 {
3498 "json2: minimal array.",
3499 __LINE__,
3500 {
3501 "json2",
3502 R"([{"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1"}])",
3503 },
3505 R"({
3506 "method" : "json2",
3507 "params" : [
3508 [
3509 {
3510 "api_version" : %API_VER%,
3511 "id" : "A1",
3512 "jsonrpc" : "2.0",
3513 "method" : "call_1",
3514 "ripplerpc" : "2.0"
3515 }
3516 ]
3517 ]
3518 })",
3519 },
3520 {
3521 "json2: array with object with nested params.",
3522 __LINE__,
3523 {
3524 "json2",
3525 R"([
3526 {"jsonrpc":"2.0",
3527 "ripplerpc":"2.0",
3528 "id":"A1",
3529 "method":"call_1",
3530 "params" : [{"inner_arg" : "yup"}]}
3531 ])",
3532 },
3534 R"({
3535 "method" : "json2",
3536 "params" : [
3537 [
3538 {
3539 "api_version" : %API_VER%,
3540 "0" : {
3541 "inner_arg" : "yup"
3542 },
3543 "id" : "A1",
3544 "jsonrpc" : "2.0",
3545 "method" : "call_1",
3546 "ripplerpc" : "2.0"
3547 }
3548 ]
3549 ]})",
3550 },
3551 {
3552 "json2: too few arguments.",
3553 __LINE__,
3554 {
3555 "json2",
3556 },
3558 R"({
3559 "method" : "json2",
3560 "params" : [
3561 {
3562 "error" : "badSyntax",
3563 "error_code" : 1,
3564 "error_message" : "Syntax error."
3565 }
3566 ]
3567 })",
3568 },
3569 {
3570 "json2: too many arguments.",
3571 __LINE__,
3572 {"json2", R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_this"})", "extra"},
3574 R"({
3575 "method" : "json2",
3576 "params" : [
3577 {
3578 "error" : "badSyntax",
3579 "error_code" : 1,
3580 "error_message" : "Syntax error."
3581 }
3582 ]
3583 })",
3584 },
3585 {
3586 "json2: malformed json (note extra comma).",
3587 __LINE__,
3588 {
3589 "json2",
3590 R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1",})",
3591 },
3593 R"({
3594 "id" : "A1",
3595 "jsonrpc" : "2.0",
3596 "method" : "json2",
3597 "params" : [
3598 {
3599 "error" : "invalidParams",
3600 "error_code" : 31,
3601 "error_message" : "Invalid parameters.",
3602 "id" : "A1",
3603 "jsonrpc" : "2.0",
3604 "ripplerpc" : "2.0"
3605 }
3606 ],
3607 "ripplerpc" : "2.0"
3608 })",
3609 },
3610 {
3611 "json2: omit jsonrpc.",
3612 __LINE__,
3613 {
3614 "json2",
3615 R"({"ripplerpc":"2.0","id":"A1","method":"call_1"})",
3616 },
3618 R"({
3619 "id" : "A1",
3620 "method" : "json2",
3621 "params" : [
3622 {
3623 "error" : "invalidParams",
3624 "error_code" : 31,
3625 "error_message" : "Invalid parameters.",
3626 "id" : "A1",
3627 "ripplerpc" : "2.0"
3628 }
3629 ],
3630 "ripplerpc" : "2.0"
3631 })",
3632 },
3633 {
3634 "json2: wrong jsonrpc version.",
3635 __LINE__,
3636 {
3637 "json2",
3638 R"({"jsonrpc":"2.1","ripplerpc":"2.0","id":"A1","method":"call_1"})",
3639 },
3641 R"({
3642 "id" : "A1",
3643 "jsonrpc" : "2.1",
3644 "method" : "json2",
3645 "params" : [
3646 {
3647 "error" : "invalidParams",
3648 "error_code" : 31,
3649 "error_message" : "Invalid parameters.",
3650 "id" : "A1",
3651 "jsonrpc" : "2.1",
3652 "ripplerpc" : "2.0"
3653 }
3654 ],
3655 "ripplerpc" : "2.0"
3656 })",
3657 },
3658 {
3659 "json2: omit ripplerpc.",
3660 __LINE__,
3661 {
3662 "json2",
3663 R"({"jsonrpc":"2.0","id":"A1","method":"call_1"})",
3664 },
3666 R"({
3667 "id" : "A1",
3668 "jsonrpc" : "2.0",
3669 "method" : "json2",
3670 "params" : [
3671 {
3672 "error" : "invalidParams",
3673 "error_code" : 31,
3674 "error_message" : "Invalid parameters.",
3675 "id" : "A1",
3676 "jsonrpc" : "2.0"
3677 }
3678 ]
3679 })",
3680 },
3681 {
3682 "json2: wrong ripplerpc version.",
3683 __LINE__,
3684 {
3685 "json2",
3686 R"({"jsonrpc":"2.0","ripplerpc":"2.00","id":"A1","method":"call_1"})",
3687 },
3689 R"({
3690 "id" : "A1",
3691 "jsonrpc" : "2.0",
3692 "method" : "json2",
3693 "params" : [
3694 {
3695 "error" : "invalidParams",
3696 "error_code" : 31,
3697 "error_message" : "Invalid parameters.",
3698 "id" : "A1",
3699 "jsonrpc" : "2.0",
3700 "ripplerpc" : "2.00"
3701 }
3702 ],
3703 "ripplerpc" : "2.00"
3704 })",
3705 },
3706 {
3707 "json2: omit id.",
3708 __LINE__,
3709 {
3710 "json2",
3711 R"({"jsonrpc":"2.0","ripplerpc":"2.0","method":"call_1"})",
3712 },
3714 R"({
3715 "jsonrpc" : "2.0",
3716 "method" : "json2",
3717 "params" : [
3718 {
3719 "error" : "invalidParams",
3720 "error_code" : 31,
3721 "error_message" : "Invalid parameters.",
3722 "jsonrpc" : "2.0",
3723 "ripplerpc" : "2.0"
3724 }
3725 ],
3726 "ripplerpc" : "2.0"
3727 })",
3728 },
3729 {
3730 "json2: omit method.",
3731 __LINE__,
3732 {
3733 "json2",
3734 R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1"})",
3735 },
3737 R"({
3738 "id" : "A1",
3739 "jsonrpc" : "2.0",
3740 "method" : "json2",
3741 "params" : [
3742 {
3743 "error" : "invalidParams",
3744 "error_code" : 31,
3745 "error_message" : "Invalid parameters.",
3746 "id" : "A1",
3747 "jsonrpc" : "2.0",
3748 "ripplerpc" : "2.0"
3749 }
3750 ],
3751 "ripplerpc" : "2.0"
3752 })",
3753 },
3754 {
3755 "json2: empty outer array.",
3756 __LINE__,
3757 {
3758 "json2",
3759 R"([])",
3760 },
3762 R"({
3763 "method" : "json2",
3764 "params" : [
3765 {
3766 "error" : "invalidParams",
3767 "error_code" : 31,
3768 "error_message" : "Invalid parameters."
3769 }
3770 ]
3771 })",
3772 },
3773 {
3774 "json2: empty inner array.",
3775 __LINE__,
3776 {
3777 "json2",
3778 R"([{"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1",[]}])",
3779 },
3781 R"({
3782 "method" : "json2",
3783 "params" : [
3784 {
3785 "error" : "invalidParams",
3786 "error_code" : 31,
3787 "error_message" : "Invalid parameters."
3788 }
3789 ]
3790 })",
3791 },
3792 {
3793 "json2: array with non-json2 object.",
3794 __LINE__,
3795 {
3796 "json2",
3797 R"([
3798 {"jsonrpc" : "2.1",
3799 "ripplerpc" : "2.0",
3800 "id" : "A1",
3801 "method" : "call_1"
3802 }
3803 ])",
3804 },
3806 R"({
3807 "method" : "json2",
3808 "params" : [
3809 {
3810 "error" : "invalidParams",
3811 "error_code" : 31,
3812 "error_message" : "Invalid parameters."
3813 }
3814 ]
3815 })",
3816 },
3817 {
3818 "json2: non-object or -array inner params member.",
3819 __LINE__,
3820 {
3821 "json2",
3822 R"({
3823 "jsonrpc" : "2.0",
3824 "ripplerpc" : "2.0",
3825 "id" : "A1",
3826 "method" : "call_1",
3827 "params" : true
3828 })",
3829 },
3831 R"({
3832 "id" : "A1",
3833 "jsonrpc" : "2.0",
3834 "method" : "json2",
3835 "params" : [
3836 {
3837 "error" : "invalidParams",
3838 "error_code" : 31,
3839 "error_message" : "Invalid parameters.",
3840 "id" : "A1",
3841 "jsonrpc" : "2.0",
3842 "ripplerpc" : "2.0"
3843 }
3844 ],
3845 "ripplerpc" : "2.0"
3846 })",
3847 },
3848
3849 // ledger
3850 // ----------------------------------------------------------------------
3851 {
3852 "ledger: minimal.",
3853 __LINE__,
3854 {"ledger"},
3856 R"({
3857 "method" : "ledger",
3858 "params" : [
3859 {
3860 "api_version" : %API_VER%,
3861 }
3862 ]
3863 })",
3864 },
3865 {
3866 "ledger: ledger index.",
3867 __LINE__,
3868 {"ledger", "4294967295"},
3870 R"({
3871 "method" : "ledger",
3872 "params" : [
3873 {
3874 "api_version" : %API_VER%,
3875 "ledger_index" : 4294967295
3876 }
3877 ]
3878 })",
3879 },
3880 {
3881 "ledger: text ledger index.",
3882 __LINE__,
3883 {"ledger", "validated"},
3885 R"({
3886 "method" : "ledger",
3887 "params" : [
3888 {
3889 "api_version" : %API_VER%,
3890 "ledger_index" : "validated"
3891 }
3892 ]
3893 })",
3894 },
3895 {
3896 "ledger: ledger hash.",
3897 __LINE__,
3898 {"ledger", "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
3900 R"({
3901 "method" : "ledger",
3902 "params" : [
3903 {
3904 "api_version" : %API_VER%,
3905 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
3906 }
3907 ]
3908 })",
3909 },
3910 {
3911 "ledger: full.",
3912 __LINE__,
3913 {"ledger", "current", "full"},
3915 R"({
3916 "method" : "ledger",
3917 "params" : [
3918 {
3919 "api_version" : %API_VER%,
3920 "full" : true,
3921 "ledger_index" : "current"
3922 }
3923 ]
3924 })",
3925 },
3926 {
3927 "ledger: tx.",
3928 __LINE__,
3929 {"ledger", "closed", "tx"},
3931 R"({
3932 "method" : "ledger",
3933 "params" : [
3934 {
3935 "api_version" : %API_VER%,
3936 "expand" : true,
3937 "ledger_index" : "closed",
3938 "transactions" : true
3939 }
3940 ]
3941 })",
3942 },
3943 {
3944 "ledger: too many arguments.",
3945 __LINE__,
3946 {"ledger", "4294967295", "spare"},
3948 R"({
3949 "method" : "ledger",
3950 "params" : [
3951 {
3952 "api_version" : %API_VER%,
3953 "ledger_index" : 4294967295
3954 }
3955 ]
3956 })",
3957 },
3958 {
3959 "ledger: ledger index too small.",
3960 __LINE__,
3961 {"ledger", "-1"},
3963 R"({
3964 "method" : "ledger",
3965 "params" : [
3966 {
3967 "api_version" : %API_VER%,
3968 "ledger_index" : 0
3969 }
3970 ]
3971 })",
3972 },
3973 {
3974 "ledger: ledger index too big.",
3975 __LINE__,
3976 {"ledger", "4294967296"},
3978 R"({
3979 "method" : "ledger",
3980 "params" : [
3981 {
3982 "api_version" : %API_VER%,
3983 "ledger_index" : 0
3984 }
3985 ]
3986 })",
3987 },
3988 {
3989 "ledger: invalid ledger text.",
3990 __LINE__,
3991 {"ledger", "latest"},
3993 R"({
3994 "method" : "ledger",
3995 "params" : [
3996 {
3997 "api_version" : %API_VER%,
3998 "ledger_index" : 0
3999 }
4000 ]
4001 })",
4002 },
4003 {
4004 "ledger: unsupported final argument.",
4005 __LINE__,
4006 {"ledger", "current", "expand"},
4008 R"({
4009 "method" : "ledger",
4010 "params" : [
4011 {
4012 "api_version" : %API_VER%,
4013 "ledger_index" : "current"
4014 }
4015 ]
4016 })",
4017 },
4018
4019 // ledger_closed
4020 // ---------------------------------------------------------------
4021 {
4022 "ledger_closed: minimal.",
4023 __LINE__,
4024 {"ledger_closed"},
4026 R"({
4027 "method" : "ledger_closed",
4028 "params" : [
4029 {
4030 "api_version" : %API_VER%,
4031 }
4032 ]
4033 })",
4034 },
4035 {
4036 "ledger_closed: too many arguments.",
4037 __LINE__,
4038 {"ledger_closed", "today"},
4040 R"({
4041 "method" : "ledger_closed",
4042 "params" : [
4043 {
4044 "error" : "badSyntax",
4045 "error_code" : 1,
4046 "error_message" : "Syntax error."
4047 }
4048 ]
4049 })",
4050 },
4051
4052 // ledger_current
4053 // --------------------------------------------------------------
4054 {
4055 "ledger_current: minimal.",
4056 __LINE__,
4057 {"ledger_current"},
4059 R"({
4060 "method" : "ledger_current",
4061 "params" : [
4062 {
4063 "api_version" : %API_VER%,
4064 }
4065 ]
4066 })",
4067 },
4068 {
4069 "ledger_current: too many arguments.",
4070 __LINE__,
4071 {"ledger_current", "today"},
4073 R"({
4074 "method" : "ledger_current",
4075 "params" : [
4076 {
4077 "error" : "badSyntax",
4078 "error_code" : 1,
4079 "error_message" : "Syntax error."
4080 }
4081 ]
4082 })",
4083 },
4084
4085 // ledger_header
4086 // ---------------------------------------------------------------
4087 {
4088 "ledger_header: ledger index.",
4089 __LINE__,
4090 {"ledger_header", "4294967295"},
4092 R"({
4093 "method" : "ledger_header",
4094 "params" : [
4095 {
4096 "api_version" : %API_VER%,
4097 "ledger_index" : 4294967295
4098 }
4099 ]
4100 })",
4101 },
4102 {
4103 "ledger_header: ledger hash.",
4104 __LINE__,
4105 {"ledger_header", "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
4107 R"({
4108 "method" : "ledger_header",
4109 "params" : [
4110 {
4111 "api_version" : %API_VER%,
4112 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
4113 }
4114 ]
4115 })",
4116 },
4117 {
4118 "ledger_header: too few arguments.",
4119 __LINE__,
4120 {
4121 "ledger_header",
4122 },
4124 R"({
4125 "method" : "ledger_header",
4126 "params" : [
4127 {
4128 "error" : "badSyntax",
4129 "error_code" : 1,
4130 "error_message" : "Syntax error."
4131 }
4132 ]
4133 })",
4134 },
4135 {
4136 "ledger_header: too many arguments.",
4137 __LINE__,
4138 {"ledger_header", "4294967295", "spare"},
4140 R"({
4141 "method" : "ledger_header",
4142 "params" : [
4143 {
4144 "error" : "badSyntax",
4145 "error_code" : 1,
4146 "error_message" : "Syntax error."
4147 }
4148 ]
4149 })",
4150 },
4151 {
4152 "ledger_header: text ledger index.",
4153 __LINE__,
4154 {"ledger_header", "current"},
4156 R"({
4157 "method" : "ledger_header",
4158 "params" : [
4159 {
4160 "api_version" : %API_VER%,
4161 "ledger_index" : 0
4162 }
4163 ]
4164 })",
4165 },
4166 {
4167 "ledger_header: ledger index too small.",
4168 __LINE__,
4169 {"ledger_header", "-1"},
4171 R"({
4172 "method" : "ledger_header",
4173 "params" : [
4174 {
4175 "api_version" : %API_VER%,
4176 "ledger_index" : 0
4177 }
4178 ]
4179 })",
4180 },
4181 {
4182 "ledger_header: ledger index too big.",
4183 __LINE__,
4184 {"ledger_header", "4294967296"},
4186 R"({
4187 "method" : "ledger_header",
4188 "params" : [
4189 {
4190 "api_version" : %API_VER%,
4191 "ledger_index" : 0
4192 }
4193 ]
4194 })",
4195 },
4196
4197 // ledger_request
4198 // --------------------------------------------------------------
4199 {
4200 "ledger_request: ledger index.",
4201 __LINE__,
4202 {"ledger_request", "4294967295"},
4204 R"({
4205 "method" : "ledger_request",
4206 "params" : [
4207 {
4208 "api_version" : %API_VER%,
4209 "ledger_index" : 4294967295
4210 }
4211 ]
4212 })",
4213 },
4214 {
4215 "ledger_request: ledger hash.",
4216 __LINE__,
4217 {"ledger_request", "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
4219 R"({
4220 "method" : "ledger_request",
4221 "params" : [
4222 {
4223 "api_version" : %API_VER%,
4224 "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
4225 }
4226 ]
4227 })",
4228 },
4229 {
4230 "ledger_request: too few arguments.",
4231 __LINE__,
4232 {
4233 "ledger_request",
4234 },
4236 R"({
4237 "method" : "ledger_request",
4238 "params" : [
4239 {
4240 "error" : "badSyntax",
4241 "error_code" : 1,
4242 "error_message" : "Syntax error."
4243 }
4244 ]
4245 })",
4246 },
4247 {
4248 "ledger_request: too many arguments.",
4249 __LINE__,
4250 {"ledger_request", "4294967295", "spare"},
4252 R"({
4253 "method" : "ledger_request",
4254 "params" : [
4255 {
4256 "error" : "badSyntax",
4257 "error_code" : 1,
4258 "error_message" : "Syntax error."
4259 }
4260 ]
4261 })",
4262 },
4263 {
4264 "ledger_request: text ledger index.",
4265 __LINE__,
4266 {"ledger_request", "current"},
4268 R"({
4269 "method" : "ledger_request",
4270 "params" : [
4271 {
4272 "api_version" : %API_VER%,
4273 "ledger_index" : 0
4274 }
4275 ]
4276 })",
4277 },
4278 {
4279 "ledger_request: ledger index too small.",
4280 __LINE__,
4281 {"ledger_request", "-1"},
4283 R"({
4284 "method" : "ledger_request",
4285 "params" : [
4286 {
4287 "api_version" : %API_VER%,
4288 "ledger_index" : 0
4289 }
4290 ]
4291 })",
4292 },
4293 {
4294 "ledger_request: ledger index too big.",
4295 __LINE__,
4296 {"ledger_request", "4294967296"},
4298 R"({
4299 "method" : "ledger_request",
4300 "params" : [
4301 {
4302 "api_version" : %API_VER%,
4303 "ledger_index" : 0
4304 }
4305 ]
4306 })",
4307 },
4308
4309 // log_level
4310 // -------------------------------------------------------------------
4311 {
4312 "log_level: minimal.",
4313 __LINE__,
4314 {
4315 "log_level",
4316 },
4318 R"({
4319 "method" : "log_level",
4320 "params" : [
4321 {
4322 "api_version" : %API_VER%,
4323 }
4324 ]
4325 })",
4326 },
4327 {
4328 "log_level: fatal.",
4329 __LINE__,
4330 {"log_level", "fatal"},
4332 R"({
4333 "method" : "log_level",
4334 "params" : [
4335 {
4336 "api_version" : %API_VER%,
4337 "severity" : "fatal"
4338 }
4339 ]
4340 })",
4341 },
4342 {
4343 "log_level: error.",
4344 __LINE__,
4345 {"log_level", "error"},
4347 R"({
4348 "method" : "log_level",
4349 "params" : [
4350 {
4351 "api_version" : %API_VER%,
4352 "severity" : "error"
4353 }
4354 ]
4355 })",
4356 },
4357 {
4358 "log_level: warn.",
4359 __LINE__,
4360 {"log_level", "warn"},
4362 R"({
4363 "method" : "log_level",
4364 "params" : [
4365 {
4366 "api_version" : %API_VER%,
4367 "severity" : "warn"
4368 }
4369 ]
4370 })",
4371 },
4372 {
4373 "log_level: debug.",
4374 __LINE__,
4375 {"log_level", "debug"},
4377 R"({
4378 "method" : "log_level",
4379 "params" : [
4380 {
4381 "api_version" : %API_VER%,
4382 "severity" : "debug"
4383 }
4384 ]
4385 })",
4386 },
4387 {
4388 "log_level: trace.",
4389 __LINE__,
4390 {"log_level", "trace"},
4392 R"({
4393 "method" : "log_level",
4394 "params" : [
4395 {
4396 "api_version" : %API_VER%,
4397 "severity" : "trace"
4398 }
4399 ]
4400 })",
4401 },
4402 {
4403 "log_level: base partition.",
4404 __LINE__,
4405 {"log_level", "base", "trace"},
4407 R"({
4408 "method" : "log_level",
4409 "params" : [
4410 {
4411 "api_version" : %API_VER%,
4412 "partition" : "base",
4413 "severity" : "trace"
4414 }
4415 ]
4416 })",
4417 },
4418 {
4419 "log_level: partition_name.",
4420 __LINE__,
4421 {"log_level", "partition_name", "fatal"},
4423 R"({
4424 "method" : "log_level",
4425 "params" : [
4426 {
4427 "api_version" : %API_VER%,
4428 "partition" : "partition_name",
4429 "severity" : "fatal"
4430 }
4431 ]
4432 })",
4433 },
4434 {
4435 "log_level: too many arguments.",
4436 __LINE__,
4437 {"log_level", "partition_name", "fatal", "extra"},
4439 R"({
4440 "method" : "log_level",
4441 "params" : [
4442 {
4443 "error" : "badSyntax",
4444 "error_code" : 1,
4445 "error_message" : "Syntax error."
4446 }
4447 ]
4448 })",
4449 },
4450 {
4451 "log_level: invalid severity.",
4452 __LINE__,
4453 {"log_level", "err"},
4455 R"({
4456 "method" : "log_level",
4457 "params" : [
4458 {
4459 "api_version" : %API_VER%,
4460 "severity" : "err"
4461 }
4462 ]
4463 })",
4464 },
4465 {
4466 "log_level: swap partition name and severity.",
4467 __LINE__,
4468 {
4469 "log_level",
4470 "fatal",
4471 "partition_name",
4472 },
4474 R"({
4475 "method" : "log_level",
4476 "params" : [
4477 {
4478 "api_version" : %API_VER%,
4479 "partition" : "fatal",
4480 "severity" : "partition_name"
4481 }
4482 ]
4483 })",
4484 },
4485
4486 // logrotate
4487 // -------------------------------------------------------------------
4488 {
4489 "logrotate: minimal.",
4490 __LINE__,
4491 {
4492 "logrotate",
4493 },
4495 R"({
4496 "method" : "logrotate",
4497 "params" : [
4498 {
4499 "api_version" : %API_VER%,
4500 }
4501 ]
4502 })",
4503 },
4504 {
4505 "logrotate: too many arguments.",
4506 __LINE__,
4507 {"logrotate", "extra"},
4509 R"({
4510 "method" : "logrotate",
4511 "params" : [
4512 {
4513 "error" : "badSyntax",
4514 "error_code" : 1,
4515 "error_message" : "Syntax error."
4516 }
4517 ]
4518 })",
4519 },
4520
4521 // owner_info
4522 // ------------------------------------------------------------------
4523 {
4524 "owner_info: minimal.",
4525 __LINE__,
4526 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
4528 R"({
4529 "method" : "owner_info",
4530 "params" : [
4531 {
4532 "api_version" : %API_VER%,
4533 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
4534 }
4535 ]
4536 })",
4537 },
4538 {
4539 "owner_info: with numeric ledger index.",
4540 __LINE__,
4541 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "987654321"},
4543 R"({
4544 "method" : "owner_info",
4545 "params" : [
4546 {
4547 "api_version" : %API_VER%,
4548 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4549 "ledger_index" : 987654321
4550 }
4551 ]
4552 })",
4553 },
4554 {
4555 "owner_info: with text ledger index.",
4556 __LINE__,
4557 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
4559 R"({
4560 "method" : "owner_info",
4561 "params" : [
4562 {
4563 "api_version" : %API_VER%,
4564 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4565 "ledger_index" : "validated"
4566 }
4567 ]
4568 })",
4569 },
4570 {
4571 "owner_info: with ledger hash.",
4572 __LINE__,
4573 {
4574 "owner_info",
4575 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4576 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
4577 },
4579 R"({
4580 "method" : "owner_info",
4581 "params" : [
4582 {
4583 "api_version" : %API_VER%,
4584 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4585 "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
4586 }
4587 ]
4588 })",
4589 },
4590 {
4591 "owner_info: with ledger index.",
4592 __LINE__,
4593 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
4595 R"({
4596 "method" : "owner_info",
4597 "params" : [
4598 {
4599 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4600 "api_version" : %API_VER%,
4601 "ledger_index" : "validated"
4602 }
4603 ]
4604 })",
4605 },
4606 {
4607 "owner_info: too few arguments.",
4608 __LINE__,
4609 {
4610 "owner_info",
4611 },
4613 R"({
4614 "method" : "owner_info",
4615 "params" : [
4616 {
4617 "error" : "badSyntax",
4618 "error_code" : 1,
4619 "error_message" : "Syntax error."
4620 }
4621 ]
4622 })",
4623 },
4624 {
4625 "owner_info: too many arguments.",
4626 __LINE__,
4627 {
4628 "owner_info",
4629 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4630 "current",
4631 "extra1",
4632 "extra2",
4633 },
4635 R"({
4636 "method" : "owner_info",
4637 "params" : [
4638 {
4639 "error" : "badSyntax",
4640 "error_code" : 1,
4641 "error_message" : "Syntax error."
4642 }
4643 ]
4644 })",
4645 },
4646 {
4647 "owner_info: invalid accountID.",
4648 __LINE__,
4649 {
4650 "owner_info",
4651 "", // Note: very few values are detected as bad!
4652 },
4654 R"({
4655 "method" : "owner_info",
4656 "params" : [
4657 {
4658 "error" : "actMalformed",
4659 "error_code" : 35,
4660 "error_message" : "Account malformed."
4661 }
4662 ]
4663 })",
4664 },
4665 {
4666 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
4667 // cannot currently occur because jvParseLedger() always returns true.
4668 "owner_info: invalid ledger selection.",
4669 __LINE__,
4670 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
4672 R"({
4673 "method" : "owner_info",
4674 "params" : [
4675 {
4676 "api_version" : %API_VER%,
4677 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4678 "ledger_index" : 0
4679 }
4680 ]
4681 })",
4682 },
4683 {
4684 // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
4685 // cannot currently occur because jvParseLedger() always returns true.
4686 "owner_info: invalid ledger selection.",
4687 __LINE__,
4688 {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
4690 R"({
4691 "method" : "owner_info",
4692 "params" : [
4693 {
4694 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4695 "api_version" : %API_VER%,
4696 "ledger_index" : 0
4697 }
4698 ]
4699 })",
4700 },
4701
4702 // peers
4703 // -----------------------------------------------------------------------
4704 {
4705 "peers: minimal.",
4706 __LINE__,
4707 {
4708 "peers",
4709 },
4711 R"({
4712 "method" : "peers",
4713 "params" : [
4714 {
4715 "api_version" : %API_VER%,
4716 }
4717 ]
4718 })",
4719 },
4720 {
4721 "peers: too many arguments.",
4722 __LINE__,
4723 {"peers", "extra"},
4725 R"({
4726 "method" : "peers",
4727 "params" : [
4728 {
4729 "error" : "badSyntax",
4730 "error_code" : 1,
4731 "error_message" : "Syntax error."
4732 }
4733 ]
4734 })",
4735 },
4736
4737 // peer_reservations_add
4738 // -------------------------------------------------------
4739 {
4740 "peer_reservations_add: minimal.",
4741 __LINE__,
4742 {"peer_reservations_add", "public_key_string"},
4744 R"({
4745 "method" : "peer_reservations_add",
4746 "params" : [
4747 {
4748 "api_version" : %API_VER%,
4749 "public_key" : "public_key_string"
4750 }
4751 ]
4752 })",
4753 },
4754 {
4755 "peer_reservations_add: with description.",
4756 __LINE__,
4757 {"peer_reservations_add", "public_key_string", "public_key_description"},
4759 R"({
4760 "method" : "peer_reservations_add",
4761 "params" : [
4762 {
4763 "api_version" : %API_VER%,
4764 "description" : "public_key_description",
4765 "public_key" : "public_key_string"
4766 }
4767 ]
4768 })",
4769 },
4770 {
4771 "peer_reservations_add: too few arguments.",
4772 __LINE__,
4773 {"peer_reservations_add"},
4775 R"({
4776 "method" : "peer_reservations_add",
4777 "params" : [
4778 {
4779 "error" : "badSyntax",
4780 "error_code" : 1,
4781 "error_message" : "Syntax error."
4782 }
4783 ]
4784 })",
4785 },
4786 {
4787 "peer_reservations_add: too many arguments.",
4788 __LINE__,
4789 {"peer_reservations_add", "public_key_string", "public_key_description", "spare"},
4791 R"({
4792 "method" : "peer_reservations_add",
4793 "params" : [
4794 {
4795 "error" : "badSyntax",
4796 "error_code" : 1,
4797 "error_message" : "Syntax error."
4798 }
4799 ]
4800 })",
4801 },
4802
4803 // peer_reservations_del
4804 // -------------------------------------------------------
4805 {
4806 "peer_reservations_del: minimal.",
4807 __LINE__,
4808 {"peer_reservations_del", "public_key_string"},
4810 R"({
4811 "method" : "peer_reservations_del",
4812 "params" : [
4813 {
4814 "api_version" : %API_VER%,
4815 "public_key" : "public_key_string"
4816 }
4817 ]
4818 })",
4819 },
4820 {
4821 "peer_reservations_del: too few arguments.",
4822 __LINE__,
4823 {"peer_reservations_del"},
4825 R"({
4826 "method" : "peer_reservations_del",
4827 "params" : [
4828 {
4829 "error" : "badSyntax",
4830 "error_code" : 1,
4831 "error_message" : "Syntax error."
4832 }
4833 ]
4834 })",
4835 },
4836 {
4837 "peer_reservations_del: too many arguments.",
4838 __LINE__,
4839 {"peer_reservations_del", "public_key_string", "public_key_description", "spare"},
4841 R"({
4842 "method" : "peer_reservations_del",
4843 "params" : [
4844 {
4845 "error" : "badSyntax",
4846 "error_code" : 1,
4847 "error_message" : "Syntax error."
4848 }
4849 ]
4850 })",
4851 },
4852
4853 // ping
4854 // ------------------------------------------------------------------------
4855 {
4856 "ping: minimal.",
4857 __LINE__,
4858 {
4859 "ping",
4860 },
4862 R"({
4863 "method" : "ping",
4864 "params" : [
4865 {
4866 "api_version" : %API_VER%,
4867 }
4868 ]
4869 })",
4870 },
4871 {
4872 "ping: too many arguments.",
4873 __LINE__,
4874 {"ping", "extra"},
4876 R"({
4877 "method" : "ping",
4878 "params" : [
4879 {
4880 "error" : "badSyntax",
4881 "error_code" : 1,
4882 "error_message" : "Syntax error."
4883 }
4884 ]
4885 })",
4886 },
4887
4888 // print
4889 // -----------------------------------------------------------------------
4890 {
4891 "print: minimal.",
4892 __LINE__,
4893 {
4894 "print",
4895 },
4897 R"({
4898 "method" : "print",
4899 "params" : [
4900 {
4901 "api_version" : %API_VER%,
4902 }
4903 ]
4904 })",
4905 },
4906 {
4907 // The docs indicate that no arguments are allowed. So should this error?
4908 "print: extra argument.",
4909 __LINE__,
4910 {"print", "extra"},
4912 R"({
4913 "method" : "print",
4914 "params" : [
4915 {
4916 "api_version" : %API_VER%,
4917 "params" : [ "extra" ]
4918 }
4919 ]
4920 })",
4921 },
4922 {
4923 "print: too many arguments.",
4924 __LINE__,
4925 {"print", "extra1", "extra2"},
4927 R"({
4928 "method" : "print",
4929 "params" : [
4930 {
4931 "error" : "badSyntax",
4932 "error_code" : 1,
4933 "error_message" : "Syntax error."
4934 }
4935 ]
4936 })",
4937 },
4938
4939 // random
4940 // ----------------------------------------------------------------------
4941 {
4942 "random: minimal.",
4943 __LINE__,
4944 {
4945 "random",
4946 },
4948 R"({
4949 "method" : "random",
4950 "params" : [
4951 {
4952 "api_version" : %API_VER%,
4953 }
4954 ]
4955 })",
4956 },
4957 {
4958 "random: too many arguments.",
4959 __LINE__,
4960 {"random", "extra"},
4962 R"({
4963 "method" : "random",
4964 "params" : [
4965 {
4966 "error" : "badSyntax",
4967 "error_code" : 1,
4968 "error_message" : "Syntax error."
4969 }
4970 ]
4971 })",
4972 },
4973
4974 // ripple_path_find
4975 // ------------------------------------------------------------
4976 {
4977 "ripple_path_find: minimal.",
4978 __LINE__,
4979 {
4980 "ripple_path_find",
4981 R"({"json_argument":true})",
4982 },
4984 R"({
4985 "method" : "ripple_path_find",
4986 "params" : [
4987 {
4988 "api_version" : %API_VER%,
4989 "json_argument" : true
4990 }
4991 ]
4992 })",
4993 },
4994 {
4995 "ripple_path_find: ledger index.",
4996 __LINE__,
4997 {"ripple_path_find", R"({"json_argument":true})", "4294967295"},
4999 R"({
5000 "method" : "ripple_path_find",
5001 "params" : [
5002 {
5003 "api_version" : %API_VER%,
5004 "json_argument" : true,
5005 "ledger_index" : 4294967295
5006 }
5007 ]
5008 })",
5009 },
5010 {
5011 "ripple_path_find: text ledger index.",
5012 __LINE__,
5013 {"ripple_path_find", R"({"json_argument":true})", "closed"},
5015 R"({
5016 "method" : "ripple_path_find",
5017 "params" : [
5018 {
5019 "api_version" : %API_VER%,
5020 "json_argument" : true,
5021 "ledger_index" : "closed"
5022 }
5023 ]
5024 })",
5025 },
5026 {
5027 "ripple_path_find: ledger hash.",
5028 __LINE__,
5029 {
5030 "ripple_path_find",
5031 R"({"json_argument":true})",
5032 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5033 },
5035 R"({
5036 "method" : "ripple_path_find",
5037 "params" : [
5038 {
5039 "api_version" : %API_VER%,
5040 "json_argument" : true,
5041 "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5042 }
5043 ]
5044 })",
5045 },
5046
5047 {
5048 "ripple_path_find: too few arguments.",
5049 __LINE__,
5050 {
5051 "ripple_path_find",
5052 },
5054 R"({
5055 "method" : "ripple_path_find",
5056 "params" : [
5057 {
5058 "error" : "badSyntax",
5059 "error_code" : 1,
5060 "error_message" : "Syntax error."
5061 }
5062 ]
5063 })",
5064 },
5065 {
5066 "ripple_path_find: too many arguments.",
5067 __LINE__,
5068 {"ripple_path_find", R"({"json_argument":true})", "current", "extra"},
5070 R"({
5071 "method" : "ripple_path_find",
5072 "params" : [
5073 {
5074 "error" : "badSyntax",
5075 "error_code" : 1,
5076 "error_message" : "Syntax error."
5077 }
5078 ]
5079 })",
5080 },
5081 {
5082 "ripple_path_find: invalid json (note extra comma).",
5083 __LINE__,
5084 {
5085 "ripple_path_find",
5086 R"({"json_argument":true,})",
5087 },
5089 R"({
5090 "method" : "ripple_path_find",
5091 "params" : [
5092 {
5093 "error" : "invalidParams",
5094 "error_code" : 31,
5095 "error_message" : "Invalid parameters."
5096 }
5097 ]
5098 })",
5099 },
5100 {
5101 "ripple_path_find: ledger index too small.",
5102 __LINE__,
5103 {"ripple_path_find", R"({"json_argument":true})", "-1"},
5105 R"({
5106 "method" : "ripple_path_find",
5107 "params" : [
5108 {
5109 "api_version" : %API_VER%,
5110 "json_argument" : true,
5111 "ledger_index" : 0
5112 }
5113 ]
5114 })",
5115 },
5116 {
5117 "ripple_path_find: ledger index too big.",
5118 __LINE__,
5119 {"ripple_path_find", R"({"json_argument":true})", "4294967296"},
5121 R"({
5122 "method" : "ripple_path_find",
5123 "params" : [
5124 {
5125 "api_version" : %API_VER%,
5126 "json_argument" : true,
5127 "ledger_index" : 0
5128 }
5129 ]
5130 })",
5131 },
5132 {
5133 "ripple_path_find: invalid text ledger index.",
5134 __LINE__,
5135 {"ripple_path_find", R"({"json_argument":true})", "cur"},
5137 R"({
5138 "method" : "ripple_path_find",
5139 "params" : [
5140 {
5141 "api_version" : %API_VER%,
5142 "json_argument" : true,
5143 "ledger_index" : 0
5144 }
5145 ]
5146 })",
5147 },
5148
5149 // sign
5150 // ------------------------------------------------------------------------
5151 {
5152 "sign: minimal.",
5153 __LINE__,
5154 {
5155 "sign",
5156 "my_secret",
5157 R"({"json_argument":true})",
5158 },
5160 R"({
5161 "method" : "sign",
5162 "params" : [
5163 {
5164 "api_version" : %API_VER%,
5165 "secret" : "my_secret",
5166 "tx_json" : {
5167 "json_argument" : true
5168 }
5169 }
5170 ]
5171 })",
5172 },
5173 {
5174 "sign: offline.",
5175 __LINE__,
5176 {"sign", "my_secret", R"({"json_argument":true})", "offline"},
5178 R"({
5179 "method" : "sign",
5180 "params" : [
5181 {
5182 "api_version" : %API_VER%,
5183 "offline" : true,
5184 "secret" : "my_secret",
5185 "tx_json" : {
5186 "json_argument" : true
5187 }
5188 }
5189 ]
5190 })",
5191 },
5192 {
5193 "sign: too few arguments.",
5194 __LINE__,
5195 {"sign", "contents_of_blob"},
5197 R"({
5198 "method" : "sign",
5199 "params" : [
5200 {
5201 "error" : "badSyntax",
5202 "error_code" : 1,
5203 "error_message" : "Syntax error."
5204 }
5205 ]
5206 })",
5207 },
5208 {
5209 "sign: offline flag with signature_target.",
5210 __LINE__,
5211 {"sign", "my_secret", R"({"json_argument":true})", "offline", "extra"},
5213 R"({
5214 "method" : "sign",
5215 "params" : [
5216 {
5217 "api_version" : %API_VER%,
5218 "offline" : true,
5219 "secret" : "my_secret",
5220 "signature_target" : "extra",
5221 "tx_json" :
5222 {
5223 "json_argument" : true
5224 }
5225 }
5226 ]
5227 })",
5228 },
5229 {
5230 "sign: too many arguments.",
5231 __LINE__,
5232 {
5233 "sign",
5234 "my_secret",
5235 R"({"json_argument":true})",
5236 "offline",
5237 "CounterpartySignature",
5238 "extra",
5239 },
5241 R"({
5242 "method" : "sign",
5243 "params" : [
5244 {
5245 "error" : "badSyntax",
5246 "error_code" : 1,
5247 "error_message" : "Syntax error."
5248 }
5249 ]
5250 })",
5251 },
5252 {
5253 "sign: invalid JSON (note extra comma).",
5254 __LINE__,
5255 {
5256 "sign",
5257 "my_secret",
5258 R"({"json_argument":true,})",
5259 },
5261 R"({
5262 "method" : "sign",
5263 "params" : [
5264 {
5265 "error" : "invalidParams",
5266 "error_code" : 31,
5267 "error_message" : "Invalid parameters."
5268 }
5269 ]
5270 })",
5271 },
5272 {
5273 "sign: misspelled offline flag interpreted as signature_target.",
5274 __LINE__,
5275 {"sign", "my_secret", R"({"json_argument":true})", "offlin"},
5277 R"({
5278 "method" : "sign",
5279 "params" : [
5280 {
5281 "api_version" : %API_VER%,
5282 "secret" : "my_secret",
5283 "signature_target" : "offlin",
5284 "tx_json" :
5285 {
5286 "json_argument" : true
5287 }
5288 }
5289 ]
5290 })",
5291 },
5292
5293 // sign_for
5294 // --------------------------------------------------------------------
5295 {
5296 "sign_for: minimal.",
5297 __LINE__,
5298 {
5299 "sign_for",
5300 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5301 "my_secret",
5302 R"({"json_argument":true})",
5303 },
5305 R"({
5306 "method" : "sign_for",
5307 "params" : [
5308 {
5309 "api_version" : %API_VER%,
5310 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5311 "secret" : "my_secret",
5312 "tx_json" : {
5313 "json_argument" : true
5314 }
5315 }
5316 ]
5317 })",
5318 },
5319 {
5320 "sign_for: offline.",
5321 __LINE__,
5322 {
5323 "sign_for",
5324 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5325 "my_secret",
5326 R"({"json_argument":true})",
5327 "offline",
5328 },
5330 R"({
5331 "method" : "sign_for",
5332 "params" : [
5333 {
5334 "api_version" : %API_VER%,
5335 "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5336 "offline" : true,
5337 "secret" : "my_secret",
5338 "tx_json" : {
5339 "json_argument" : true
5340 }
5341 }
5342 ]
5343 })",
5344 },
5345 {
5346 "sign_for: too few arguments.",
5347 __LINE__,
5348 {
5349 "sign_for",
5350 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5351 "my_secret",
5352 },
5354 R"({
5355 "method" : "sign_for",
5356 "params" : [
5357 {
5358 "error" : "badSyntax",
5359 "error_code" : 1,
5360 "error_message" : "Syntax error."
5361 }
5362 ]
5363 })",
5364 },
5365 {
5366 "sign_for: too many arguments.",
5367 __LINE__,
5368 {
5369 "sign_for",
5370 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5371 "my_secret",
5372 R"({"json_argument":true})",
5373 "offline",
5374 "extra",
5375 },
5377 R"({
5378 "method" : "sign_for",
5379 "params" : [
5380 {
5381 "error" : "badSyntax",
5382 "error_code" : 1,
5383 "error_message" : "Syntax error."
5384 }
5385 ]
5386 })",
5387 },
5388 {
5389 "sign_for: invalid json (note extra comma).",
5390 __LINE__,
5391 {
5392 "sign_for",
5393 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5394 "my_secret",
5395 R"({"json_argument":true,})",
5396 },
5398 R"({
5399 "method" : "sign_for",
5400 "params" : [
5401 {
5402 "error" : "invalidParams",
5403 "error_code" : 31,
5404 "error_message" : "Invalid parameters."
5405 }
5406 ]
5407 })",
5408 },
5409 {
5410 "sign_for: invalid final argument.",
5411 __LINE__,
5412 {
5413 "sign_for",
5414 "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5415 "my_secret",
5416 R"({"json_argument":true})",
5417 "ofline",
5418 },
5420 R"({
5421 "method" : "sign_for",
5422 "params" : [
5423 {
5424 "error" : "invalidParams",
5425 "error_code" : 31,
5426 "error_message" : "Invalid parameters."
5427 }
5428 ]
5429 })",
5430 },
5431
5432 // submit
5433 // ----------------------------------------------------------------------
5434 {
5435 "submit: blob.",
5436 __LINE__,
5437 {"submit", "the blob is unvalidated and may be any length..."},
5439 R"({
5440 "method" : "submit",
5441 "params" : [
5442 {
5443 "api_version" : %API_VER%,
5444 "tx_blob" : "the blob is unvalidated and may be any length..."
5445 }
5446 ]
5447 })",
5448 },
5449 {
5450 "submit: json.",
5451 __LINE__,
5452 {
5453 "submit",
5454 "my_secret",
5455 R"({"json_argument":true})",
5456 },
5458 R"({
5459 "method" : "submit",
5460 "params" : [
5461 {
5462 "api_version" : %API_VER%,
5463 "secret" : "my_secret",
5464 "tx_json" : {
5465 "json_argument" : true
5466 }
5467 }
5468 ]
5469 })",
5470 },
5471 {
5472 "submit: too few arguments.",
5473 __LINE__,
5474 {
5475 "submit",
5476 },
5478 R"({
5479 "method" : "submit",
5480 "params" : [
5481 {
5482 "error" : "badSyntax",
5483 "error_code" : 1,
5484 "error_message" : "Syntax error."
5485 }
5486 ]
5487 })",
5488 },
5489 {
5490 // Note: I believe this _ought_ to be detected as too many arguments.
5491 "submit: four arguments.",
5492 __LINE__,
5493 {"submit", "my_secret", R"({"json_argument":true})", "offline"},
5495 R"({
5496 "method" : "submit",
5497 "params" : [
5498 {
5499 "api_version" : %API_VER%,
5500 "offline" : true,
5501 "secret" : "my_secret",
5502 "tx_json" : {
5503 "json_argument" : true
5504 }
5505 }
5506 ]
5507 })",
5508 },
5509 {
5510 "submit: offline flag with signature_target.",
5511 __LINE__,
5512 {"submit", "my_secret", R"({"json_argument":true})", "offline", "extra"},
5514 R"({
5515 "method" : "submit",
5516 "params" : [
5517 {
5518 "api_version" : %API_VER%,
5519 "offline" : true,
5520 "secret" : "my_secret",
5521 "signature_target" : "extra",
5522 "tx_json" :
5523 {
5524 "json_argument" : true
5525 }
5526 }
5527 ]
5528 })",
5529 },
5530 {
5531 "submit: too many arguments.",
5532 __LINE__,
5533 {
5534 "submit",
5535 "my_secret",
5536 R"({"json_argument":true})",
5537 "offline",
5538 "CounterpartySignature",
5539 "extra",
5540 },
5542 R"({
5543 "method" : "submit",
5544 "params" : [
5545 {
5546 "error" : "badSyntax",
5547 "error_code" : 1,
5548 "error_message" : "Syntax error."
5549 }
5550 ]
5551 })",
5552 },
5553 {
5554 "submit: invalid json (note extra comma).",
5555 __LINE__,
5556 {
5557 "submit",
5558 "my_secret",
5559 R"({"json_argument":true,})",
5560 },
5562 R"({
5563 "method" : "submit",
5564 "params" : [
5565 {
5566 "error" : "invalidParams",
5567 "error_code" : 31,
5568 "error_message" : "Invalid parameters."
5569 }
5570 ]
5571 })",
5572 },
5573 {
5574 "submit: misspelled offline flag interpreted as signature_target.",
5575 __LINE__,
5576 {"submit", "my_secret", R"({"json_argument":true})", "offlne"},
5578 R"({
5579 "method" : "submit",
5580 "params" : [
5581 {
5582 "api_version" : %API_VER%,
5583 "secret" : "my_secret",
5584 "signature_target" : "offlne",
5585 "tx_json" :
5586 {
5587 "json_argument" : true
5588 }
5589 }
5590 ]
5591 })",
5592 },
5593
5594 // submit_multisigned
5595 // ----------------------------------------------------------
5596 {
5597 "submit_multisigned: json.",
5598 __LINE__,
5599 {
5600 "submit_multisigned",
5601 R"({"json_argument":true})",
5602 },
5604 R"({
5605 "method" : "submit_multisigned",
5606 "params" : [
5607 {
5608 "api_version" : %API_VER%,
5609 "tx_json" : {
5610 "json_argument" : true
5611 }
5612 }
5613 ]
5614 })",
5615 },
5616 {
5617 "submit_multisigned: too few arguments.",
5618 __LINE__,
5619 {
5620 "submit_multisigned",
5621 },
5623 R"({
5624 "method" : "submit_multisigned",
5625 "params" : [
5626 {
5627 "error" : "badSyntax",
5628 "error_code" : 1,
5629 "error_message" : "Syntax error."
5630 }
5631 ]
5632 })",
5633 },
5634 {
5635 "submit_multisigned: too many arguments.",
5636 __LINE__,
5637 {"submit_multisigned", R"({"json_argument":true})", "extra"},
5639 R"({
5640 "method" : "submit_multisigned",
5641 "params" : [
5642 {
5643 "error" : "badSyntax",
5644 "error_code" : 1,
5645 "error_message" : "Syntax error."
5646 }
5647 ]
5648 })",
5649 },
5650 {
5651 "submit_multisigned: invalid json (note extra comma).",
5652 __LINE__,
5653 {
5654 "submit_multisigned",
5655 R"({"json_argument":true,})",
5656 },
5658 R"({
5659 "method" : "submit_multisigned",
5660 "params" : [
5661 {
5662 "error" : "invalidParams",
5663 "error_code" : 31,
5664 "error_message" : "Invalid parameters."
5665 }
5666 }
5667 ]
5668 })",
5669 },
5670
5671 // server_info
5672 // -----------------------------------------------------------------
5673 {
5674 "server_info: minimal.",
5675 __LINE__,
5676 {
5677 "server_info",
5678 },
5680 R"({
5681 "method" : "server_info",
5682 "params" : [
5683 {
5684 "api_version" : %API_VER%,
5685 }
5686 ]
5687 })",
5688 },
5689 {
5690 "server_info: counters.",
5691 __LINE__,
5692 {"server_info", "counters"},
5694 R"({
5695 "method" : "server_info",
5696 "params" : [
5697 {
5698 "api_version" : %API_VER%,
5699 "counters" : true
5700 }
5701 ]
5702 })",
5703 },
5704 {
5705 "server_info: too many arguments.",
5706 __LINE__,
5707 {"server_info", "counters", "extra"},
5709 R"({
5710 "method" : "server_info",
5711 "params" : [
5712 {
5713 "error" : "badSyntax",
5714 "error_code" : 1,
5715 "error_message" : "Syntax error."
5716 }
5717 ]
5718 })",
5719 },
5720 {
5721 "server_info: non-counters argument.",
5722 __LINE__,
5723 {"server_info", "counter"},
5725 R"({
5726 "method" : "server_info",
5727 "params" : [
5728 {
5729 "api_version" : %API_VER%,
5730 }
5731 ]
5732 })",
5733 },
5734
5735 // server_state
5736 // ----------------------------------------------------------------
5737 {
5738 "server_state: minimal.",
5739 __LINE__,
5740 {
5741 "server_state",
5742 },
5744 R"({
5745 "method" : "server_state",
5746 "params" : [
5747 {
5748 "api_version" : %API_VER%,
5749 }
5750 ]
5751 })",
5752 },
5753 {
5754 "server_state: counters.",
5755 __LINE__,
5756 {"server_state", "counters"},
5758 R"({
5759 "method" : "server_state",
5760 "params" : [
5761 {
5762 "api_version" : %API_VER%,
5763 "counters" : true
5764 }
5765 ]
5766 })",
5767 },
5768 {
5769 "server_state: too many arguments.",
5770 __LINE__,
5771 {"server_state", "counters", "extra"},
5773 R"({
5774 "method" : "server_state",
5775 "params" : [
5776 {
5777 "error" : "badSyntax",
5778 "error_code" : 1,
5779 "error_message" : "Syntax error."
5780 }
5781 ]
5782 })",
5783 },
5784 {
5785 "server_state: non-counters argument.",
5786 __LINE__,
5787 {"server_state", "counter"},
5789 R"({
5790 "method" : "server_state",
5791 "params" : [
5792 {
5793 "api_version" : %API_VER%,
5794 }
5795 ]
5796 })",
5797 },
5798
5799 // stop
5800 // ------------------------------------------------------------------------
5801 {
5802 "stop: minimal.",
5803 __LINE__,
5804 {
5805 "stop",
5806 },
5808 R"({
5809 "method" : "stop",
5810 "params" : [
5811 {
5812 "api_version" : %API_VER%,
5813 }
5814 ]
5815 })",
5816 },
5817 {
5818 "stop: too many arguments.",
5819 __LINE__,
5820 {"stop", "extra"},
5822 R"({
5823 "method" : "stop",
5824 "params" : [
5825 {
5826 "error" : "badSyntax",
5827 "error_code" : 1,
5828 "error_message" : "Syntax error."
5829 }
5830 ]
5831 })",
5832 },
5833
5834 // transaction_entry
5835 // -----------------------------------------------------------
5836 {
5837 "transaction_entry: ledger index.",
5838 __LINE__,
5839 {
5840 "transaction_entry",
5841 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5842 "4294967295",
5843 },
5845 R"({
5846 "method" : "transaction_entry",
5847 "params" : [
5848 {
5849 "api_version" : %API_VER%,
5850 "ledger_index" : 4294967295,
5851 "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5852 }
5853 ]
5854 })",
5855 },
5856 {
5857 "transaction_entry: text ledger index.",
5858 __LINE__,
5859 {
5860 "transaction_entry",
5861 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5862 "current",
5863 },
5865 R"({
5866 "method" : "transaction_entry",
5867 "params" : [
5868 {
5869 "api_version" : %API_VER%,
5870 "ledger_index" : "current",
5871 "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5872 }
5873 ]
5874 })",
5875 },
5876 {
5877 "transaction_entry: ledger hash.",
5878 __LINE__,
5879 {
5880 "transaction_entry",
5881 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5882 "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210",
5883 },
5885 R"({
5886 "method" : "transaction_entry",
5887 "params" : [
5888 {
5889 "api_version" : %API_VER%,
5890 "ledger_hash" : "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210",
5891 "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5892 }
5893 ]
5894 })",
5895 },
5896 {
5897 "transaction_entry: too few arguments.",
5898 __LINE__,
5899 {
5900 "transaction_entry",
5901 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5902 },
5904 R"({
5905 "method" : "transaction_entry",
5906 "params" : [
5907 {
5908 "error" : "badSyntax",
5909 "error_code" : 1,
5910 "error_message" : "Syntax error."
5911 }
5912 ]
5913 })",
5914 },
5915 {
5916 "transaction_entry: too many arguments.",
5917 __LINE__,
5918 {
5919 "transaction_entry",
5920 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5921 "validated",
5922 "extra",
5923 },
5925 R"({
5926 "method" : "transaction_entry",
5927 "params" : [
5928 {
5929 "error" : "badSyntax",
5930 "error_code" : 1,
5931 "error_message" : "Syntax error."
5932 }
5933 ]
5934 })",
5935 },
5936 {
5937 "transaction_entry: short tx_hash.",
5938 __LINE__,
5939 {
5940 "transaction_entry",
5941 "123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5942 "validated",
5943 },
5945 R"({
5946 "method" : "transaction_entry",
5947 "params" : [
5948 {
5949 "error" : "invalidParams",
5950 "error_code" : 31,
5951 "error_message" : "Invalid parameters."
5952 }
5953 ]
5954 })",
5955 },
5956 {
5957 "transaction_entry: long tx_hash.",
5958 __LINE__,
5959 {
5960 "transaction_entry",
5961 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUVW",
5962 "validated",
5963 },
5965 R"({
5966 "method" : "transaction_entry",
5967 "params" : [
5968 {
5969 "error" : "invalidParams",
5970 "error_code" : 31,
5971 "error_message" : "Invalid parameters."
5972 }
5973 ]
5974 })",
5975 },
5976 {
5977 "transaction_entry: small ledger index.",
5978 __LINE__,
5979 {
5980 "transaction_entry",
5981 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5982 "0",
5983 },
5985 R"({
5986 "method" : "transaction_entry",
5987 "params" : [
5988 {
5989 "error" : "invalidParams",
5990 "error_code" : 31,
5991 "error_message" : "Invalid parameters."
5992 }
5993 ]
5994 })",
5995 },
5996 {
5997 "transaction_entry: large ledger index.",
5998 __LINE__,
5999 {
6000 "transaction_entry",
6001 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
6002 "4294967296",
6003 },
6005 R"({
6006 "method" : "transaction_entry",
6007 "params" : [
6008 {
6009 "error" : "invalidParams",
6010 "error_code" : 31,
6011 "error_message" : "Invalid parameters."
6012 }
6013 ]
6014 })",
6015 },
6016 {
6017 "transaction_entry: short ledger hash.",
6018 __LINE__,
6019 {
6020 "transaction_entry",
6021 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
6022 "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA987654321",
6023 },
6025 R"({
6026 "method" : "transaction_entry",
6027 "params" : [
6028 {
6029 "error" : "invalidParams",
6030 "error_code" : 31,
6031 "error_message" : "Invalid parameters."
6032 }
6033 ]
6034 })",
6035 },
6036 {
6037 "transaction_entry: long ledger hash.",
6038 __LINE__,
6039 {
6040 "transaction_entry",
6041 "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
6042 "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210Z",
6043 },
6045 R"({
6046 "method" : "transaction_entry",
6047 "params" : [
6048 {
6049 "error" : "invalidParams",
6050 "error_code" : 31,
6051 "error_message" : "Invalid parameters."
6052 }
6053 ]
6054 })",
6055 },
6056
6057 // tx
6058 // --------------------------------------------------------------------------
6059 {
6060 "tx: ctid. minimal",
6061 __LINE__,
6062 {"tx", "FFFFFFFFFFFFFFFF", "1", "2"},
6064 R"({
6065 "method" : "tx",
6066 "params" : [
6067 {
6068 "api_version" : %API_VER%,
6069 "ctid" : "FFFFFFFFFFFFFFFF",
6070 "max_ledger" : "2",
6071 "min_ledger" : "1"
6072 }
6073 ]
6074 })",
6075 },
6076 {
6077 "tx: ctid. binary",
6078 __LINE__,
6079 {"tx", "FFFFFFFFFFFFFFFF", "binary", "1", "2"},
6081 R"({
6082 "method" : "tx",
6083 "params" : [
6084 {
6085 "api_version" : %API_VER%,
6086 "binary" : true,
6087 "ctid" : "FFFFFFFFFFFFFFFF",
6088 "max_ledger" : "2",
6089 "min_ledger" : "1"
6090 }
6091 ]
6092 })",
6093 },
6094 {
6095 "tx: minimal.",
6096 __LINE__,
6097 {"tx", "transaction_hash_is_not_validated"},
6099 R"({
6100 "method" : "tx",
6101 "params" : [
6102 {
6103 "api_version" : %API_VER%,
6104 "transaction" : "transaction_hash_is_not_validated"
6105 }
6106 ]
6107 })",
6108 },
6109 {
6110 "tx: binary.",
6111 __LINE__,
6112 {"tx", "transaction_hash_is_not_validated", "binary"},
6114 R"({
6115 "method" : "tx",
6116 "params" : [
6117 {
6118 "api_version" : %API_VER%,
6119 "binary" : true,
6120 "transaction" : "transaction_hash_is_not_validated"
6121 }
6122 ]
6123 })",
6124 },
6125 {
6126 "tx: too few arguments.",
6127 __LINE__,
6128 {
6129 "tx",
6130 },
6132 R"({
6133 "method" : "tx",
6134 "params" : [
6135 {
6136 "error" : "badSyntax",
6137 "error_code" : 1,
6138 "error_message" : "Syntax error."
6139 }
6140 ]
6141 })",
6142 },
6143 {
6144 "tx: too many arguments.",
6145 __LINE__,
6146 {"tx", "transaction_hash_is_not_validated", "binary", "1", "2", "extra"},
6148 R"({
6149 "method" : "tx",
6150 "params" : [
6151 {
6152 "error" : "badSyntax",
6153 "error_code" : 1,
6154 "error_message" : "Syntax error."
6155 }
6156 ]
6157 })",
6158 },
6159 {
6160 "tx: invalid final argument is apparently ignored.",
6161 __LINE__,
6162 {"tx", "transaction_hash_is_not_validated", "bin"},
6164 R"({
6165 "method" : "tx",
6166 "params" : [
6167 {
6168 "api_version" : %API_VER%,
6169 "transaction" : "transaction_hash_is_not_validated"
6170 }
6171 ]
6172 })",
6173 },
6174
6175 // tx_history
6176 // ------------------------------------------------------------------
6177 {
6178 "tx_history: minimal.",
6179 __LINE__,
6180 {"tx_history", "0"},
6182 R"({
6183 "method" : "tx_history",
6184 "params" : [
6185 {
6186 "api_version" : %API_VER%,
6187 "start" : 0
6188 }
6189 ]
6190 })",
6191 },
6192 {
6193 "tx_history: too few arguments.",
6194 __LINE__,
6195 {
6196 "tx_history",
6197 },
6199 R"({
6200 "method" : "tx_history",
6201 "params" : [
6202 {
6203 "error" : "badSyntax",
6204 "error_code" : 1,
6205 "error_message" : "Syntax error."
6206 }
6207 ]
6208 })",
6209 },
6210 {
6211 "tx_history: too many arguments.",
6212 __LINE__,
6213 {"tx_history", "0", "1"},
6215 R"({
6216 "method" : "tx_history",
6217 "params" : [
6218 {
6219 "error" : "badSyntax",
6220 "error_code" : 1,
6221 "error_message" : "Syntax error."
6222 }
6223 ]
6224 })",
6225 },
6226 {
6227 // Note: this really shouldn't throw, but does at the moment.
6228 "tx_history: start too small.",
6229 __LINE__,
6230 {"tx_history", "-1"},
6232 R"()",
6233 },
6234 {
6235 // Note: this really shouldn't throw, but does at the moment.
6236 "tx_history: start too big.",
6237 __LINE__,
6238 {"tx_history", "4294967296"},
6240 R"()",
6241 },
6242 {
6243 // Note: this really shouldn't throw, but does at the moment.
6244 "tx_history: start not integer.",
6245 __LINE__,
6246 {"tx_history", "beginning"},
6248 R"()",
6249 },
6250
6251 // unl_list
6252 // --------------------------------------------------------------------
6253 {
6254 "unl_list: minimal.",
6255 __LINE__,
6256 {
6257 "unl_list",
6258 },
6260 R"({
6261 "method" : "unl_list",
6262 "params" : [
6263 {
6264 "api_version" : %API_VER%,
6265 }
6266 ]
6267 })",
6268 },
6269 {
6270 "unl_list: too many arguments.",
6271 __LINE__,
6272 {"unl_list", "extra"},
6274 R"({
6275 "method" : "unl_list",
6276 "params" : [
6277 {
6278 "error" : "badSyntax",
6279 "error_code" : 1,
6280 "error_message" : "Syntax error."
6281 }
6282 ]
6283 })",
6284 },
6285
6286 // validation_create
6287 // -----------------------------------------------------------
6288 {
6289 "validation_create: minimal.",
6290 __LINE__,
6291 {
6292 "validation_create",
6293 },
6295 R"({
6296 "method" : "validation_create",
6297 "params" : [
6298 {
6299 "api_version" : %API_VER%,
6300 }
6301 ]
6302 })",
6303 },
6304 {
6305 "validation_create: with secret.",
6306 __LINE__,
6307 {"validation_create", "the form of the secret is not validated"},
6309 R"({
6310 "method" : "validation_create",
6311 "params" : [
6312 {
6313 "api_version" : %API_VER%,
6314 "secret" : "the form of the secret is not validated"
6315 }
6316 ]
6317 })",
6318 },
6319 {
6320 "validation_create: too many arguments.",
6321 __LINE__,
6322 {"validation_create", "the form of the secret is not validated", "extra"},
6324 R"({
6325 "method" : "validation_create",
6326 "params" : [
6327 {
6328 "error" : "badSyntax",
6329 "error_code" : 1,
6330 "error_message" : "Syntax error."
6331 }
6332 ]
6333 })",
6334 },
6335
6336 // version
6337 // ---------------------------------------------------------------------
6338 {
6339 "version: minimal.",
6340 __LINE__,
6341 {
6342 "version",
6343 },
6345 R"({
6346 "method" : "version",
6347 "params" : [
6348 {
6349 "api_version" : %API_VER%,
6350 }
6351 ]
6352 })",
6353 },
6354 {
6355 "version: too many arguments.",
6356 __LINE__,
6357 {"version", "extra"},
6359 R"({
6360 "method" : "version",
6361 "params" : [
6362 {
6363 "error" : "badSyntax",
6364 "error_code" : 1,
6365 "error_message" : "Syntax error."
6366 }
6367 ]
6368 })",
6369 },
6370
6371 // wallet_propose
6372 // --------------------------------------------------------------
6373 {
6374 "wallet_propose: minimal.",
6375 __LINE__,
6376 {
6377 "wallet_propose",
6378 },
6380 R"({
6381 "method" : "wallet_propose",
6382 "params" : [
6383 {
6384 "api_version" : %API_VER%,
6385 }
6386 ]
6387 })",
6388 },
6389 {
6390 "wallet_propose: with passphrase.",
6391 __LINE__,
6392 {"wallet_propose", "the form of the passphrase is not validated"},
6394 R"({
6395 "method" : "wallet_propose",
6396 "params" : [
6397 {
6398 "api_version" : %API_VER%,
6399 "passphrase" : "the form of the passphrase is not validated"
6400 }
6401 ]
6402 })",
6403 },
6404 {
6405 "wallet_propose: too many arguments.",
6406 __LINE__,
6407 {"wallet_propose", "the form of the passphrase is not validated", "extra"},
6409 R"({
6410 "method" : "wallet_propose",
6411 "params" : [
6412 {
6413 "error" : "badSyntax",
6414 "error_code" : 1,
6415 "error_message" : "Syntax error."
6416 }
6417 ]
6418 })",
6419 },
6420
6421 // internal
6422 // --------------------------------------------------------------------
6423 {
6424 "internal: minimal.",
6425 __LINE__,
6426 {"internal", "command_name"},
6428 R"({
6429 "method" : "internal",
6430 "params" : [
6431 {
6432 "api_version" : %API_VER%,
6433 "internal_command" : "command_name",
6434 "params" : []
6435 }
6436 ]
6437 })",
6438 },
6439 {
6440 "internal: with parameters.",
6441 __LINE__,
6442 {"internal", "command_name", "string_arg", "1", "-1", "4294967296", "3.14159"},
6444 R"({
6445 "method" : "internal",
6446 "params" : [
6447 {
6448 "api_version" : %API_VER%,
6449 "internal_command" : "command_name",
6450 "params" : [ "string_arg", "1", "-1", "4294967296", "3.14159" ]
6451 }
6452 ]
6453 })",
6454 },
6455 {
6456 "internal: too few arguments.",
6457 __LINE__,
6458 {
6459 "internal",
6460 },
6462 R"({
6463 "method" : "internal",
6464 "params" : [
6465 {
6466 "error" : "badSyntax",
6467 "error_code" : 1,
6468 "error_message" : "Syntax error."
6469 }
6470 ]
6471 })",
6472 },
6473
6474 // path_find
6475 // -------------------------------------------------------------------
6476 {
6477 "path_find: minimal.",
6478 __LINE__,
6479 {
6480 "path_find",
6481 },
6483 R"({
6484 "method" : "path_find",
6485 "params" : [
6486 {
6487 "error" : "noEvents",
6488 "error_code" : 7,
6489 "error_message" : "Current transport does not support events."
6490 }
6491 ]
6492 })",
6493 },
6494 {
6495 "path_find: with arguments.",
6496 __LINE__,
6497 {"path_find", "string_arg", "1", "-1", "4294967296", "3.14159"},
6499 R"({
6500 "method" : "path_find",
6501 "params" : [
6502 {
6503 "error" : "noEvents",
6504 "error_code" : 7,
6505 "error_message" : "Current transport does not support events."
6506 }
6507 ]
6508 })",
6509 },
6510
6511 // subscribe
6512 // -------------------------------------------------------------------
6513 {
6514 "subscribe: minimal.",
6515 __LINE__,
6516 {
6517 "subscribe",
6518 },
6520 R"({
6521 "method" : "subscribe",
6522 "params" : [
6523 {
6524 "error" : "noEvents",
6525 "error_code" : 7,
6526 "error_message" : "Current transport does not support events."
6527 }
6528 ]
6529 })",
6530 },
6531 {
6532 "subscribe: with arguments.",
6533 __LINE__,
6534 {"subscribe", "string_arg", "1", "-1", "4294967296", "3.14159"},
6536 R"({
6537 "method" : "subscribe",
6538 "params" : [
6539 {
6540 "error" : "noEvents",
6541 "error_code" : 7,
6542 "error_message" : "Current transport does not support events."
6543 }
6544 ]
6545 })",
6546 },
6547
6548 // unsubscribe
6549 // -----------------------------------------------------------------
6550 {
6551 "unsubscribe: minimal.",
6552 __LINE__,
6553 {
6554 "unsubscribe",
6555 },
6557 R"({
6558 "method" : "unsubscribe",
6559 "params" : [
6560 {
6561 "error" : "noEvents",
6562 "error_code" : 7,
6563 "error_message" : "Current transport does not support events."
6564 }
6565 ]
6566 })",
6567 },
6568 {
6569 "unsubscribe: with arguments.",
6570 __LINE__,
6571 {"unsubscribe", "string_arg", "1", "-1", "4294967296", "3.14159"},
6573 R"({
6574 "method" : "unsubscribe",
6575 "params" : [
6576 {
6577 "error" : "noEvents",
6578 "error_code" : 7,
6579 "error_message" : "Current transport does not support events."
6580 }
6581 ]
6582 })",
6583 },
6584
6585 // unknown_command
6586 // -------------------------------------------------------------
6587 {
6588 "unknown_command: minimal.",
6589 __LINE__,
6590 {
6591 "unknown_command",
6592 },
6594 R"({
6595 "method" : "unknown_command",
6596 "params" : [
6597 {
6598 "api_version" : %API_VER%,
6599 }
6600 ]
6601 })",
6602 },
6603 {
6604 "unknown_command: with arguments.",
6605 __LINE__,
6606 {"unknown_command", "string_arg", "1", "-1", "4294967296", "3.14159"},
6608 R"({
6609 "method" : "unknown_command",
6610 "params" : [
6611 {
6612 "api_version" : %API_VER%,
6613 "params" : [ "string_arg", "1", "-1", "4294967296", "3.14159" ]
6614 }
6615 ]
6616 })",
6617 },
6618};
6619
6621updateAPIVersionString(char const* const req, unsigned apiVersion)
6622{
6623 std::string const versionStr = std::to_string(apiVersion);
6624 static auto const kPlaceHolder = "%API_VER%";
6625 std::string jr(req);
6626 boost::replace_all(jr, kPlaceHolder, versionStr);
6627 return jr;
6628}
6629
6631makeNetworkConfig(uint32_t networkID)
6632{
6633 using namespace test::jtx;
6634 return envconfig([&](std::unique_ptr<Config> cfg) {
6635 cfg->networkId = networkID;
6636 return cfg;
6637 });
6638}
6639
6641{
6642public:
6643 void
6644 testRPCCall(unsigned apiVersion)
6645 {
6646 testcase << "RPCCall API version " << apiVersion;
6647 if (!BEAST_EXPECT(
6648 apiVersion >= rpc::kApiMinimumSupportedVersion &&
6649 apiVersion <= rpc::kApiMaximumValidVersion))
6650 return;
6651
6652 test::jtx::Env const env(*this, makeNetworkConfig(11111)); // Used only for its Journal.
6653
6654 // For each RPCCall test.
6655 for (RPCCallTestData const& rpcCallTest : kRpcCallTestArray)
6656 {
6657 if (!BEAST_EXPECT(!rpcCallTest.exp.empty()))
6658 break;
6659
6660 std::vector<std::string> const args{rpcCallTest.args.begin(), rpcCallTest.args.end()};
6661
6662 char const* const expVersioned =
6663 (apiVersion - rpc::kApiMinimumSupportedVersion) < rpcCallTest.exp.size()
6664 ? rpcCallTest.exp[apiVersion - rpc::kApiMinimumSupportedVersion]
6665 : rpcCallTest.exp.back();
6666
6667 // Note that, over the long term, kNone of these tests should
6668 // throw. But, for the moment, some of them do. So handle it.
6669 json::Value got;
6670 try
6671 {
6672 got = jtx::cmdToJSONRPC(args, env.journal, apiVersion);
6673 }
6674 catch (std::bad_cast const&)
6675 {
6676 if ((rpcCallTest.throwsWhat == RPCCallTestData::Exception::BadCast) &&
6677 (std::strlen(expVersioned) == 0))
6678 {
6679 pass();
6680 }
6681 else
6682 {
6683 fail(rpcCallTest.description, __FILE__, rpcCallTest.line);
6684 }
6685 // Try the next test.
6686 continue;
6687 }
6688
6689 json::Value exp;
6690 json::Reader{}.parse(updateAPIVersionString(expVersioned, apiVersion), exp);
6691
6692 // Lambda to remove the "params[0u]:error_code" field if present.
6693 // Error codes are not expected to be stable between releases.
6694 auto const rmErrorCode = [](json::Value& json) {
6695 if (json.isMember(jss::params) && json[jss::params].isArray() &&
6696 json[jss::params].size() > 0 && json[jss::params][0u].isObject())
6697 {
6698 json[jss::params][0u].removeMember(jss::error_code);
6699 }
6700 };
6701 rmErrorCode(got);
6702 rmErrorCode(exp);
6703
6704 // Pass if we didn't expect a throw and we got what we expected.
6705 if ((rpcCallTest.throwsWhat == RPCCallTestData::Exception::NoException) && (got == exp))
6706 {
6707 pass();
6708 }
6709 else
6710 {
6711 fail(rpcCallTest.description, __FILE__, rpcCallTest.line);
6712 }
6713 }
6714 }
6715
6716 // The command-line table and the dispatch table must agree.
6717 //
6718 // Forwards: every name the command line accepts must reach a handler at the
6719 // version the command-line client requests. Presence in the dispatch table is
6720 // not enough: a handler whose API range excludes kApiCommandLineVersion parses
6721 // the command and then answers RpcUnknownCommand.
6722 //
6723 // Backwards: a handler that claims a command-line form must have one, and
6724 // one that denies it must not, so that Handler::hasCommandLineForm cannot go
6725 // stale.
6726 //
6727 // Three command-line names are exempt from the forward check because they
6728 // are wrappers that forward a caller-supplied method rather than naming one
6729 // themselves, so they have no handler of their own.
6730 void
6732 {
6733 testcase("Command-line and dispatch tables agree");
6734
6735 static constexpr std::array kWrappers{
6739 };
6740
6741 auto const commandLine = commandLineMethodNames();
6742 auto const handlers = rpc::getHandlerNames();
6743 BEAST_EXPECT(!commandLine.empty());
6744 BEAST_EXPECT(!handlers.empty());
6745
6746 // The command-line client always requests this version, so this is the
6747 // only version at which its commands have to be dispatchable. Beta
6748 // methods are off: a command must work against a stock server.
6749 auto const handlerFor = [](std::string_view name) {
6750 return rpc::getHandler(rpc::kApiCommandLineVersion, false, name);
6751 };
6752
6753 for (auto const& name : commandLine)
6754 {
6755 if (std::ranges::find(kWrappers, name) != kWrappers.end())
6756 continue;
6757
6758 auto const* handler = handlerFor(name);
6759 if (BEAST_EXPECTS(handler != nullptr, std::string{name}))
6760 BEAST_EXPECTS(handler->hasCommandLineForm, std::string{name});
6761 }
6762
6763 for (auto const& name : handlers)
6764 {
6765 auto const* handler = handlerFor(name);
6766 bool const claimsCommandLine = handler != nullptr && handler->hasCommandLineForm;
6767
6768 // Both name lists are sorted, so a binary search suffices.
6769 BEAST_EXPECTS(
6770 claimsCommandLine == std::ranges::binary_search(commandLine, name.view()),
6771 std::string{name});
6772 }
6773 }
6774
6775 void
6776 run() override
6777 {
6778 forAllApiVersions([this](unsigned apiVersion) { testRPCCall(apiVersion); });
6780 }
6781};
6782
6784
6785} // namespace xrpl::test
T binary_search(T... args)
A testsuite class.
Definition suite.h:52
void pass()
Record a successful test condition.
Definition suite.h:532
void fail(String const &reason, char const *file, int line)
Record a failure.
Definition suite.h:554
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
Unserialize a JSON document into a Value.
Definition json_reader.h:20
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Represents a JSON value.
Definition json_value.h:121
void run() override
Runs the suite.
void testRPCCall(unsigned apiVersion)
A transaction testing environment.
Definition Env.h:161
beast::Journal const journal
Definition Env.h:204
T end(T... args)
T find(T... args)
JSON (JavaScript Object Notation).
Definition json_errors.h:5
constexpr std::string_view kInternal
Definition MethodNames.h:43
constexpr std::string_view kJson2
Definition MethodNames.h:45
constexpr std::string_view kJson
Definition MethodNames.h:44
The api_version numbers this server serves.
Definition ApiVersion.h:26
std::span< NullTerminatedView const > getHandlerNames()
Return the names of all methods, sorted and without duplicates.
Definition Handler.cpp:657
Handler const * getHandler(unsigned version, bool betaEnabled, std::string_view name)
Definition Handler.cpp:638
static constexpr auto kApiMaximumValidVersion
Definition ApiVersion.h:37
static constexpr auto kApiMinimumSupportedVersion
Definition ApiVersion.h:32
static constexpr auto kApiCommandLineVersion
Definition ApiVersion.h:35
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:38
json::Value cmdToJSONRPC(std::vector< std::string > const &args, beast::Journal j, unsigned int apiVersion)
Given an xrpld unit test rpc command, return the corresponding JSON.
Definition utility.cpp:107
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
std::unique_ptr< Config > makeNetworkConfig(uint32_t networkID)
std::string updateAPIVersionString(char const *const req, unsigned apiVersion)
static RPCCallTestData const kRpcCallTestArray[]
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:159
std::span< std::string_view const > commandLineMethodNames()
Return the names of all methods accepted on the command line.
Definition RPCCall.cpp:1920
T size(T... args)
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, char const *exp)
RPCCallTestData(char const *description, int line, std::initializer_list< char const * > const &args, Exception throwsWhat, std::initializer_list< 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)