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