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