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