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