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"},
1440  R"({
1441  "method" : "account_tx",
1442  "params" : [
1443  {
1444  "error" : "lgrIdxsInvalid",
1445  "error_code" : 55,
1446  "error_message" : "Ledger indexes invalid."
1447  }
1448  ]
1449  })",
1450  },
1451  {
1452  // Note: this really shouldn't throw, but does at the moment.
1453  "account_tx: non-integer min.",
1454  __LINE__,
1455  {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Binary", "-1"},
1457  R"()",
1458  },
1459  {
1460  // Note: this really shouldn't throw, but does at the moment.
1461  "account_tx: non-integer max.",
1462  __LINE__,
1463  {"account_tx", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "counts"},
1465  R"()",
1466  },
1467  {
1468  // Note: this really shouldn't throw, but does at the moment.
1469  "account_tx: non-integer offset.",
1470  __LINE__,
1471  {"account_tx",
1472  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1473  "-1",
1474  "-1",
1475  "decending"},
1477  R"()",
1478  },
1479  {
1480  // Note: this really shouldn't throw, but does at the moment.
1481  "account_tx: non-integer limit.",
1482  __LINE__,
1483  {"account_tx",
1484  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1485  "-1",
1486  "-1",
1487  "300",
1488  "false"},
1490  R"()",
1491  },
1492  {// Note: this really shouldn't throw, but does at the moment.
1493  "account_tx: RIPD-1570.",
1494  __LINE__,
1495  {"account_tx",
1496  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1497  "-1",
1498  "-1",
1499  "2",
1500  "false",
1501  "false",
1502  "false"},
1504  R"()"},
1505 
1506  // book_offers
1507  // -----------------------------------------------------------------
1508  {"book_offers: minimal no issuer.",
1509  __LINE__,
1510  {
1511  "book_offers",
1512  "USD",
1513  "EUR",
1514  },
1516  R"({
1517  "method" : "book_offers",
1518  "params" : [
1519  {
1520  "api_version" : %MAX_API_VER%,
1521  "taker_gets" : {
1522  "currency" : "EUR"
1523  },
1524  "taker_pays" : {
1525  "currency" : "USD"
1526  }
1527  }
1528  ]
1529  })"},
1530  {"book_offers: minimal with currency/issuer",
1531  __LINE__,
1532  {
1533  "book_offers",
1534  "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1535  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1536  },
1538  R"({
1539  "method" : "book_offers",
1540  "params" : [
1541  {
1542  "api_version" : %MAX_API_VER%,
1543  "taker_gets" : {
1544  "currency" : "EUR",
1545  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1546  },
1547  "taker_pays" : {
1548  "currency" : "USD",
1549  "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1550  }
1551  }
1552  ]
1553  })"},
1554  {// Note: documentation suggests that "issuer" is the wrong type.
1555  // Should it be "taker" instead?
1556  "book_offers: add issuer.",
1557  __LINE__,
1558  {"book_offers", "USD", "EUR", "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"},
1560  R"({
1561  "method" : "book_offers",
1562  "params" : [
1563  {
1564  "api_version" : %MAX_API_VER%,
1565  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1566  "taker_gets" : {
1567  "currency" : "EUR"
1568  },
1569  "taker_pays" : {
1570  "currency" : "USD"
1571  }
1572  }
1573  ]
1574  })"},
1575  {"book_offers: add issuer and numeric ledger index.",
1576  __LINE__,
1577  {"book_offers",
1578  "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1579  "EUR",
1580  "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1581  "666"},
1583  R"({
1584  "method" : "book_offers",
1585  "params" : [
1586  {
1587  "api_version" : %MAX_API_VER%,
1588  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1589  "ledger_index" : 666,
1590  "taker_gets" : {
1591  "currency" : "EUR"
1592  },
1593  "taker_pays" : {
1594  "currency" : "USD",
1595  "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1596  }
1597  }
1598  ]
1599  })"},
1600  {"book_offers: add issuer and text ledger index.",
1601  __LINE__,
1602  {"book_offers",
1603  "USD",
1604  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1605  "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1606  "current"},
1608  R"({
1609  "method" : "book_offers",
1610  "params" : [
1611  {
1612  "api_version" : %MAX_API_VER%,
1613  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1614  "ledger_index" : "current",
1615  "taker_gets" : {
1616  "currency" : "EUR",
1617  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1618  },
1619  "taker_pays" : {
1620  "currency" : "USD"
1621  }
1622  }
1623  ]
1624  })"},
1625  {"book_offers: add issuer and ledger hash.",
1626  __LINE__,
1627  {"book_offers",
1628  "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1629  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1630  "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1631  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
1633  R"({
1634  "method" : "book_offers",
1635  "params" : [
1636  {
1637  "api_version" : %MAX_API_VER%,
1638  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1639  "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1640  "taker_gets" : {
1641  "currency" : "EUR",
1642  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1643  },
1644  "taker_pays" : {
1645  "currency" : "USD",
1646  "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1647  }
1648  }
1649  ]
1650  })"},
1651  {"book_offers: issuer, ledger hash, and limit.",
1652  __LINE__,
1653  {
1654  "book_offers",
1655  "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1656  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1657  "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1658  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1659  "junk", // Note: indexing bug in parseBookOffers() requires junk
1660  // param.
1661  "200",
1662  },
1664  R"({
1665  "method" : "book_offers",
1666  "params" : [
1667  {
1668  "api_version" : %MAX_API_VER%,
1669  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1670  "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1671  "limit" : 200,
1672  "proof" : true,
1673  "taker_gets" : {
1674  "currency" : "EUR",
1675  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1676  },
1677  "taker_pays" : {
1678  "currency" : "USD",
1679  "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1680  }
1681  }
1682  ]
1683  })"},
1684  {// Note: parser supports "marker", but the docs don't cover it.
1685  "book_offers: issuer, ledger hash, limit, and marker.",
1686  __LINE__,
1687  {"book_offers",
1688  "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1689  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1690  "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1691  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1692  "junk", // Note: indexing bug in parseBookOffers() requires junk param.
1693  "200",
1694  "MyMarker"},
1696  R"({
1697  "method" : "book_offers",
1698  "params" : [
1699  {
1700  "api_version" : %MAX_API_VER%,
1701  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1702  "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1703  "limit" : 200,
1704  "marker" : "MyMarker",
1705  "proof" : true,
1706  "taker_gets" : {
1707  "currency" : "EUR",
1708  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1709  },
1710  "taker_pays" : {
1711  "currency" : "USD",
1712  "issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
1713  }
1714  }
1715  ]
1716  })"},
1717  {"book_offers: too few arguments.",
1718  __LINE__,
1719  {
1720  "book_offers",
1721  },
1723  R"({
1724  "method" : "book_offers",
1725  "params" : [
1726  {
1727  "error" : "badSyntax",
1728  "error_code" : 1,
1729  "error_message" : "Syntax error."
1730  }
1731  ]
1732  })"},
1733  {"book_offers: too many arguments.",
1734  __LINE__,
1735  {"book_offers",
1736  "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1737  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1738  "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1739  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1740  "junk", // Note: indexing bug in parseBookOffers() requires junk param.
1741  "200",
1742  "MyMarker",
1743  "extra"},
1745  R"({
1746  "method" : "book_offers",
1747  "params" : [
1748  {
1749  "error" : "badSyntax",
1750  "error_code" : 1,
1751  "error_message" : "Syntax error."
1752  }
1753  ]
1754  })"},
1755 
1756  {"book_offers: taker pays no currency.",
1757  __LINE__,
1758  {
1759  "book_offers",
1760  "/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1761  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1762  },
1764  R"({
1765  "method" : "book_offers",
1766  "params" : [
1767  {
1768  "error" : "invalidParams",
1769  "error_code" : 31,
1770  "error_message" : "Invalid currency/issuer '/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'"
1771  }
1772  ]
1773  })"},
1774  {"book_offers: taker gets no currency.",
1775  __LINE__,
1776  {
1777  "book_offers",
1778  "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1779  "/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1780  },
1782  R"({
1783  "method" : "book_offers",
1784  "params" : [
1785  {
1786  "error" : "invalidParams",
1787  "error_code" : 31,
1788  "error_message" : "Invalid currency/issuer '/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA'"
1789  }
1790  ]
1791  })"},
1792  {"book_offers: invalid issuer.",
1793  __LINE__,
1794  {"book_offers", "USD", "EUR", "not_a_valid_issuer"},
1796  R"({
1797  "method" : "book_offers",
1798  "params" : [
1799  {
1800  "api_version" : %MAX_API_VER%,
1801  "issuer" : "not_a_valid_issuer",
1802  "taker_gets" : {
1803  "currency" : "EUR"
1804  },
1805  "taker_pays" : {
1806  "currency" : "USD"
1807  }
1808  }
1809  ]
1810  })"},
1811  {"book_offers: invalid text ledger index.",
1812  __LINE__,
1813  {"book_offers",
1814  "USD",
1815  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1816  "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1817  "not_a_ledger"},
1819  R"({
1820  "method" : "book_offers",
1821  "params" : [
1822  {
1823  "api_version" : %MAX_API_VER%,
1824  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1825  "ledger_index" : 0,
1826  "taker_gets" : {
1827  "currency" : "EUR",
1828  "issuer" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
1829  },
1830  "taker_pays" : {
1831  "currency" : "USD"
1832  }
1833  }
1834  ]
1835  })"},
1836  {// Note: this really shouldn't throw, but does at the moment.
1837  "book_offers: non-numeric limit.",
1838  __LINE__,
1839  {
1840  "book_offers",
1841  "USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1842  "EUR/rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1843  "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1844  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
1845  "junk", // Note: indexing bug in parseBookOffers() requires junk
1846  // param.
1847  "not_a_number",
1848  },
1850  R"()"},
1851 
1852  // can_delete
1853  // ------------------------------------------------------------------
1854  {"can_delete: minimal.",
1855  __LINE__,
1856  {
1857  "can_delete",
1858  },
1860  R"({
1861  "method" : "can_delete",
1862  "params" : [
1863  {
1864  "api_version" : %MAX_API_VER%,
1865  }
1866  ]
1867  })"},
1868  {"can_delete: ledger index.",
1869  __LINE__,
1870  {
1871  "can_delete",
1872  "4294967295",
1873  },
1875  R"({
1876  "method" : "can_delete",
1877  "params" : [
1878  {
1879  "api_version" : %MAX_API_VER%,
1880  "can_delete" : 4294967295
1881  }
1882  ]
1883  })"},
1884  {"can_delete: ledger hash.",
1885  __LINE__,
1886  {
1887  "can_delete",
1888  "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210",
1889  },
1891  R"({
1892  "method" : "can_delete",
1893  "params" : [
1894  {
1895  "api_version" : %MAX_API_VER%,
1896  "can_delete" : "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210"
1897  }
1898  ]
1899  })"},
1900  {"can_delete: always.",
1901  __LINE__,
1902  {
1903  "can_delete",
1904  "always",
1905  },
1907  R"({
1908  "method" : "can_delete",
1909  "params" : [
1910  {
1911  "api_version" : %MAX_API_VER%,
1912  "can_delete" : "always"
1913  }
1914  ]
1915  })"},
1916  {"can_delete: never.",
1917  __LINE__,
1918  {
1919  "can_delete",
1920  "never",
1921  },
1923  R"({
1924  "method" : "can_delete",
1925  "params" : [
1926  {
1927  "api_version" : %MAX_API_VER%,
1928  "can_delete" : "never"
1929  }
1930  ]
1931  })"},
1932  {"can_delete: now.",
1933  __LINE__,
1934  {
1935  "can_delete",
1936  "now",
1937  },
1939  R"({
1940  "method" : "can_delete",
1941  "params" : [
1942  {
1943  "api_version" : %MAX_API_VER%,
1944  "can_delete" : "now"
1945  }
1946  ]
1947  })"},
1948  {"can_delete: too many arguments.",
1949  __LINE__,
1950  {"can_delete", "always", "never"},
1952  R"({
1953  "method" : "can_delete",
1954  "params" : [
1955  {
1956  "error" : "badSyntax",
1957  "error_code" : 1,
1958  "error_message" : "Syntax error."
1959  }
1960  ]
1961  })"},
1962  {"can_delete: invalid argument.",
1963  __LINE__,
1964  {"can_delete", "invalid"},
1966  R"({
1967  "method" : "can_delete",
1968  "params" : [
1969  {
1970  "api_version" : %MAX_API_VER%,
1971  "can_delete" : "invalid"
1972  }
1973  ]
1974  })"},
1975  {// Note: this should return an error but not throw.
1976  "can_delete: ledger index > 32 bits.",
1977  __LINE__,
1978  {
1979  "can_delete",
1980  "4294967296",
1981  },
1983  R"()"},
1984  {// Note: this really shouldn't throw since it's a legitimate ledger hash.
1985  "can_delete: ledger hash with no alphas.",
1986  __LINE__,
1987  {
1988  "can_delete",
1989  "0123456701234567012345670123456701234567012345670123456701234567",
1990  },
1992  R"()"},
1993 
1994  // channel_authorize
1995  // -----------------------------------------------------------
1996  {"channel_authorize: minimal.",
1997  __LINE__,
1998  {"channel_authorize",
1999  "secret_can_be_anything",
2000  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2001  "18446744073709551615"},
2003  R"({
2004  "method" : "channel_authorize",
2005  "params" : [
2006  {
2007  "api_version" : %MAX_API_VER%,
2008  "amount" : "18446744073709551615",
2009  "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2010  "secret" : "secret_can_be_anything"
2011  }
2012  ]
2013  })"},
2014  {"channel_authorize: too few arguments.",
2015  __LINE__,
2016  {
2017  "channel_authorize",
2018  "secret_can_be_anything",
2019  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2020  },
2022  R"({
2023  "method" : "channel_authorize",
2024  "params" : [
2025  {
2026  "error" : "badSyntax",
2027  "error_code" : 1,
2028  "error_message" : "Syntax error."
2029  }
2030  ]
2031  })"},
2032  {"channel_authorize: too many arguments.",
2033  __LINE__,
2034  {"channel_authorize",
2035  "secp256k1",
2036  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2037  "2000",
2038  "whatever",
2039  "whenever"},
2041  R"({
2042  "method" : "channel_authorize",
2043  "params" : [
2044  {
2045  "error" : "badSyntax",
2046  "error_code" : 1,
2047  "error_message" : "Syntax error."
2048  }
2049  ]
2050  })"},
2051  {"channel_authorize: bad key type.",
2052  __LINE__,
2053  {"channel_authorize",
2054  "secp257k1",
2055  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2056  "2000",
2057  "whatever"},
2059  R"({
2060  "method" : "channel_authorize",
2061  "params" : [
2062  {
2063  "error" : "badKeyType",
2064  "error_code" : 1,
2065  "error_message" : "Bad key type."
2066  }
2067  ]
2068  })"},
2069  {"channel_authorize: channel_id too short.",
2070  __LINE__,
2071  {"channel_authorize",
2072  "secret_can_be_anything",
2073  "123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2074  "2000"},
2076  R"({
2077  "method" : "channel_authorize",
2078  "params" : [
2079  {
2080  "error" : "channelMalformed",
2081  "error_code" : 43,
2082  "error_message" : "Payment channel is malformed."
2083  }
2084  ]
2085  })"},
2086  {"channel_authorize: channel_id too long.",
2087  __LINE__,
2088  {"channel_authorize",
2089  "secret_can_be_anything",
2090  "10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2091  "2000"},
2093  R"({
2094  "method" : "channel_authorize",
2095  "params" : [
2096  {
2097  "error" : "channelMalformed",
2098  "error_code" : 43,
2099  "error_message" : "Payment channel is malformed."
2100  }
2101  ]
2102  })"},
2103  {"channel_authorize: channel_id not hex.",
2104  __LINE__,
2105  {"channel_authorize",
2106  "secret_can_be_anything",
2107  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEZ",
2108  "2000"},
2110  R"({
2111  "method" : "channel_authorize",
2112  "params" : [
2113  {
2114  "error" : "channelMalformed",
2115  "error_code" : 43,
2116  "error_message" : "Payment channel is malformed."
2117  }
2118  ]
2119  })"},
2120  {"channel_authorize: negative amount.",
2121  __LINE__,
2122  {"channel_authorize",
2123  "secret_can_be_anything",
2124  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2125  "-1"},
2127  R"({
2128  "method" : "channel_authorize",
2129  "params" : [
2130  {
2131  "error" : "channelAmtMalformed",
2132  "error_code" : 44,
2133  "error_message" : "Payment channel amount is malformed."
2134  }
2135  ]
2136  })"},
2137  {"channel_authorize: amount > 64 bits.",
2138  __LINE__,
2139  {"channel_authorize",
2140  "secret_can_be_anything",
2141  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2142  "18446744073709551616"},
2144  R"({
2145  "method" : "channel_authorize",
2146  "params" : [
2147  {
2148  "error" : "channelAmtMalformed",
2149  "error_code" : 44,
2150  "error_message" : "Payment channel amount is malformed."
2151  }
2152  ]
2153  })"},
2154 
2155  // channel_verify
2156  // --------------------------------------------------------------
2157  {"channel_verify: public key.",
2158  __LINE__,
2159  {"channel_verify",
2160  "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2161  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2162  "0",
2163  "DEADBEEF"},
2165  R"({
2166  "method" : "channel_verify",
2167  "params" : [
2168  {
2169  "api_version" : %MAX_API_VER%,
2170  "amount" : "0",
2171  "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2172  "public_key" : "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2173  "signature" : "DEADBEEF"
2174  }
2175  ]
2176  })"},
2177  {"channel_verify: public key hex.",
2178  __LINE__,
2179  {"channel_verify",
2180  "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2181  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2182  "18446744073709551615",
2183  "DEADBEEF"},
2185  R"({
2186  "method" : "channel_verify",
2187  "params" : [
2188  {
2189  "api_version" : %MAX_API_VER%,
2190  "amount" : "18446744073709551615",
2191  "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2192  "public_key" : "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2193  "signature" : "DEADBEEF"
2194  }
2195  ]
2196  })"},
2197  {"channel_verify: too few arguments.",
2198  __LINE__,
2199  {"channel_verify",
2200  "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2201  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
2203  R"({
2204  "method" : "channel_verify",
2205  "params" : [
2206  {
2207  "error" : "badSyntax",
2208  "error_code" : 1,
2209  "error_message" : "Syntax error."
2210  }
2211  ]
2212  })"},
2213  {"channel_verify: too many arguments.",
2214  __LINE__,
2215  {"channel_verify",
2216  "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2217  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2218  "2000",
2219  "DEADBEEF",
2220  "Whatever"},
2222  R"({
2223  "method" : "channel_verify",
2224  "params" : [
2225  {
2226  "error" : "badSyntax",
2227  "error_code" : 1,
2228  "error_message" : "Syntax error."
2229  }
2230  ]
2231  })"},
2232  {"channel_verify: malformed public key.",
2233  __LINE__,
2234  {"channel_verify",
2235  "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9GoV",
2236  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2237  "2000",
2238  "DEADBEEF"},
2240  R"({
2241  "method" : "channel_verify",
2242  "params" : [
2243  {
2244  "error" : "publicMalformed",
2245  "error_code" : 60,
2246  "error_message" : "Public key is malformed."
2247  }
2248  ]
2249  })"},
2250  {"channel_verify: malformed hex public key.",
2251  __LINE__,
2252  {"channel_verify",
2253  "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F",
2254  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2255  "2000",
2256  "DEADBEEF"},
2258  R"({
2259  "method" : "channel_verify",
2260  "params" : [
2261  {
2262  "error" : "publicMalformed",
2263  "error_code" : 60,
2264  "error_message" : "Public key is malformed."
2265  }
2266  ]
2267  })"},
2268  {"channel_verify: invalid channel id.",
2269  __LINE__,
2270  {"channel_verify",
2271  "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2272  "10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2273  "2000",
2274  "DEADBEEF"},
2276  R"({
2277  "method" : "channel_verify",
2278  "params" : [
2279  {
2280  "error" : "channelMalformed",
2281  "error_code" : 43,
2282  "error_message" : "Payment channel is malformed."
2283  }
2284  ]
2285  })"},
2286  {"channel_verify: short channel id.",
2287  __LINE__,
2288  {"channel_verify",
2289  "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2290  "123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2291  "2000",
2292  "DEADBEEF"},
2294  R"({
2295  "method" : "channel_verify",
2296  "params" : [
2297  {
2298  "error" : "channelMalformed",
2299  "error_code" : 43,
2300  "error_message" : "Payment channel is malformed."
2301  }
2302  ]
2303  })"},
2304  {"channel_verify: amount too small.",
2305  __LINE__,
2306  {"channel_verify",
2307  "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2308  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2309  "-1",
2310  "DEADBEEF"},
2312  R"({
2313  "method" : "channel_verify",
2314  "params" : [
2315  {
2316  "error" : "channelAmtMalformed",
2317  "error_code" : 44,
2318  "error_message" : "Payment channel amount is malformed."
2319  }
2320  ]
2321  })"},
2322  {"channel_verify: amount too large.",
2323  __LINE__,
2324  {"channel_verify",
2325  "021D93E21C44160A1B3B66DA1F37B86BE39FFEA3FC4B95FAA2063F82EE823599F6",
2326  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2327  "18446744073709551616",
2328  "DEADBEEF"},
2330  R"({
2331  "method" : "channel_verify",
2332  "params" : [
2333  {
2334  "error" : "channelAmtMalformed",
2335  "error_code" : 44,
2336  "error_message" : "Payment channel amount is malformed."
2337  }
2338  ]
2339  })"},
2340  {"channel_verify: non-hex signature.",
2341  __LINE__,
2342  {"channel_verify",
2343  "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2344  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2345  "40000000",
2346  "ThisIsNotHexadecimal"},
2348  R"({
2349  "method" : "channel_verify",
2350  "params" : [
2351  {
2352  "api_version" : %MAX_API_VER%,
2353  "amount" : "40000000",
2354  "channel_id" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF",
2355  "public_key" : "aB4BXXLuPu8DpVuyq1DBiu3SrPdtK9AYZisKhu8mvkoiUD8J9Gov",
2356  "signature" : "ThisIsNotHexadecimal"
2357  }
2358  ]
2359  })"},
2360 
2361  // connect
2362  // ---------------------------------------------------------------------
2363  {"connect: minimal.",
2364  __LINE__,
2365  {
2366  "connect",
2367  "ThereIsNoCheckingOnTheIPFormat",
2368  },
2370  R"({
2371  "method" : "connect",
2372  "params" : [
2373  {
2374  "api_version" : %MAX_API_VER%,
2375  "ip" : "ThereIsNoCheckingOnTheIPFormat"
2376  }
2377  ]
2378  })"},
2379  {"connect: ip and port.",
2380  __LINE__,
2381  {"connect", "ThereIsNoCheckingOnTheIPFormat", "6561"},
2383  R"({
2384  "method" : "connect",
2385  "params" : [
2386  {
2387  "api_version" : %MAX_API_VER%,
2388  "ip" : "ThereIsNoCheckingOnTheIPFormat",
2389  "port" : 6561
2390  }
2391  ]
2392  })"},
2393  {"connect: too few arguments.",
2394  __LINE__,
2395  {
2396  "connect",
2397  },
2399  R"({
2400  "method" : "connect",
2401  "params" : [
2402  {
2403  "error" : "badSyntax",
2404  "error_code" : 1,
2405  "error_message" : "Syntax error."
2406  }
2407  ]
2408  })"},
2409  {"connect: too many arguments.",
2410  __LINE__,
2411  {"connect", "ThereIsNoCheckingOnTheIPFormat", "6561", "extra"},
2413  R"({
2414  "method" : "connect",
2415  "params" : [
2416  {
2417  "error" : "badSyntax",
2418  "error_code" : 1,
2419  "error_message" : "Syntax error."
2420  }
2421  ]
2422  })"},
2423  {// Note: this should return an error but not throw.
2424  "connect: port too small.",
2425  __LINE__,
2426  {
2427  "connect",
2428  "ThereIsNoCheckingOnTheIPFormat",
2429  "-1",
2430  },
2432  R"()"},
2433  {// Note: this should return an error but not throw.
2434  "connect: port too large.",
2435  __LINE__,
2436  {
2437  "connect",
2438  "ThereIsNoCheckingOnTheIPFormat",
2439  "4294967296",
2440  },
2442  R"()"},
2443 
2444  // consensus_info
2445  // --------------------------------------------------------------
2446  {"consensus_info: minimal.",
2447  __LINE__,
2448  {
2449  "consensus_info",
2450  },
2452  R"({
2453  "method" : "consensus_info",
2454  "params" : [
2455  {
2456  "api_version" : %MAX_API_VER%
2457  }
2458  ]
2459  })"},
2460  {"consensus_info: too many arguments.",
2461  __LINE__,
2462  {"consensus_info", "whatever"},
2464  R"({
2465  "method" : "consensus_info",
2466  "params" : [
2467  {
2468  "error" : "badSyntax",
2469  "error_code" : 1,
2470  "error_message" : "Syntax error."
2471  }
2472  ]
2473  })"},
2474 
2475  // deposit_authorized
2476  // ----------------------------------------------------------
2477  {"deposit_authorized: minimal.",
2478  __LINE__,
2479  {
2480  "deposit_authorized",
2481  "source_account_NotValidated",
2482  "destination_account_NotValidated",
2483  },
2485  R"({
2486  "method" : "deposit_authorized",
2487  "params" : [
2488  {
2489  "api_version" : %MAX_API_VER%,
2490  "destination_account" : "destination_account_NotValidated",
2491  "source_account" : "source_account_NotValidated"
2492  }
2493  ]
2494  })"},
2495  {"deposit_authorized: with text ledger index.",
2496  __LINE__,
2497  {"deposit_authorized",
2498  "source_account_NotValidated",
2499  "destination_account_NotValidated",
2500  "validated"},
2502  R"({
2503  "method" : "deposit_authorized",
2504  "params" : [
2505  {
2506  "api_version" : %MAX_API_VER%,
2507  "destination_account" : "destination_account_NotValidated",
2508  "ledger_index" : "validated",
2509  "source_account" : "source_account_NotValidated"
2510  }
2511  ]
2512  })"},
2513  {"deposit_authorized: with ledger index.",
2514  __LINE__,
2515  {"deposit_authorized",
2516  "source_account_NotValidated",
2517  "destination_account_NotValidated",
2518  "4294967295"},
2520  R"({
2521  "method" : "deposit_authorized",
2522  "params" : [
2523  {
2524  "api_version" : %MAX_API_VER%,
2525  "destination_account" : "destination_account_NotValidated",
2526  "ledger_index" : 4294967295,
2527  "source_account" : "source_account_NotValidated"
2528  }
2529  ]
2530  })"},
2531  {"deposit_authorized: with ledger hash.",
2532  __LINE__,
2533  {"deposit_authorized",
2534  "source_account_NotValidated",
2535  "destination_account_NotValidated",
2536  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
2538  R"({
2539  "method" : "deposit_authorized",
2540  "params" : [
2541  {
2542  "api_version" : %MAX_API_VER%,
2543  "destination_account" : "destination_account_NotValidated",
2544  "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
2545  "source_account" : "source_account_NotValidated"
2546  }
2547  ]
2548  })"},
2549  {"deposit_authorized: too few arguments.",
2550  __LINE__,
2551  {
2552  "deposit_authorized",
2553  "source_account_NotValidated",
2554  },
2556  R"({
2557  "method" : "deposit_authorized",
2558  "params" : [
2559  {
2560  "error" : "badSyntax",
2561  "error_code" : 1,
2562  "error_message" : "Syntax error."
2563  }
2564  ]
2565  })"},
2566  {"deposit_authorized: too many arguments.",
2567  __LINE__,
2568  {"deposit_authorized",
2569  "source_account_NotValidated",
2570  "destination_account_NotValidated",
2571  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789",
2572  "spare"},
2574  R"({
2575  "method" : "deposit_authorized",
2576  "params" : [
2577  {
2578  "error" : "badSyntax",
2579  "error_code" : 1,
2580  "error_message" : "Syntax error."
2581  }
2582  ]
2583  })"},
2584  {"deposit_authorized: invalid ledger selection.",
2585  __LINE__,
2586  {
2587  "deposit_authorized",
2588  "source_account_NotValidated",
2589  "destination_account_NotValidated",
2590  "NotALedger",
2591  },
2593  R"({
2594  "method" : "deposit_authorized",
2595  "params" : [
2596  {
2597  "api_version" : %MAX_API_VER%,
2598  "destination_account" : "destination_account_NotValidated",
2599  "ledger_index" : 0,
2600  "source_account" : "source_account_NotValidated"
2601  }
2602  ]
2603  })"},
2604 
2605  // download_shard
2606  // --------------------------------------------------------------
2607  {"download_shard: minimal.",
2608  __LINE__,
2609  {
2610  "download_shard",
2611  "20",
2612  "url_NotValidated",
2613  },
2615  R"({
2616  "method" : "download_shard",
2617  "params" : [
2618  {
2619  "api_version" : %MAX_API_VER%,
2620  "shards" : [
2621  {
2622  "index" : 20,
2623  "url" : "url_NotValidated"
2624  }
2625  ]
2626  }
2627  ]
2628  })"},
2629  {"download_shard:",
2630  __LINE__,
2631  {
2632  "download_shard",
2633  "20",
2634  "url_NotValidated",
2635  },
2637  R"({
2638  "method" : "download_shard",
2639  "params" : [
2640  {
2641  "api_version" : %MAX_API_VER%,
2642  "shards" : [
2643  {
2644  "index" : 20,
2645  "url" : "url_NotValidated"
2646  }
2647  ]
2648  }
2649  ]
2650  })"},
2651  {"download_shard: many shards.",
2652  __LINE__,
2653  {
2654  "download_shard",
2655  "200000000",
2656  "url_NotValidated0",
2657  "199999999",
2658  "url_NotValidated1",
2659  "199999998",
2660  "url_NotValidated2",
2661  "199999997",
2662  "url_NotValidated3",
2663  },
2665  R"({
2666  "method" : "download_shard",
2667  "params" : [
2668  {
2669  "api_version" : %MAX_API_VER%,
2670  "shards" : [
2671  {
2672  "index" : 200000000,
2673  "url" : "url_NotValidated0"
2674  },
2675  {
2676  "index" : 199999999,
2677  "url" : "url_NotValidated1"
2678  },
2679  {
2680  "index" : 199999998,
2681  "url" : "url_NotValidated2"
2682  },
2683  {
2684  "index" : 199999997,
2685  "url" : "url_NotValidated3"
2686  }
2687  ]
2688  }
2689  ]
2690  })"},
2691  {"download_shard: many shards.",
2692  __LINE__,
2693  {
2694  "download_shard",
2695  "2000000",
2696  "url_NotValidated0",
2697  "2000001",
2698  "url_NotValidated1",
2699  "2000002",
2700  "url_NotValidated2",
2701  "2000003",
2702  "url_NotValidated3",
2703  "2000004",
2704  "url_NotValidated4",
2705  },
2707  R"({
2708  "method" : "download_shard",
2709  "params" : [
2710  {
2711  "api_version" : %MAX_API_VER%,
2712  "shards" : [
2713  {
2714  "index" : 2000000,
2715  "url" : "url_NotValidated0"
2716  },
2717  {
2718  "index" : 2000001,
2719  "url" : "url_NotValidated1"
2720  },
2721  {
2722  "index" : 2000002,
2723  "url" : "url_NotValidated2"
2724  },
2725  {
2726  "index" : 2000003,
2727  "url" : "url_NotValidated3"
2728  },
2729  {
2730  "index" : 2000004,
2731  "url" : "url_NotValidated4"
2732  }
2733  ]
2734  }
2735  ]
2736  })"},
2737  {"download_shard: too few arguments.",
2738  __LINE__,
2739  {"download_shard", "20"},
2741  R"({
2742  "method" : "download_shard",
2743  "params" : [
2744  {
2745  "error" : "badSyntax",
2746  "error_code" : 1,
2747  "error_message" : "Syntax error."
2748  }
2749  ]
2750  })"},
2751  {// Note: this should return an error but not throw.
2752  "download_shard: novalidate too few arguments.",
2753  __LINE__,
2754  {"download_shard", "novalidate", "20"},
2756  R"()"},
2757  {"download_shard: novalidate at end.",
2758  __LINE__,
2759  {
2760  "download_shard",
2761  "20",
2762  "url_NotValidated",
2763  "novalidate",
2764  },
2766  R"({
2767  "method" : "download_shard",
2768  "params" : [
2769  {
2770  "api_version" : %MAX_API_VER%,
2771  "shards" : [
2772  {
2773  "index" : 20,
2774  "url" : "url_NotValidated"
2775  }
2776  ]
2777  }
2778  ]
2779  })"},
2780  {"download_shard: novalidate in middle.",
2781  __LINE__,
2782  {
2783  "download_shard",
2784  "20",
2785  "url_NotValidated20",
2786  "novalidate",
2787  "200",
2788  "url_NotValidated200",
2789  },
2791  R"({
2792  "method" : "download_shard",
2793  "params" : [
2794  {
2795  "error" : "invalidParams",
2796  "error_code" : 31,
2797  "error_message" : "Invalid parameters."
2798  }
2799  ]
2800  })"},
2801  {// Note: this should return an error but not throw.
2802  "download_shard: arguments swapped.",
2803  __LINE__,
2804  {
2805  "download_shard",
2806  "url_NotValidated",
2807  "20",
2808  },
2810  R"()"},
2811  {"download_shard: index too small.",
2812  __LINE__,
2813  {
2814  "download_shard",
2815  "-1",
2816  "url_NotValidated",
2817  },
2819  R"()"},
2820  {"download_shard: index too big.",
2821  __LINE__,
2822  {
2823  "download_shard",
2824  "4294967296",
2825  "url_NotValidated",
2826  },
2828  R"()"},
2829 
2830  // feature
2831  // ---------------------------------------------------------------------
2832  {"feature: minimal.",
2833  __LINE__,
2834  {
2835  "feature",
2836  },
2838  R"({
2839  "method" : "feature",
2840  "params" : [
2841  {
2842  "api_version" : %MAX_API_VER%,
2843  }
2844  ]
2845  })"},
2846  {"feature: with name.",
2847  __LINE__,
2848  {"feature", "featureNameOrHexIsNotValidated"},
2850  R"({
2851  "method" : "feature",
2852  "params" : [
2853  {
2854  "api_version" : %MAX_API_VER%,
2855  "feature" : "featureNameOrHexIsNotValidated"
2856  }
2857  ]
2858  })"},
2859  {"feature: accept.",
2860  __LINE__,
2861  {"feature",
2862  "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA98"
2863  "76543210",
2864  "accept"},
2866  R"({
2867  "method" : "feature",
2868  "params" : [
2869  {
2870  "api_version" : %MAX_API_VER%,
2871  "feature" : "FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210FEDCBA9876543210",
2872  "vetoed" : false
2873  }
2874  ]
2875  })"},
2876  {"feature: reject.",
2877  __LINE__,
2878  {"feature", "0", "reject"},
2880  R"({
2881  "method" : "feature",
2882  "params" : [
2883  {
2884  "api_version" : %MAX_API_VER%,
2885  "feature" : "0",
2886  "vetoed" : true
2887  }
2888  ]
2889  })"},
2890  {"feature: too many arguments.",
2891  __LINE__,
2892  {"feature", "featureNameOrHexIsNotValidated", "accept", "anotherArg"},
2894  R"({
2895  "method" : "feature",
2896  "params" : [
2897  {
2898  "error" : "badSyntax",
2899  "error_code" : 1,
2900  "error_message" : "Syntax error."
2901  }
2902  ]
2903  })"},
2904  {"feature: neither accept nor reject.",
2905  __LINE__,
2906  {
2907  "feature",
2908  "featureNameOrHexIsNotValidated",
2909  "veto",
2910  },
2912  R"({
2913  "method" : "feature",
2914  "params" : [
2915  {
2916  "error" : "invalidParams",
2917  "error_code" : 31,
2918  "error_message" : "Invalid parameters."
2919  }
2920  ]
2921  })"},
2922 
2923  // fetch_info
2924  // ------------------------------------------------------------------
2925  {"fetch_info: minimal.",
2926  __LINE__,
2927  {
2928  "fetch_info",
2929  },
2931  R"({
2932  "method" : "fetch_info",
2933  "params" : [
2934  {
2935  "api_version" : %MAX_API_VER%,
2936  }
2937  ]
2938  })"},
2939  {"fetch_info: clear.",
2940  __LINE__,
2941  {"fetch_info", "clear"},
2943  R"({
2944  "method" : "fetch_info",
2945  "params" : [
2946  {
2947  "api_version" : %MAX_API_VER%,
2948  "clear" : true
2949  }
2950  ]
2951  })"},
2952  {"fetch_info: too many arguments.",
2953  __LINE__,
2954  {"fetch_info", "clear", "other"},
2956  R"({
2957  "method" : "fetch_info",
2958  "params" : [
2959  {
2960  "error" : "badSyntax",
2961  "error_code" : 1,
2962  "error_message" : "Syntax error."
2963  }
2964  ]
2965  })"},
2966  {"fetch_info: other trailing argument.",
2967  __LINE__,
2968  {"fetch_info", "too"},
2970  R"({
2971  "method" : "fetch_info",
2972  "params" : [
2973  {
2974  "api_version" : %MAX_API_VER%,
2975  "too" : true
2976  }
2977  ]
2978  })"},
2979 
2980  // gateway_balances
2981  // ------------------------------------------------------------
2982  {"gateway_balances: minimal.",
2983  __LINE__,
2984  {"gateway_balances", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
2986  R"({
2987  "method" : "gateway_balances",
2988  "params" : [
2989  {
2990  "api_version" : %MAX_API_VER%,
2991  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2992  }
2993  ]
2994  })"},
2995  {"gateway_balances: with ledger index.",
2996  __LINE__,
2997  {"gateway_balances", "890765", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
2999  R"({
3000  "method" : "gateway_balances",
3001  "params" : [
3002  {
3003  "api_version" : %MAX_API_VER%,
3004  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3005  "ledger_index" : "890765"
3006  }
3007  ]
3008  })"},
3009  {"gateway_balances: with text ledger index.",
3010  __LINE__,
3011  {"gateway_balances", "current", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
3013  R"({
3014  "method" : "gateway_balances",
3015  "params" : [
3016  {
3017  "api_version" : %MAX_API_VER%,
3018  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3019  "ledger_index" : "current"
3020  }
3021  ]
3022  })"},
3023  {"gateway_balances: with 64 character ledger hash.",
3024  __LINE__,
3025  {"gateway_balances",
3026  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
3027  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
3029  R"({
3030  "method" : "gateway_balances",
3031  "params" : [
3032  {
3033  "api_version" : %MAX_API_VER%,
3034  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3035  "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
3036  }
3037  ]
3038  })"},
3039  {"gateway_balances: 1 hotwallet.",
3040  __LINE__,
3041  {"gateway_balances",
3042  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3043  "hotwallet_is_not_validated"},
3045  R"({
3046  "method" : "gateway_balances",
3047  "params" : [
3048  {
3049  "api_version" : %MAX_API_VER%,
3050  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3051  "hotwallet" : [ "hotwallet_is_not_validated" ]
3052  }
3053  ]
3054  })"},
3055  {"gateway_balances: 3 hotwallets.",
3056  __LINE__,
3057  {
3058  "gateway_balances",
3059  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
3060  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3061  "hotwallet_is_not_validated_1",
3062  "hotwallet_is_not_validated_2",
3063  "hotwallet_is_not_validated_3",
3064  },
3066  R"({
3067  "method" : "gateway_balances",
3068  "params" : [
3069  {
3070  "api_version" : %MAX_API_VER%,
3071  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
3072  "hotwallet" : [
3073  "hotwallet_is_not_validated_1",
3074  "hotwallet_is_not_validated_2",
3075  "hotwallet_is_not_validated_3"
3076  ],
3077  "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
3078  }
3079  ]
3080  })"},
3081  {"gateway_balances: too few arguments.",
3082  __LINE__,
3083  {
3084  "gateway_balances",
3085  },
3087  R"({
3088  "method" : "gateway_balances",
3089  "params" : [
3090  {
3091  "error" : "badSyntax",
3092  "error_code" : 1,
3093  "error_message" : "Syntax error."
3094  }
3095  ]
3096  })"},
3097  {"gateway_balances: empty first argument.",
3098  __LINE__,
3099  {"gateway_balances", ""},
3101  R"({
3102  "method" : "gateway_balances",
3103  "params" : [
3104  {
3105  "error" : "invalidParams",
3106  "error_code" : 31,
3107  "error_message" : "Invalid first parameter"
3108  }
3109  ]
3110  })"},
3111  {"gateway_balances: with ledger index but no gateway.",
3112  __LINE__,
3113  {
3114  "gateway_balances",
3115  "890765",
3116  },
3118  R"({
3119  "method" : "gateway_balances",
3120  "params" : [
3121  {
3122  "error" : "invalidParams",
3123  "error_code" : 31,
3124  "error_message" : "Invalid hotwallet"
3125  }
3126  ]
3127  })"},
3128  {"gateway_balances: with text ledger index but no gateway.",
3129  __LINE__,
3130  {
3131  "gateway_balances",
3132  "current",
3133  },
3135  R"({
3136  "method" : "gateway_balances",
3137  "params" : [
3138  {
3139  "error" : "invalidParams",
3140  "error_code" : 31,
3141  "error_message" : "Invalid hotwallet"
3142  }
3143  ]
3144  })"},
3145  {"gateway_balances: with 64 character ledger hash but no gateway.",
3146  __LINE__,
3147  {
3148  "gateway_balances",
3149  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
3150  },
3152  R"({
3153  "method" : "gateway_balances",
3154  "params" : [
3155  {
3156  "error" : "invalidParams",
3157  "error_code" : 31,
3158  "error_message" : "Invalid hotwallet"
3159  }
3160  ]
3161  })"},
3162 
3163  // get_counts
3164  // ------------------------------------------------------------------
3165  {"get_counts: minimal.",
3166  __LINE__,
3167  {
3168  "get_counts",
3169  },
3171  R"({
3172  "method" : "get_counts",
3173  "params" : [
3174  {
3175  "api_version" : %MAX_API_VER%,
3176  }
3177  ]
3178  })"},
3179  {"get_counts: with maximum count.",
3180  __LINE__,
3181  {"get_counts", "100"},
3183  R"({
3184  "method" : "get_counts",
3185  "params" : [
3186  {
3187  "api_version" : %MAX_API_VER%,
3188  "min_count" : 100
3189  }
3190  ]
3191  })"},
3192  {"get_counts: too many arguments.",
3193  __LINE__,
3194  {"get_counts", "100", "whatever"},
3196  R"({
3197  "method" : "get_counts",
3198  "params" : [
3199  {
3200  "error" : "badSyntax",
3201  "error_code" : 1,
3202  "error_message" : "Syntax error."
3203  }
3204  ]
3205  })"},
3206  {"get_counts: count too small.",
3207  __LINE__,
3208  {
3209  "get_counts",
3210  "-1",
3211  },
3213  R"()"},
3214  {"get_counts: count too large.",
3215  __LINE__,
3216  {"get_counts", "4294967296"},
3218  R"()"},
3219 
3220  // json
3221  // ------------------------------------------------------------------------
3222  {"json: minimal.",
3223  __LINE__,
3224  {
3225  "json",
3226  "command",
3227  R"({"json_argument":true})",
3228  },
3230  R"({
3231  "method" : "command",
3232  "params" : [
3233  {
3234  "api_version" : %MAX_API_VER%,
3235  "json_argument" : true,
3236  "method" : "command"
3237  }
3238  ]
3239  })"},
3240  {"json: null object.",
3241  __LINE__,
3242  {
3243  "json",
3244  "command",
3245  R"({})",
3246  },
3248  R"({
3249  "method" : "command",
3250  "params" : [
3251  {
3252  "api_version" : %MAX_API_VER%,
3253  "method" : "command"
3254  }
3255  ]
3256  })"},
3257  {"json: too few arguments.",
3258  __LINE__,
3259  {"json", "command"},
3261  R"({
3262  "method" : "json",
3263  "params" : [
3264  {
3265  "error" : "badSyntax",
3266  "error_code" : 1,
3267  "error_message" : "Syntax error."
3268  }
3269  ]
3270  })"},
3271  {"json: too many arguments.",
3272  __LINE__,
3273  {"json", "command", R"({"json_argument":true})", "extra"},
3275  R"({
3276  "method" : "json",
3277  "params" : [
3278  {
3279  "error" : "badSyntax",
3280  "error_code" : 1,
3281  "error_message" : "Syntax error."
3282  }
3283  ]
3284  })"},
3285  {"json: array, not object.",
3286  __LINE__,
3287  {
3288  "json",
3289  "command",
3290  R"(["arg1","arg2"])",
3291  },
3293  R"({
3294  "method" : "json",
3295  "params" : [
3296  {
3297  "error" : "invalidParams",
3298  "error_code" : 31,
3299  "error_message" : "Invalid parameters."
3300  }
3301  ]
3302  })"},
3303  {"json: invalid json (note closing comma).",
3304  __LINE__,
3305  {
3306  "json",
3307  "command",
3308  R"({"json_argument":true,})",
3309  },
3311  R"({
3312  "method" : "json",
3313  "params" : [
3314  {
3315  "error" : "invalidParams",
3316  "error_code" : 31,
3317  "error_message" : "Invalid parameters."
3318  }
3319  ]
3320  })"},
3321 
3322  // json2
3323  // -----------------------------------------------------------------------
3324  {"json2: minimal object.",
3325  __LINE__,
3326  {
3327  "json2",
3328  R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1"})",
3329  },
3331  R"({
3332  "id" : "A1",
3333  "jsonrpc" : "2.0",
3334  "method" : "call_1",
3335  "params" : [
3336  {
3337  "api_version" : %MAX_API_VER%,
3338  "id" : "A1",
3339  "jsonrpc" : "2.0",
3340  "method" : "call_1",
3341  "ripplerpc" : "2.0"
3342  }
3343  ],
3344  "ripplerpc" : "2.0"
3345  })"},
3346  {"json2: object with nested params.",
3347  __LINE__,
3348  {
3349  "json2",
3350  R"({
3351  "jsonrpc" : "2.0",
3352  "ripplerpc" : "2.0",
3353  "id" : "A1",
3354  "method" : "call_1",
3355  "params" : [{"inner_arg" : "yup"}]
3356  })",
3357  },
3359  R"({
3360  "id" : "A1",
3361  "jsonrpc" : "2.0",
3362  "method" : "call_1",
3363  "params" : [
3364  {
3365  "api_version" : %MAX_API_VER%,
3366  "0" : {
3367  "inner_arg" : "yup"
3368  },
3369  "id" : "A1",
3370  "jsonrpc" : "2.0",
3371  "method" : "call_1",
3372  "ripplerpc" : "2.0"
3373  }
3374  ],
3375  "ripplerpc" : "2.0"
3376  })"},
3377  {"json2: minimal array.",
3378  __LINE__,
3379  {
3380  "json2",
3381  R"([{"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1"}])",
3382  },
3384  R"({
3385  "method" : "json2",
3386  "params" : [
3387  [
3388  {
3389  "api_version" : %MAX_API_VER%,
3390  "id" : "A1",
3391  "jsonrpc" : "2.0",
3392  "method" : "call_1",
3393  "ripplerpc" : "2.0"
3394  }
3395  ]
3396  ]
3397  })"},
3398  {"json2: array with object with nested params.",
3399  __LINE__,
3400  {
3401  "json2",
3402  R"([
3403  {"jsonrpc":"2.0",
3404  "ripplerpc":"2.0",
3405  "id":"A1",
3406  "method":"call_1",
3407  "params" : [{"inner_arg" : "yup"}]}
3408  ])",
3409  },
3411  R"({
3412  "method" : "json2",
3413  "params" : [
3414  [
3415  {
3416  "api_version" : %MAX_API_VER%,
3417  "0" : {
3418  "inner_arg" : "yup"
3419  },
3420  "id" : "A1",
3421  "jsonrpc" : "2.0",
3422  "method" : "call_1",
3423  "ripplerpc" : "2.0"
3424  }
3425  ]
3426  ]})"},
3427  {"json2: too few arguments.",
3428  __LINE__,
3429  {
3430  "json2",
3431  },
3433  R"({
3434  "method" : "json2",
3435  "params" : [
3436  {
3437  "error" : "badSyntax",
3438  "error_code" : 1,
3439  "error_message" : "Syntax error."
3440  }
3441  ]
3442  })"},
3443  {"json2: too many arguments.",
3444  __LINE__,
3445  {"json2",
3446  R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_this"})",
3447  "extra"},
3449  R"({
3450  "method" : "json2",
3451  "params" : [
3452  {
3453  "error" : "badSyntax",
3454  "error_code" : 1,
3455  "error_message" : "Syntax error."
3456  }
3457  ]
3458  })"},
3459  {"json2: malformed json (note extra comma).",
3460  __LINE__,
3461  {
3462  "json2",
3463  R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1",})",
3464  },
3466  R"({
3467  "id" : "A1",
3468  "jsonrpc" : "2.0",
3469  "method" : "json2",
3470  "params" : [
3471  {
3472  "error" : "invalidParams",
3473  "error_code" : 31,
3474  "error_message" : "Invalid parameters.",
3475  "id" : "A1",
3476  "jsonrpc" : "2.0",
3477  "ripplerpc" : "2.0"
3478  }
3479  ],
3480  "ripplerpc" : "2.0"
3481  })"},
3482  {"json2: omit jsonrpc.",
3483  __LINE__,
3484  {
3485  "json2",
3486  R"({"ripplerpc":"2.0","id":"A1","method":"call_1"})",
3487  },
3489  R"({
3490  "id" : "A1",
3491  "method" : "json2",
3492  "params" : [
3493  {
3494  "error" : "invalidParams",
3495  "error_code" : 31,
3496  "error_message" : "Invalid parameters.",
3497  "id" : "A1",
3498  "ripplerpc" : "2.0"
3499  }
3500  ],
3501  "ripplerpc" : "2.0"
3502  })"},
3503  {"json2: wrong jsonrpc version.",
3504  __LINE__,
3505  {
3506  "json2",
3507  R"({"jsonrpc":"2.1","ripplerpc":"2.0","id":"A1","method":"call_1"})",
3508  },
3510  R"({
3511  "id" : "A1",
3512  "jsonrpc" : "2.1",
3513  "method" : "json2",
3514  "params" : [
3515  {
3516  "error" : "invalidParams",
3517  "error_code" : 31,
3518  "error_message" : "Invalid parameters.",
3519  "id" : "A1",
3520  "jsonrpc" : "2.1",
3521  "ripplerpc" : "2.0"
3522  }
3523  ],
3524  "ripplerpc" : "2.0"
3525  })"},
3526  {"json2: omit ripplerpc.",
3527  __LINE__,
3528  {
3529  "json2",
3530  R"({"jsonrpc":"2.0","id":"A1","method":"call_1"})",
3531  },
3533  R"({
3534  "id" : "A1",
3535  "jsonrpc" : "2.0",
3536  "method" : "json2",
3537  "params" : [
3538  {
3539  "error" : "invalidParams",
3540  "error_code" : 31,
3541  "error_message" : "Invalid parameters.",
3542  "id" : "A1",
3543  "jsonrpc" : "2.0"
3544  }
3545  ]
3546  })"},
3547  {"json2: wrong ripplerpc version.",
3548  __LINE__,
3549  {
3550  "json2",
3551  R"({"jsonrpc":"2.0","ripplerpc":"2.00","id":"A1","method":"call_1"})",
3552  },
3554  R"({
3555  "id" : "A1",
3556  "jsonrpc" : "2.0",
3557  "method" : "json2",
3558  "params" : [
3559  {
3560  "error" : "invalidParams",
3561  "error_code" : 31,
3562  "error_message" : "Invalid parameters.",
3563  "id" : "A1",
3564  "jsonrpc" : "2.0",
3565  "ripplerpc" : "2.00"
3566  }
3567  ],
3568  "ripplerpc" : "2.00"
3569  })"},
3570  {"json2: omit id.",
3571  __LINE__,
3572  {
3573  "json2",
3574  R"({"jsonrpc":"2.0","ripplerpc":"2.0","method":"call_1"})",
3575  },
3577  R"({
3578  "jsonrpc" : "2.0",
3579  "method" : "json2",
3580  "params" : [
3581  {
3582  "error" : "invalidParams",
3583  "error_code" : 31,
3584  "error_message" : "Invalid parameters.",
3585  "jsonrpc" : "2.0",
3586  "ripplerpc" : "2.0"
3587  }
3588  ],
3589  "ripplerpc" : "2.0"
3590  })"},
3591  {"json2: omit method.",
3592  __LINE__,
3593  {
3594  "json2",
3595  R"({"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1"})",
3596  },
3598  R"({
3599  "id" : "A1",
3600  "jsonrpc" : "2.0",
3601  "method" : "json2",
3602  "params" : [
3603  {
3604  "error" : "invalidParams",
3605  "error_code" : 31,
3606  "error_message" : "Invalid parameters.",
3607  "id" : "A1",
3608  "jsonrpc" : "2.0",
3609  "ripplerpc" : "2.0"
3610  }
3611  ],
3612  "ripplerpc" : "2.0"
3613  })"},
3614  {"json2: empty outer array.",
3615  __LINE__,
3616  {
3617  "json2",
3618  R"([])",
3619  },
3621  R"({
3622  "method" : "json2",
3623  "params" : [
3624  {
3625  "error" : "invalidParams",
3626  "error_code" : 31,
3627  "error_message" : "Invalid parameters."
3628  }
3629  ]
3630  })"},
3631  {"json2: empty inner array.",
3632  __LINE__,
3633  {
3634  "json2",
3635  R"([{"jsonrpc":"2.0","ripplerpc":"2.0","id":"A1","method":"call_1",[]}])",
3636  },
3638  R"({
3639  "method" : "json2",
3640  "params" : [
3641  {
3642  "error" : "invalidParams",
3643  "error_code" : 31,
3644  "error_message" : "Invalid parameters."
3645  }
3646  ]
3647  })"},
3648  {"json2: array with non-json2 object.",
3649  __LINE__,
3650  {
3651  "json2",
3652  R"([
3653  {"jsonrpc" : "2.1",
3654  "ripplerpc" : "2.0",
3655  "id" : "A1",
3656  "method" : "call_1"
3657  }
3658  ])",
3659  },
3661  R"({
3662  "method" : "json2",
3663  "params" : [
3664  {
3665  "error" : "invalidParams",
3666  "error_code" : 31,
3667  "error_message" : "Invalid parameters."
3668  }
3669  ]
3670  })"},
3671  {"json2: non-object or -array inner params member.",
3672  __LINE__,
3673  {
3674  "json2",
3675  R"({
3676  "jsonrpc" : "2.0",
3677  "ripplerpc" : "2.0",
3678  "id" : "A1",
3679  "method" : "call_1",
3680  "params" : true
3681  })",
3682  },
3684  R"({
3685  "id" : "A1",
3686  "jsonrpc" : "2.0",
3687  "method" : "json2",
3688  "params" : [
3689  {
3690  "error" : "invalidParams",
3691  "error_code" : 31,
3692  "error_message" : "Invalid parameters.",
3693  "id" : "A1",
3694  "jsonrpc" : "2.0",
3695  "ripplerpc" : "2.0"
3696  }
3697  ],
3698  "ripplerpc" : "2.0"
3699  })"},
3700 
3701  // ledger
3702  // ----------------------------------------------------------------------
3703  {"ledger: minimal.",
3704  __LINE__,
3705  {"ledger"},
3707  R"({
3708  "method" : "ledger",
3709  "params" : [
3710  {
3711  "api_version" : %MAX_API_VER%,
3712  }
3713  ]
3714  })"},
3715  {"ledger: ledger index.",
3716  __LINE__,
3717  {"ledger", "4294967295"},
3719  R"({
3720  "method" : "ledger",
3721  "params" : [
3722  {
3723  "api_version" : %MAX_API_VER%,
3724  "ledger_index" : 4294967295
3725  }
3726  ]
3727  })"},
3728  {"ledger: text ledger index.",
3729  __LINE__,
3730  {"ledger", "validated"},
3732  R"({
3733  "method" : "ledger",
3734  "params" : [
3735  {
3736  "api_version" : %MAX_API_VER%,
3737  "ledger_index" : "validated"
3738  }
3739  ]
3740  })"},
3741  {"ledger: ledger hash.",
3742  __LINE__,
3743  {"ledger",
3744  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
3746  R"({
3747  "method" : "ledger",
3748  "params" : [
3749  {
3750  "api_version" : %MAX_API_VER%,
3751  "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
3752  }
3753  ]
3754  })"},
3755  {"ledger: full.",
3756  __LINE__,
3757  {"ledger", "current", "full"},
3759  R"({
3760  "method" : "ledger",
3761  "params" : [
3762  {
3763  "api_version" : %MAX_API_VER%,
3764  "full" : true,
3765  "ledger_index" : "current"
3766  }
3767  ]
3768  })"},
3769  {"ledger: tx.",
3770  __LINE__,
3771  {"ledger", "closed", "tx"},
3773  R"({
3774  "method" : "ledger",
3775  "params" : [
3776  {
3777  "api_version" : %MAX_API_VER%,
3778  "expand" : true,
3779  "ledger_index" : "closed",
3780  "transactions" : true
3781  }
3782  ]
3783  })"},
3784  {"ledger: too many arguments.",
3785  __LINE__,
3786  {"ledger", "4294967295", "spare"},
3788  R"({
3789  "method" : "ledger",
3790  "params" : [
3791  {
3792  "api_version" : %MAX_API_VER%,
3793  "ledger_index" : 4294967295
3794  }
3795  ]
3796  })"},
3797  {"ledger: ledger index too small.",
3798  __LINE__,
3799  {"ledger", "-1"},
3801  R"({
3802  "method" : "ledger",
3803  "params" : [
3804  {
3805  "api_version" : %MAX_API_VER%,
3806  "ledger_index" : 0
3807  }
3808  ]
3809  })"},
3810  {"ledger: ledger index too big.",
3811  __LINE__,
3812  {"ledger", "4294967296"},
3814  R"({
3815  "method" : "ledger",
3816  "params" : [
3817  {
3818  "api_version" : %MAX_API_VER%,
3819  "ledger_index" : 0
3820  }
3821  ]
3822  })"},
3823  {"ledger: invalid ledger text.",
3824  __LINE__,
3825  {"ledger", "latest"},
3827  R"({
3828  "method" : "ledger",
3829  "params" : [
3830  {
3831  "api_version" : %MAX_API_VER%,
3832  "ledger_index" : 0
3833  }
3834  ]
3835  })"},
3836  {"ledger: unsupported final argument.",
3837  __LINE__,
3838  {"ledger", "current", "expand"},
3840  R"({
3841  "method" : "ledger",
3842  "params" : [
3843  {
3844  "api_version" : %MAX_API_VER%,
3845  "ledger_index" : "current"
3846  }
3847  ]
3848  })"},
3849 
3850  // ledger_closed
3851  // ---------------------------------------------------------------
3852  {"ledger_closed: minimal.",
3853  __LINE__,
3854  {"ledger_closed"},
3856  R"({
3857  "method" : "ledger_closed",
3858  "params" : [
3859  {
3860  "api_version" : %MAX_API_VER%,
3861  }
3862  ]
3863  })"},
3864  {"ledger_closed: too many arguments.",
3865  __LINE__,
3866  {"ledger_closed", "today"},
3868  R"({
3869  "method" : "ledger_closed",
3870  "params" : [
3871  {
3872  "error" : "badSyntax",
3873  "error_code" : 1,
3874  "error_message" : "Syntax error."
3875  }
3876  ]
3877  })"},
3878 
3879  // ledger_current
3880  // --------------------------------------------------------------
3881  {"ledger_current: minimal.",
3882  __LINE__,
3883  {"ledger_current"},
3885  R"({
3886  "method" : "ledger_current",
3887  "params" : [
3888  {
3889  "api_version" : %MAX_API_VER%,
3890  }
3891  ]
3892  })"},
3893  {"ledger_current: too many arguments.",
3894  __LINE__,
3895  {"ledger_current", "today"},
3897  R"({
3898  "method" : "ledger_current",
3899  "params" : [
3900  {
3901  "error" : "badSyntax",
3902  "error_code" : 1,
3903  "error_message" : "Syntax error."
3904  }
3905  ]
3906  })"},
3907 
3908  // ledger_header
3909  // ---------------------------------------------------------------
3910  {"ledger_header: ledger index.",
3911  __LINE__,
3912  {"ledger_header", "4294967295"},
3914  R"({
3915  "method" : "ledger_header",
3916  "params" : [
3917  {
3918  "api_version" : %MAX_API_VER%,
3919  "ledger_index" : 4294967295
3920  }
3921  ]
3922  })"},
3923  {"ledger_header: ledger hash.",
3924  __LINE__,
3925  {"ledger_header",
3926  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
3928  R"({
3929  "method" : "ledger_header",
3930  "params" : [
3931  {
3932  "api_version" : %MAX_API_VER%,
3933  "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
3934  }
3935  ]
3936  })"},
3937  {"ledger_header: too few arguments.",
3938  __LINE__,
3939  {
3940  "ledger_header",
3941  },
3943  R"({
3944  "method" : "ledger_header",
3945  "params" : [
3946  {
3947  "error" : "badSyntax",
3948  "error_code" : 1,
3949  "error_message" : "Syntax error."
3950  }
3951  ]
3952  })"},
3953  {"ledger_header: too many arguments.",
3954  __LINE__,
3955  {"ledger_header", "4294967295", "spare"},
3957  R"({
3958  "method" : "ledger_header",
3959  "params" : [
3960  {
3961  "error" : "badSyntax",
3962  "error_code" : 1,
3963  "error_message" : "Syntax error."
3964  }
3965  ]
3966  })"},
3967  {"ledger_header: text ledger index.",
3968  __LINE__,
3969  {"ledger_header", "current"},
3971  R"({
3972  "method" : "ledger_header",
3973  "params" : [
3974  {
3975  "api_version" : %MAX_API_VER%,
3976  "ledger_index" : 0
3977  }
3978  ]
3979  })"},
3980  {"ledger_header: ledger index too small.",
3981  __LINE__,
3982  {"ledger_header", "-1"},
3984  R"({
3985  "method" : "ledger_header",
3986  "params" : [
3987  {
3988  "api_version" : %MAX_API_VER%,
3989  "ledger_index" : 0
3990  }
3991  ]
3992  })"},
3993  {"ledger_header: ledger index too big.",
3994  __LINE__,
3995  {"ledger_header", "4294967296"},
3997  R"({
3998  "method" : "ledger_header",
3999  "params" : [
4000  {
4001  "api_version" : %MAX_API_VER%,
4002  "ledger_index" : 0
4003  }
4004  ]
4005  })"},
4006 
4007  // ledger_request
4008  // --------------------------------------------------------------
4009  {"ledger_request: ledger index.",
4010  __LINE__,
4011  {"ledger_request", "4294967295"},
4013  R"({
4014  "method" : "ledger_request",
4015  "params" : [
4016  {
4017  "api_version" : %MAX_API_VER%,
4018  "ledger_index" : 4294967295
4019  }
4020  ]
4021  })"},
4022  {"ledger_request: ledger hash.",
4023  __LINE__,
4024  {"ledger_request",
4025  "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"},
4027  R"({
4028  "method" : "ledger_request",
4029  "params" : [
4030  {
4031  "api_version" : %MAX_API_VER%,
4032  "ledger_hash" : "ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789"
4033  }
4034  ]
4035  })"},
4036  {"ledger_request: too few arguments.",
4037  __LINE__,
4038  {
4039  "ledger_request",
4040  },
4042  R"({
4043  "method" : "ledger_request",
4044  "params" : [
4045  {
4046  "error" : "badSyntax",
4047  "error_code" : 1,
4048  "error_message" : "Syntax error."
4049  }
4050  ]
4051  })"},
4052  {"ledger_request: too many arguments.",
4053  __LINE__,
4054  {"ledger_request", "4294967295", "spare"},
4056  R"({
4057  "method" : "ledger_request",
4058  "params" : [
4059  {
4060  "error" : "badSyntax",
4061  "error_code" : 1,
4062  "error_message" : "Syntax error."
4063  }
4064  ]
4065  })"},
4066  {"ledger_request: text ledger index.",
4067  __LINE__,
4068  {"ledger_request", "current"},
4070  R"({
4071  "method" : "ledger_request",
4072  "params" : [
4073  {
4074  "api_version" : %MAX_API_VER%,
4075  "ledger_index" : 0
4076  }
4077  ]
4078  })"},
4079  {"ledger_request: ledger index too small.",
4080  __LINE__,
4081  {"ledger_request", "-1"},
4083  R"({
4084  "method" : "ledger_request",
4085  "params" : [
4086  {
4087  "api_version" : %MAX_API_VER%,
4088  "ledger_index" : 0
4089  }
4090  ]
4091  })"},
4092  {"ledger_request: ledger index too big.",
4093  __LINE__,
4094  {"ledger_request", "4294967296"},
4096  R"({
4097  "method" : "ledger_request",
4098  "params" : [
4099  {
4100  "api_version" : %MAX_API_VER%,
4101  "ledger_index" : 0
4102  }
4103  ]
4104  })"},
4105 
4106  // log_level
4107  // -------------------------------------------------------------------
4108  {"log_level: minimal.",
4109  __LINE__,
4110  {
4111  "log_level",
4112  },
4114  R"({
4115  "method" : "log_level",
4116  "params" : [
4117  {
4118  "api_version" : %MAX_API_VER%,
4119  }
4120  ]
4121  })"},
4122  {"log_level: fatal.",
4123  __LINE__,
4124  {"log_level", "fatal"},
4126  R"({
4127  "method" : "log_level",
4128  "params" : [
4129  {
4130  "api_version" : %MAX_API_VER%,
4131  "severity" : "fatal"
4132  }
4133  ]
4134  })"},
4135  {"log_level: error.",
4136  __LINE__,
4137  {"log_level", "error"},
4139  R"({
4140  "method" : "log_level",
4141  "params" : [
4142  {
4143  "api_version" : %MAX_API_VER%,
4144  "severity" : "error"
4145  }
4146  ]
4147  })"},
4148  {"log_level: warn.",
4149  __LINE__,
4150  {"log_level", "warn"},
4152  R"({
4153  "method" : "log_level",
4154  "params" : [
4155  {
4156  "api_version" : %MAX_API_VER%,
4157  "severity" : "warn"
4158  }
4159  ]
4160  })"},
4161  {"log_level: debug.",
4162  __LINE__,
4163  {"log_level", "debug"},
4165  R"({
4166  "method" : "log_level",
4167  "params" : [
4168  {
4169  "api_version" : %MAX_API_VER%,
4170  "severity" : "debug"
4171  }
4172  ]
4173  })"},
4174  {"log_level: trace.",
4175  __LINE__,
4176  {"log_level", "trace"},
4178  R"({
4179  "method" : "log_level",
4180  "params" : [
4181  {
4182  "api_version" : %MAX_API_VER%,
4183  "severity" : "trace"
4184  }
4185  ]
4186  })"},
4187  {"log_level: base partition.",
4188  __LINE__,
4189  {"log_level", "base", "trace"},
4191  R"({
4192  "method" : "log_level",
4193  "params" : [
4194  {
4195  "api_version" : %MAX_API_VER%,
4196  "partition" : "base",
4197  "severity" : "trace"
4198  }
4199  ]
4200  })"},
4201  {"log_level: partiton_name.",
4202  __LINE__,
4203  {"log_level", "partition_name", "fatal"},
4205  R"({
4206  "method" : "log_level",
4207  "params" : [
4208  {
4209  "api_version" : %MAX_API_VER%,
4210  "partition" : "partition_name",
4211  "severity" : "fatal"
4212  }
4213  ]
4214  })"},
4215  {"log_level: too many arguments.",
4216  __LINE__,
4217  {"log_level", "partition_name", "fatal", "extra"},
4219  R"({
4220  "method" : "log_level",
4221  "params" : [
4222  {
4223  "error" : "badSyntax",
4224  "error_code" : 1,
4225  "error_message" : "Syntax error."
4226  }
4227  ]
4228  })"},
4229  {"log_level: invalid severity.",
4230  __LINE__,
4231  {"log_level", "err"},
4233  R"({
4234  "method" : "log_level",
4235  "params" : [
4236  {
4237  "api_version" : %MAX_API_VER%,
4238  "severity" : "err"
4239  }
4240  ]
4241  })"},
4242  {"log_level: swap partition name and severity.",
4243  __LINE__,
4244  {
4245  "log_level",
4246  "fatal",
4247  "partition_name",
4248  },
4250  R"({
4251  "method" : "log_level",
4252  "params" : [
4253  {
4254  "api_version" : %MAX_API_VER%,
4255  "partition" : "fatal",
4256  "severity" : "partition_name"
4257  }
4258  ]
4259  })"},
4260 
4261  // logrotate
4262  // -------------------------------------------------------------------
4263  {"logrotate: minimal.",
4264  __LINE__,
4265  {
4266  "logrotate",
4267  },
4269  R"({
4270  "method" : "logrotate",
4271  "params" : [
4272  {
4273  "api_version" : %MAX_API_VER%,
4274  }
4275  ]
4276  })"},
4277  {"logrotate: too many arguments.",
4278  __LINE__,
4279  {"logrotate", "extra"},
4281  R"({
4282  "method" : "logrotate",
4283  "params" : [
4284  {
4285  "error" : "badSyntax",
4286  "error_code" : 1,
4287  "error_message" : "Syntax error."
4288  }
4289  ]
4290  })"},
4291 
4292  // owner_info
4293  // ------------------------------------------------------------------
4294  {"owner_info: minimal.",
4295  __LINE__,
4296  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
4298  R"({
4299  "method" : "owner_info",
4300  "params" : [
4301  {
4302  "api_version" : %MAX_API_VER%,
4303  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
4304  }
4305  ]
4306  })"},
4307  {"owner_info: with numeric ledger index.",
4308  __LINE__,
4309  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "987654321"},
4311  R"({
4312  "method" : "owner_info",
4313  "params" : [
4314  {
4315  "api_version" : %MAX_API_VER%,
4316  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4317  "ledger_index" : 987654321
4318  }
4319  ]
4320  })"},
4321  {"owner_info: with text ledger index.",
4322  __LINE__,
4323  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
4325  R"({
4326  "method" : "owner_info",
4327  "params" : [
4328  {
4329  "api_version" : %MAX_API_VER%,
4330  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4331  "ledger_index" : "validated"
4332  }
4333  ]
4334  })"},
4335  {"owner_info: with ledger hash.",
4336  __LINE__,
4337  {"owner_info",
4338  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4339  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
4341  R"({
4342  "method" : "owner_info",
4343  "params" : [
4344  {
4345  "api_version" : %MAX_API_VER%,
4346  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4347  "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
4348  }
4349  ]
4350  })"},
4351  {"owner_info: strict.",
4352  __LINE__,
4353  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "strict"},
4355  R"({
4356  "method" : "owner_info",
4357  "params" : [
4358  {
4359  "api_version" : %MAX_API_VER%,
4360  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4361  "strict" : 1
4362  }
4363  ]
4364  })"},
4365  {"owner_info: with ledger index and strict.",
4366  __LINE__,
4367  {"owner_info",
4368  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4369  "validated",
4370  "strict"},
4372  R"({
4373  "method" : "owner_info",
4374  "params" : [
4375  {
4376  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4377  "api_version" : %MAX_API_VER%,
4378  "ledger_index" : "validated",
4379  "strict" : 1
4380  }
4381  ]
4382  })"},
4383  {"owner_info: too few arguments.",
4384  __LINE__,
4385  {
4386  "owner_info",
4387  },
4389  R"({
4390  "method" : "owner_info",
4391  "params" : [
4392  {
4393  "error" : "badSyntax",
4394  "error_code" : 1,
4395  "error_message" : "Syntax error."
4396  }
4397  ]
4398  })"},
4399  {"owner_info: too many arguments.",
4400  __LINE__,
4401  {
4402  "owner_info",
4403  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4404  "current",
4405  "extra",
4406  "strict",
4407  },
4409  R"({
4410  "method" : "owner_info",
4411  "params" : [
4412  {
4413  "error" : "badSyntax",
4414  "error_code" : 1,
4415  "error_message" : "Syntax error."
4416  }
4417  ]
4418  })"},
4419  {
4420  "owner_info: invalid accountID.",
4421  __LINE__,
4422  {
4423  "owner_info",
4424  "", // Note: very few values are detected as bad!
4425  },
4427  R"({
4428  "method" : "owner_info",
4429  "params" : [
4430  {
4431  "error" : "actMalformed",
4432  "error_code" : 35,
4433  "error_message" : "Account malformed."
4434  }
4435  ]
4436  })",
4437  },
4438  {
4439  // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
4440  // cannot currently occur because jvParseLedger() always returns true.
4441  "owner_info: invalid ledger selection.",
4442  __LINE__,
4443  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
4445  R"({
4446  "method" : "owner_info",
4447  "params" : [
4448  {
4449  "api_version" : %MAX_API_VER%,
4450  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4451  "ledger_index" : 0
4452  }
4453  ]
4454  })",
4455  },
4456  {
4457  // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
4458  // cannot currently occur because jvParseLedger() always returns true.
4459  "owner_info: invalid ledger selection and strict.",
4460  __LINE__,
4461  {"owner_info",
4462  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4463  "no_ledger",
4464  "strict"},
4466  R"({
4467  "method" : "owner_info",
4468  "params" : [
4469  {
4470  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4471  "api_version" : %MAX_API_VER%,
4472  "ledger_index" : 0,
4473  "strict" : 1
4474  }
4475  ]
4476  })",
4477  },
4478 
4479  // peers
4480  // -----------------------------------------------------------------------
4481  {"peers: minimal.",
4482  __LINE__,
4483  {
4484  "peers",
4485  },
4487  R"({
4488  "method" : "peers",
4489  "params" : [
4490  {
4491  "api_version" : %MAX_API_VER%,
4492  }
4493  ]
4494  })"},
4495  {"peers: too many arguments.",
4496  __LINE__,
4497  {"peers", "extra"},
4499  R"({
4500  "method" : "peers",
4501  "params" : [
4502  {
4503  "error" : "badSyntax",
4504  "error_code" : 1,
4505  "error_message" : "Syntax error."
4506  }
4507  ]
4508  })"},
4509 
4510  // peer_reservations_add
4511  // -------------------------------------------------------
4512  {"peer_reservations_add: minimal.",
4513  __LINE__,
4514  {"peer_reservations_add", "public_key_string"},
4516  R"({
4517  "method" : "peer_reservations_add",
4518  "params" : [
4519  {
4520  "api_version" : %MAX_API_VER%,
4521  "public_key" : "public_key_string"
4522  }
4523  ]
4524  })"},
4525  {"peer_reservations_add: with description.",
4526  __LINE__,
4527  {"peer_reservations_add", "public_key_string", "public_key_description"},
4529  R"({
4530  "method" : "peer_reservations_add",
4531  "params" : [
4532  {
4533  "api_version" : %MAX_API_VER%,
4534  "description" : "public_key_description",
4535  "public_key" : "public_key_string"
4536  }
4537  ]
4538  })"},
4539  {"peer_reservations_add: too few arguments.",
4540  __LINE__,
4541  {"peer_reservations_add"},
4543  R"({
4544  "method" : "peer_reservations_add",
4545  "params" : [
4546  {
4547  "error" : "badSyntax",
4548  "error_code" : 1,
4549  "error_message" : "Syntax error."
4550  }
4551  ]
4552  })"},
4553  {"peer_reservations_add: too many arguments.",
4554  __LINE__,
4555  {"peer_reservations_add",
4556  "public_key_string",
4557  "public_key_description",
4558  "spare"},
4560  R"({
4561  "method" : "peer_reservations_add",
4562  "params" : [
4563  {
4564  "error" : "badSyntax",
4565  "error_code" : 1,
4566  "error_message" : "Syntax error."
4567  }
4568  ]
4569  })"},
4570 
4571  // peer_reservations_del
4572  // -------------------------------------------------------
4573  {"peer_reservations_del: minimal.",
4574  __LINE__,
4575  {"peer_reservations_del", "public_key_string"},
4577  R"({
4578  "method" : "peer_reservations_del",
4579  "params" : [
4580  {
4581  "api_version" : %MAX_API_VER%,
4582  "public_key" : "public_key_string"
4583  }
4584  ]
4585  })"},
4586  {"peer_reservations_del: too few arguments.",
4587  __LINE__,
4588  {"peer_reservations_del"},
4590  R"({
4591  "method" : "peer_reservations_del",
4592  "params" : [
4593  {
4594  "error" : "badSyntax",
4595  "error_code" : 1,
4596  "error_message" : "Syntax error."
4597  }
4598  ]
4599  })"},
4600  {"peer_reservations_del: too many arguments.",
4601  __LINE__,
4602  {"peer_reservations_del",
4603  "public_key_string",
4604  "public_key_description",
4605  "spare"},
4607  R"({
4608  "method" : "peer_reservations_del",
4609  "params" : [
4610  {
4611  "error" : "badSyntax",
4612  "error_code" : 1,
4613  "error_message" : "Syntax error."
4614  }
4615  ]
4616  })"},
4617 
4618  // ping
4619  // ------------------------------------------------------------------------
4620  {"ping: minimal.",
4621  __LINE__,
4622  {
4623  "ping",
4624  },
4626  R"({
4627  "method" : "ping",
4628  "params" : [
4629  {
4630  "api_version" : %MAX_API_VER%,
4631  }
4632  ]
4633  })"},
4634  {"ping: too many arguments.",
4635  __LINE__,
4636  {"ping", "extra"},
4638  R"({
4639  "method" : "ping",
4640  "params" : [
4641  {
4642  "error" : "badSyntax",
4643  "error_code" : 1,
4644  "error_message" : "Syntax error."
4645  }
4646  ]
4647  })"},
4648 
4649  // print
4650  // -----------------------------------------------------------------------
4651  {"print: minimal.",
4652  __LINE__,
4653  {
4654  "print",
4655  },
4657  R"({
4658  "method" : "print",
4659  "params" : [
4660  {
4661  "api_version" : %MAX_API_VER%,
4662  }
4663  ]
4664  })"},
4665  {// The docs indicate that no arguments are allowed. So should this error?
4666  "print: extra argument.",
4667  __LINE__,
4668  {"print", "extra"},
4670  R"({
4671  "method" : "print",
4672  "params" : [
4673  {
4674  "api_version" : %MAX_API_VER%,
4675  "params" : [ "extra" ]
4676  }
4677  ]
4678  })"},
4679  {"print: too many arguments.",
4680  __LINE__,
4681  {"print", "extra1", "extra2"},
4683  R"({
4684  "method" : "print",
4685  "params" : [
4686  {
4687  "error" : "badSyntax",
4688  "error_code" : 1,
4689  "error_message" : "Syntax error."
4690  }
4691  ]
4692  })"},
4693 
4694  // random
4695  // ----------------------------------------------------------------------
4696  {"random: minimal.",
4697  __LINE__,
4698  {
4699  "random",
4700  },
4702  R"({
4703  "method" : "random",
4704  "params" : [
4705  {
4706  "api_version" : %MAX_API_VER%,
4707  }
4708  ]
4709  })"},
4710  {"random: too many arguments.",
4711  __LINE__,
4712  {"random", "extra"},
4714  R"({
4715  "method" : "random",
4716  "params" : [
4717  {
4718  "error" : "badSyntax",
4719  "error_code" : 1,
4720  "error_message" : "Syntax error."
4721  }
4722  ]
4723  })"},
4724 
4725  // ripple_path_find
4726  // ------------------------------------------------------------
4727  {"ripple_path_find: minimal.",
4728  __LINE__,
4729  {
4730  "ripple_path_find",
4731  R"({"json_argument":true})",
4732  },
4734  R"({
4735  "method" : "ripple_path_find",
4736  "params" : [
4737  {
4738  "api_version" : %MAX_API_VER%,
4739  "json_argument" : true
4740  }
4741  ]
4742  })"},
4743  {"ripple_path_find: ledger index.",
4744  __LINE__,
4745  {"ripple_path_find", R"({"json_argument":true})", "4294967295"},
4747  R"({
4748  "method" : "ripple_path_find",
4749  "params" : [
4750  {
4751  "api_version" : %MAX_API_VER%,
4752  "json_argument" : true,
4753  "ledger_index" : 4294967295
4754  }
4755  ]
4756  })"},
4757  {"ripple_path_find: text ledger index.",
4758  __LINE__,
4759  {"ripple_path_find", R"({"json_argument":true})", "closed"},
4761  R"({
4762  "method" : "ripple_path_find",
4763  "params" : [
4764  {
4765  "api_version" : %MAX_API_VER%,
4766  "json_argument" : true,
4767  "ledger_index" : "closed"
4768  }
4769  ]
4770  })"},
4771  {"ripple_path_find: ledger hash.",
4772  __LINE__,
4773  {"ripple_path_find",
4774  R"({"json_argument":true})",
4775  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"},
4777  R"({
4778  "method" : "ripple_path_find",
4779  "params" : [
4780  {
4781  "api_version" : %MAX_API_VER%,
4782  "json_argument" : true,
4783  "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
4784  }
4785  ]
4786  })"},
4787 
4788  {"ripple_path_find: too few arguments.",
4789  __LINE__,
4790  {
4791  "ripple_path_find",
4792  },
4794  R"({
4795  "method" : "ripple_path_find",
4796  "params" : [
4797  {
4798  "error" : "badSyntax",
4799  "error_code" : 1,
4800  "error_message" : "Syntax error."
4801  }
4802  ]
4803  })"},
4804  {"ripple_path_find: too many arguments.",
4805  __LINE__,
4806  {"ripple_path_find", R"({"json_argument":true})", "current", "extra"},
4808  R"({
4809  "method" : "ripple_path_find",
4810  "params" : [
4811  {
4812  "error" : "badSyntax",
4813  "error_code" : 1,
4814  "error_message" : "Syntax error."
4815  }
4816  ]
4817  })"},
4818  {"ripple_path_find: invalid json (note extra comma).",
4819  __LINE__,
4820  {
4821  "ripple_path_find",
4822  R"({"json_argument":true,})",
4823  },
4825  R"({
4826  "method" : "ripple_path_find",
4827  "params" : [
4828  {
4829  "error" : "invalidParams",
4830  "error_code" : 31,
4831  "error_message" : "Invalid parameters."
4832  }
4833  ]
4834  })"},
4835  {"ripple_path_find: ledger index too small.",
4836  __LINE__,
4837  {"ripple_path_find", R"({"json_argument":true})", "-1"},
4839  R"({
4840  "method" : "ripple_path_find",
4841  "params" : [
4842  {
4843  "api_version" : %MAX_API_VER%,
4844  "json_argument" : true,
4845  "ledger_index" : 0
4846  }
4847  ]
4848  })"},
4849  {"ripple_path_find: ledger index too big.",
4850  __LINE__,
4851  {"ripple_path_find", R"({"json_argument":true})", "4294967296"},
4853  R"({
4854  "method" : "ripple_path_find",
4855  "params" : [
4856  {
4857  "api_version" : %MAX_API_VER%,
4858  "json_argument" : true,
4859  "ledger_index" : 0
4860  }
4861  ]
4862  })"},
4863  {"ripple_path_find: invalid text ledger index.",
4864  __LINE__,
4865  {"ripple_path_find", R"({"json_argument":true})", "cur"},
4867  R"({
4868  "method" : "ripple_path_find",
4869  "params" : [
4870  {
4871  "api_version" : %MAX_API_VER%,
4872  "json_argument" : true,
4873  "ledger_index" : 0
4874  }
4875  ]
4876  })"},
4877 
4878  // sign
4879  // ------------------------------------------------------------------------
4880  {"sign: minimal.",
4881  __LINE__,
4882  {
4883  "sign",
4884  "my_secret",
4885  R"({"json_argument":true})",
4886  },
4888  R"({
4889  "method" : "sign",
4890  "params" : [
4891  {
4892  "api_version" : %MAX_API_VER%,
4893  "secret" : "my_secret",
4894  "tx_json" : {
4895  "json_argument" : true
4896  }
4897  }
4898  ]
4899  })"},
4900  {"sign: offline.",
4901  __LINE__,
4902  {"sign", "my_secret", R"({"json_argument":true})", "offline"},
4904  R"({
4905  "method" : "sign",
4906  "params" : [
4907  {
4908  "api_version" : %MAX_API_VER%,
4909  "offline" : true,
4910  "secret" : "my_secret",
4911  "tx_json" : {
4912  "json_argument" : true
4913  }
4914  }
4915  ]
4916  })"},
4917  {"sign: too few arguments.",
4918  __LINE__,
4919  {"sign", "contents_of_blob"},
4921  R"({
4922  "method" : "sign",
4923  "params" : [
4924  {
4925  "error" : "badSyntax",
4926  "error_code" : 1,
4927  "error_message" : "Syntax error."
4928  }
4929  ]
4930  })"},
4931  {"sign: too many arguments.",
4932  __LINE__,
4933  {"sign", "my_secret", R"({"json_argument":true})", "offline", "extra"},
4935  R"({
4936  "method" : "sign",
4937  "params" : [
4938  {
4939  "error" : "badSyntax",
4940  "error_code" : 1,
4941  "error_message" : "Syntax error."
4942  }
4943  ]
4944  })"},
4945  {"sign: invalid JSON (note extra comma).",
4946  __LINE__,
4947  {
4948  "sign",
4949  "my_secret",
4950  R"({"json_argument":true,})",
4951  },
4953  R"({
4954  "method" : "sign",
4955  "params" : [
4956  {
4957  "error" : "invalidParams",
4958  "error_code" : 31,
4959  "error_message" : "Invalid parameters."
4960  }
4961  ]
4962  })"},
4963  {"sign: invalid final argument.",
4964  __LINE__,
4965  {"sign", "my_secret", R"({"json_argument":true})", "offlin"},
4967  R"({
4968  "method" : "sign",
4969  "params" : [
4970  {
4971  "error" : "invalidParams",
4972  "error_code" : 31,
4973  "error_message" : "Invalid parameters."
4974  }
4975  ]
4976  })"},
4977 
4978  // sign_for
4979  // --------------------------------------------------------------------
4980  {"sign_for: minimal.",
4981  __LINE__,
4982  {
4983  "sign_for",
4984  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4985  "my_secret",
4986  R"({"json_argument":true})",
4987  },
4989  R"({
4990  "method" : "sign_for",
4991  "params" : [
4992  {
4993  "api_version" : %MAX_API_VER%,
4994  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4995  "secret" : "my_secret",
4996  "tx_json" : {
4997  "json_argument" : true
4998  }
4999  }
5000  ]
5001  })"},
5002  {"sign_for: offline.",
5003  __LINE__,
5004  {"sign_for",
5005  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5006  "my_secret",
5007  R"({"json_argument":true})",
5008  "offline"},
5010  R"({
5011  "method" : "sign_for",
5012  "params" : [
5013  {
5014  "api_version" : %MAX_API_VER%,
5015  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5016  "offline" : true,
5017  "secret" : "my_secret",
5018  "tx_json" : {
5019  "json_argument" : true
5020  }
5021  }
5022  ]
5023  })"},
5024  {"sign_for: too few arguments.",
5025  __LINE__,
5026  {
5027  "sign_for",
5028  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5029  "my_secret",
5030  },
5032  R"({
5033  "method" : "sign_for",
5034  "params" : [
5035  {
5036  "error" : "badSyntax",
5037  "error_code" : 1,
5038  "error_message" : "Syntax error."
5039  }
5040  ]
5041  })"},
5042  {"sign_for: too many arguments.",
5043  __LINE__,
5044  {"sign_for",
5045  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5046  "my_secret",
5047  R"({"json_argument":true})",
5048  "offline",
5049  "extra"},
5051  R"({
5052  "method" : "sign_for",
5053  "params" : [
5054  {
5055  "error" : "badSyntax",
5056  "error_code" : 1,
5057  "error_message" : "Syntax error."
5058  }
5059  ]
5060  })"},
5061  {"sign_for: invalid json (note extra comma).",
5062  __LINE__,
5063  {
5064  "sign_for",
5065  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5066  "my_secret",
5067  R"({"json_argument":true,})",
5068  },
5070  R"({
5071  "method" : "sign_for",
5072  "params" : [
5073  {
5074  "error" : "invalidParams",
5075  "error_code" : 31,
5076  "error_message" : "Invalid parameters."
5077  }
5078  ]
5079  })"},
5080  {"sign_for: invalid final argument.",
5081  __LINE__,
5082  {"sign_for",
5083  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5084  "my_secret",
5085  R"({"json_argument":true})",
5086  "ofline"},
5088  R"({
5089  "method" : "sign_for",
5090  "params" : [
5091  {
5092  "error" : "invalidParams",
5093  "error_code" : 31,
5094  "error_message" : "Invalid parameters."
5095  }
5096  ]
5097  })"},
5098 
5099  // submit
5100  // ----------------------------------------------------------------------
5101  {"submit: blob.",
5102  __LINE__,
5103  {"submit", "the blob is unvalidated and may be any length..."},
5105  R"({
5106  "method" : "submit",
5107  "params" : [
5108  {
5109  "api_version" : %MAX_API_VER%,
5110  "tx_blob" : "the blob is unvalidated and may be any length..."
5111  }
5112  ]
5113  })"},
5114  {"submit: json.",
5115  __LINE__,
5116  {
5117  "submit",
5118  "my_secret",
5119  R"({"json_argument":true})",
5120  },
5122  R"({
5123  "method" : "submit",
5124  "params" : [
5125  {
5126  "api_version" : %MAX_API_VER%,
5127  "secret" : "my_secret",
5128  "tx_json" : {
5129  "json_argument" : true
5130  }
5131  }
5132  ]
5133  })"},
5134  {"submit: too few arguments.",
5135  __LINE__,
5136  {
5137  "submit",
5138  },
5140  R"({
5141  "method" : "submit",
5142  "params" : [
5143  {
5144  "error" : "badSyntax",
5145  "error_code" : 1,
5146  "error_message" : "Syntax error."
5147  }
5148  ]
5149  })"},
5150  {// Note: I believe this _ought_ to be detected as too many arguments.
5151  "submit: four arguments.",
5152  __LINE__,
5153  {"submit", "my_secret", R"({"json_argument":true})", "offline"},
5155  R"({
5156  "method" : "submit",
5157  "params" : [
5158  {
5159  "api_version" : %MAX_API_VER%,
5160  "offline" : true,
5161  "secret" : "my_secret",
5162  "tx_json" : {
5163  "json_argument" : true
5164  }
5165  }
5166  ]
5167  })"},
5168  {"submit: too many arguments.",
5169  __LINE__,
5170  {"submit", "my_secret", R"({"json_argument":true})", "offline", "extra"},
5172  R"({
5173  "method" : "submit",
5174  "params" : [
5175  {
5176  "error" : "badSyntax",
5177  "error_code" : 1,
5178  "error_message" : "Syntax error."
5179  }
5180  ]
5181  })"},
5182  {"submit: invalid json (note extra comma).",
5183  __LINE__,
5184  {
5185  "submit",
5186  "my_secret",
5187  R"({"json_argument":true,})",
5188  },
5190  R"({
5191  "method" : "submit",
5192  "params" : [
5193  {
5194  "error" : "invalidParams",
5195  "error_code" : 31,
5196  "error_message" : "Invalid parameters."
5197  }
5198  ]
5199  })"},
5200  {"submit: last argument not \"offline\".",
5201  __LINE__,
5202  {"submit", "my_secret", R"({"json_argument":true})", "offlne"},
5204  R"({
5205  "method" : "submit",
5206  "params" : [
5207  {
5208  "error" : "invalidParams",
5209  "error_code" : 31,
5210  "error_message" : "Invalid parameters."
5211  }
5212  ]
5213  })"},
5214 
5215  // submit_multisigned
5216  // ----------------------------------------------------------
5217  {"submit_multisigned: json.",
5218  __LINE__,
5219  {
5220  "submit_multisigned",
5221  R"({"json_argument":true})",
5222  },
5224  R"({
5225  "method" : "submit_multisigned",
5226  "params" : [
5227  {
5228  "api_version" : %MAX_API_VER%,
5229  "tx_json" : {
5230  "json_argument" : true
5231  }
5232  }
5233  ]
5234  })"},
5235  {"submit_multisigned: too few arguments.",
5236  __LINE__,
5237  {
5238  "submit_multisigned",
5239  },
5241  R"({
5242  "method" : "submit_multisigned",
5243  "params" : [
5244  {
5245  "error" : "badSyntax",
5246  "error_code" : 1,
5247  "error_message" : "Syntax error."
5248  }
5249  ]
5250  })"},
5251  {"submit_multisigned: too many arguments.",
5252  __LINE__,
5253  {"submit_multisigned", R"({"json_argument":true})", "extra"},
5255  R"({
5256  "method" : "submit_multisigned",
5257  "params" : [
5258  {
5259  "error" : "badSyntax",
5260  "error_code" : 1,
5261  "error_message" : "Syntax error."
5262  }
5263  ]
5264  })"},
5265  {"submit_multisigned: invalid json (note extra comma).",
5266  __LINE__,
5267  {
5268  "submit_multisigned",
5269  R"({"json_argument":true,})",
5270  },
5272  R"({
5273  "method" : "submit_multisigned",
5274  "params" : [
5275  {
5276  "error" : "invalidParams",
5277  "error_code" : 31,
5278  "error_message" : "Invalid parameters."
5279  }
5280  }
5281  ]
5282  })"},
5283 
5284  // server_info
5285  // -----------------------------------------------------------------
5286  {"server_info: minimal.",
5287  __LINE__,
5288  {
5289  "server_info",
5290  },
5292  R"({
5293  "method" : "server_info",
5294  "params" : [
5295  {
5296  "api_version" : %MAX_API_VER%,
5297  }
5298  ]
5299  })"},
5300  {"server_info: counters.",
5301  __LINE__,
5302  {"server_info", "counters"},
5304  R"({
5305  "method" : "server_info",
5306  "params" : [
5307  {
5308  "api_version" : %MAX_API_VER%,
5309  "counters" : true
5310  }
5311  ]
5312  })"},
5313  {"server_info: too many arguments.",
5314  __LINE__,
5315  {"server_info", "counters", "extra"},
5317  R"({
5318  "method" : "server_info",
5319  "params" : [
5320  {
5321  "error" : "badSyntax",
5322  "error_code" : 1,
5323  "error_message" : "Syntax error."
5324  }
5325  ]
5326  })"},
5327  {"server_info: non-counters argument.",
5328  __LINE__,
5329  {"server_info", "counter"},
5331  R"({
5332  "method" : "server_info",
5333  "params" : [
5334  {
5335  "api_version" : %MAX_API_VER%,
5336  }
5337  ]
5338  })"},
5339 
5340  // server_state
5341  // ----------------------------------------------------------------
5342  {"server_state: minimal.",
5343  __LINE__,
5344  {
5345  "server_state",
5346  },
5348  R"({
5349  "method" : "server_state",
5350  "params" : [
5351  {
5352  "api_version" : %MAX_API_VER%,
5353  }
5354  ]
5355  })"},
5356  {"server_state: counters.",
5357  __LINE__,
5358  {"server_state", "counters"},
5360  R"({
5361  "method" : "server_state",
5362  "params" : [
5363  {
5364  "api_version" : %MAX_API_VER%,
5365  "counters" : true
5366  }
5367  ]
5368  })"},
5369  {"server_state: too many arguments.",
5370  __LINE__,
5371  {"server_state", "counters", "extra"},
5373  R"({
5374  "method" : "server_state",
5375  "params" : [
5376  {
5377  "error" : "badSyntax",
5378  "error_code" : 1,
5379  "error_message" : "Syntax error."
5380  }
5381  ]
5382  })"},
5383  {"server_state: non-counters argument.",
5384  __LINE__,
5385  {"server_state", "counter"},
5387  R"({
5388  "method" : "server_state",
5389  "params" : [
5390  {
5391  "api_version" : %MAX_API_VER%,
5392  }
5393  ]
5394  })"},
5395 
5396  // stop
5397  // ------------------------------------------------------------------------
5398  {"stop: minimal.",
5399  __LINE__,
5400  {
5401  "stop",
5402  },
5404  R"({
5405  "method" : "stop",
5406  "params" : [
5407  {
5408  "api_version" : %MAX_API_VER%,
5409  }
5410  ]
5411  })"},
5412  {"stop: too many arguments.",
5413  __LINE__,
5414  {"stop", "extra"},
5416  R"({
5417  "method" : "stop",
5418  "params" : [
5419  {
5420  "error" : "badSyntax",
5421  "error_code" : 1,
5422  "error_message" : "Syntax error."
5423  }
5424  ]
5425  })"},
5426 
5427  // transaction_entry
5428  // -----------------------------------------------------------
5429  {"transaction_entry: ledger index.",
5430  __LINE__,
5431  {"transaction_entry",
5432  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5433  "4294967295"},
5435  R"({
5436  "method" : "transaction_entry",
5437  "params" : [
5438  {
5439  "api_version" : %MAX_API_VER%,
5440  "ledger_index" : 4294967295,
5441  "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5442  }
5443  ]
5444  })"},
5445  {"transaction_entry: text ledger index.",
5446  __LINE__,
5447  {"transaction_entry",
5448  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5449  "current"},
5451  R"({
5452  "method" : "transaction_entry",
5453  "params" : [
5454  {
5455  "api_version" : %MAX_API_VER%,
5456  "ledger_index" : "current",
5457  "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5458  }
5459  ]
5460  })"},
5461  {"transaction_entry: ledger hash.",
5462  __LINE__,
5463  {"transaction_entry",
5464  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5465  "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210"},
5467  R"({
5468  "method" : "transaction_entry",
5469  "params" : [
5470  {
5471  "api_version" : %MAX_API_VER%,
5472  "ledger_hash" : "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210",
5473  "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5474  }
5475  ]
5476  })"},
5477  {"transaction_entry: too few arguments.",
5478  __LINE__,
5479  {
5480  "transaction_entry",
5481  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5482  },
5484  R"({
5485  "method" : "transaction_entry",
5486  "params" : [
5487  {
5488  "error" : "badSyntax",
5489  "error_code" : 1,
5490  "error_message" : "Syntax error."
5491  }
5492  ]
5493  })"},
5494  {"transaction_entry: too many arguments.",
5495  __LINE__,
5496  {"transaction_entry",
5497  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5498  "validated",
5499  "extra"},
5501  R"({
5502  "method" : "transaction_entry",
5503  "params" : [
5504  {
5505  "error" : "badSyntax",
5506  "error_code" : 1,
5507  "error_message" : "Syntax error."
5508  }
5509  ]
5510  })"},
5511  {"transaction_entry: short tx_hash.",
5512  __LINE__,
5513  {
5514  "transaction_entry",
5515  "123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5516  "validated",
5517  },
5519  R"({
5520  "method" : "transaction_entry",
5521  "params" : [
5522  {
5523  "error" : "invalidParams",
5524  "error_code" : 31,
5525  "error_message" : "Invalid parameters."
5526  }
5527  ]
5528  })"},
5529  {"transaction_entry: long tx_hash.",
5530  __LINE__,
5531  {
5532  "transaction_entry",
5533  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUVW",
5534  "validated",
5535  },
5537  R"({
5538  "method" : "transaction_entry",
5539  "params" : [
5540  {
5541  "error" : "invalidParams",
5542  "error_code" : 31,
5543  "error_message" : "Invalid parameters."
5544  }
5545  ]
5546  })"},
5547  {"transaction_entry: small ledger index.",
5548  __LINE__,
5549  {
5550  "transaction_entry",
5551  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5552  "0",
5553  },
5555  R"({
5556  "method" : "transaction_entry",
5557  "params" : [
5558  {
5559  "error" : "invalidParams",
5560  "error_code" : 31,
5561  "error_message" : "Invalid parameters."
5562  }
5563  ]
5564  })"},
5565  {"transaction_entry: large ledger index.",
5566  __LINE__,
5567  {
5568  "transaction_entry",
5569  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5570  "4294967296",
5571  },
5573  R"({
5574  "method" : "transaction_entry",
5575  "params" : [
5576  {
5577  "error" : "invalidParams",
5578  "error_code" : 31,
5579  "error_message" : "Invalid parameters."
5580  }
5581  ]
5582  })"},
5583  {"transaction_entry: short ledger hash.",
5584  __LINE__,
5585  {
5586  "transaction_entry",
5587  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5588  "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA987654321",
5589  },
5591  R"({
5592  "method" : "transaction_entry",
5593  "params" : [
5594  {
5595  "error" : "invalidParams",
5596  "error_code" : 31,
5597  "error_message" : "Invalid parameters."
5598  }
5599  ]
5600  })"},
5601  {"transaction_entry: long ledger hash.",
5602  __LINE__,
5603  {
5604  "transaction_entry",
5605  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5606  "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210Z",
5607  },
5609  R"({
5610  "method" : "transaction_entry",
5611  "params" : [
5612  {
5613  "error" : "invalidParams",
5614  "error_code" : 31,
5615  "error_message" : "Invalid parameters."
5616  }
5617  ]
5618  })"},
5619 
5620  // tx
5621  // --------------------------------------------------------------------------
5622  {"tx: minimal.",
5623  __LINE__,
5624  {"tx", "transaction_hash_is_not_validated"},
5626  R"({
5627  "method" : "tx",
5628  "params" : [
5629  {
5630  "api_version" : %MAX_API_VER%,
5631  "transaction" : "transaction_hash_is_not_validated"
5632  }
5633  ]
5634  })"},
5635  {"tx: binary.",
5636  __LINE__,
5637  {"tx", "transaction_hash_is_not_validated", "binary"},
5639  R"({
5640  "method" : "tx",
5641  "params" : [
5642  {
5643  "api_version" : %MAX_API_VER%,
5644  "binary" : true,
5645  "transaction" : "transaction_hash_is_not_validated"
5646  }
5647  ]
5648  })"},
5649  {"tx: too few arguments.",
5650  __LINE__,
5651  {
5652  "tx",
5653  },
5655  R"({
5656  "method" : "tx",
5657  "params" : [
5658  {
5659  "error" : "badSyntax",
5660  "error_code" : 1,
5661  "error_message" : "Syntax error."
5662  }
5663  ]
5664  })"},
5665  {"tx: too many arguments.",
5666  __LINE__,
5667  {"tx", "transaction_hash_is_not_validated", "binary", "1", "2", "extra"},
5669  R"({
5670  "method" : "tx",
5671  "params" : [
5672  {
5673  "error" : "badSyntax",
5674  "error_code" : 1,
5675  "error_message" : "Syntax error."
5676  }
5677  ]
5678  })"},
5679  {"tx: invalid final argument is apparently ignored.",
5680  __LINE__,
5681  {"tx", "transaction_hash_is_not_validated", "bin"},
5683  R"({
5684  "method" : "tx",
5685  "params" : [
5686  {
5687  "api_version" : %MAX_API_VER%,
5688  "transaction" : "transaction_hash_is_not_validated"
5689  }
5690  ]
5691  })"},
5692 
5693  // tx_account
5694  // ------------------------------------------------------------------
5695  {"tx_account: minimal.",
5696  __LINE__,
5697  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
5699  R"({
5700  "method" : "tx_account",
5701  "params" : [
5702  {
5703  "api_version" : %MAX_API_VER%,
5704  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5705  }
5706  ]
5707  })"},
5708  {"tx_account: ledger_index .",
5709  __LINE__,
5710  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "4294967295"},
5712  R"({
5713  "method" : "tx_account",
5714  "params" : [
5715  {
5716  "api_version" : %MAX_API_VER%,
5717  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5718  "ledger_index" : 4294967295
5719  }
5720  ]
5721  })"},
5722  {"tx_account: ledger_index plus trailing params.",
5723  __LINE__,
5724  {"tx_account",
5725  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5726  "707",
5727  "forward",
5728  "binary",
5729  "count"},
5731  R"({
5732  "method" : "tx_account",
5733  "params" : [
5734  {
5735  "api_version" : %MAX_API_VER%,
5736  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5737  "binary" : true,
5738  "count" : true,
5739  "forward" : true,
5740  "ledger_index" : 707
5741  }
5742  ]
5743  })"},
5744  {"tx_account: ledger_index_min and _max.",
5745  __LINE__,
5746  {"tx_account",
5747  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5748  "2147483647",
5749  "2147483647"},
5751  R"({
5752  "method" : "tx_account",
5753  "params" : [
5754  {
5755  "api_version" : %MAX_API_VER%,
5756  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5757  "ledger_index_max" : 2147483647,
5758  "ledger_index_min" : 2147483647
5759  }
5760  ]
5761  })"},
5762  {"tx_account: ledger_index_min and _max plus trailing params.",
5763  __LINE__,
5764  {"tx_account",
5765  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5766  "33333",
5767  "2147483647",
5768  "binary",
5769  "count",
5770  "forward"},
5772  R"({
5773  "method" : "tx_account",
5774  "params" : [
5775  {
5776  "api_version" : %MAX_API_VER%,
5777  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5778  "binary" : true,
5779  "count" : true,
5780  "forward" : true,
5781  "ledger_index_max" : 2147483647,
5782  "ledger_index_min" : 33333
5783  }
5784  ]
5785  })"},
5786  {"tx_account: ledger_index_min and _max plus limit.",
5787  __LINE__,
5788  {"tx_account",
5789  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5790  "-1",
5791  "2147483647",
5792  "2147483647"},
5794  R"({
5795  "method" : "tx_account",
5796  "params" : [
5797  {
5798  "api_version" : %MAX_API_VER%,
5799  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5800  "ledger_index_max" : 2147483647,
5801  "ledger_index_min" : -1,
5802  "limit" : 2147483647
5803  }
5804  ]
5805  })"},
5806  {"tx_account: ledger_index_min and _max, limit, trailing args.",
5807  __LINE__,
5808  {"tx_account",
5809  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5810  "1",
5811  "1",
5812  "-1",
5813  "count",
5814  "forward",
5815  "binary"},
5817  R"({
5818  "method" : "tx_account",
5819  "params" : [
5820  {
5821  "api_version" : %MAX_API_VER%,
5822  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5823  "binary" : true,
5824  "count" : true,
5825  "forward" : true,
5826  "ledger_index_max" : 1,
5827  "ledger_index_min" : 1,
5828  "limit" : -1
5829  }
5830  ]
5831  })"},
5832  {"tx_account: too few arguments.",
5833  __LINE__,
5834  {
5835  "tx_account",
5836  },
5838  R"({
5839  "method" : "tx_account",
5840  "params" : [
5841  {
5842  "error" : "badSyntax",
5843  "error_code" : 1,
5844  "error_message" : "Syntax error."
5845  }
5846  ]
5847  })"},
5848  {"tx_account: too many arguments.",
5849  __LINE__,
5850  {"tx_account",
5851  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5852  "589",
5853  "590",
5854  "67",
5855  "extra",
5856  "descending",
5857  "count",
5858  "binary"},
5860  R"({
5861  "method" : "tx_account",
5862  "params" : [
5863  {
5864  "error" : "badSyntax",
5865  "error_code" : 1,
5866  "error_message" : "Syntax error."
5867  }
5868  ]
5869  })"},
5870  {
5871  "tx_account: invalid accountID.",
5872  __LINE__,
5873  {"tx_account", "rHb9CJAWyB4rj9!VRWn96DkukG4bwdtyTh"},
5875  R"({
5876  "method" : "tx_account",
5877  "params" : [
5878  {
5879  "error" : "actMalformed",
5880  "error_code" : 35,
5881  "error_message" : "Account malformed."
5882  }
5883  ]
5884  })",
5885  },
5886  {
5887  // Note: not currently detected as bad input.
5888  "tx_account: invalid ledger.",
5889  __LINE__,
5890  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-478.7"},
5892  R"({
5893  "method" : "tx_account",
5894  "params" : [
5895  {
5896  "api_version" : %MAX_API_VER%,
5897  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5898  "ledger_index" : 0
5899  }
5900  ]
5901  })",
5902  },
5903  {
5904  "tx_account: max less than min.",
5905  __LINE__,
5906  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "580", "579"},
5908  R"({
5909  "method" : "tx_account",
5910  "params" : [
5911  {
5912  "error" : "lgrIdxsInvalid",
5913  "error_code" : 55,
5914  "error_message" : "Ledger indexes invalid."
5915  }
5916  ]
5917  })",
5918  },
5919  {
5920  // Note: this really shouldn't throw, but does at the moment.
5921  "tx_account: min large but still valid.",
5922  __LINE__,
5923  {"tx_account",
5924  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5925  "2147483648",
5926  "2147483648"},
5928  R"()",
5929  },
5930  {
5931  // Note: this really shouldn't throw, but does at the moment.
5932  "tx_account: max large but still valid.",
5933  __LINE__,
5934  {"tx_account",
5935  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5936  "2147483647",
5937  "2147483648"},
5939  R"()",
5940  },
5941  {
5942  // Note: this really shouldn't throw, but does at the moment.
5943  "tx_account: large limit.",
5944  __LINE__,
5945  {"tx_account",
5946  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5947  "-1",
5948  "-1",
5949  "2147483648"},
5951  R"()",
5952  },
5953  {
5954  // Note: this really shouldn't throw, but does at the moment.
5955  "tx_account: non-integer min.",
5956  __LINE__,
5957  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Binary", "-1"},
5959  R"()",
5960  },
5961  {
5962  // Note: this really shouldn't throw, but does at the moment.
5963  "tx_account: non-integer max.",
5964  __LINE__,
5965  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "counts"},
5967  R"()",
5968  },
5969  {
5970  // Note: this really shouldn't throw, but does at the moment.
5971  "tx_account: non-integer limit.",
5972  __LINE__,
5973  {"tx_account",
5974  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5975  "-1",
5976  "-1",
5977  "decending"},
5979  R"()",
5980  },
5981 
5982  // tx_history
5983  // ------------------------------------------------------------------
5984  {"tx_history: minimal.",
5985  __LINE__,
5986  {"tx_history", "0"},
5988  R"({
5989  "method" : "tx_history",
5990  "params" : [
5991  {
5992  "api_version" : %MAX_API_VER%,
5993  "start" : 0
5994  }
5995  ]
5996  })"},
5997  {"tx_history: too few arguments.",
5998  __LINE__,
5999  {
6000  "tx_history",
6001  },
6003  R"({
6004  "method" : "tx_history",
6005  "params" : [
6006  {
6007  "error" : "badSyntax",
6008  "error_code" : 1,
6009  "error_message" : "Syntax error."
6010  }
6011  ]
6012  })"},
6013  {"tx_history: too many arguments.",
6014  __LINE__,
6015  {"tx_history", "0", "1"},
6017  R"({
6018  "method" : "tx_history",
6019  "params" : [
6020  {
6021  "error" : "badSyntax",
6022  "error_code" : 1,
6023  "error_message" : "Syntax error."
6024  }
6025  ]
6026  })"},
6027  {
6028  // Note: this really shouldn't throw, but does at the moment.
6029  "tx_history: start too small.",
6030  __LINE__,
6031  {"tx_history", "-1"},
6033  R"()",
6034  },
6035  {
6036  // Note: this really shouldn't throw, but does at the moment.
6037  "tx_history: start too big.",
6038  __LINE__,
6039  {"tx_history", "4294967296"},
6041  R"()",
6042  },
6043  {
6044  // Note: this really shouldn't throw, but does at the moment.
6045  "tx_history: start not integer.",
6046  __LINE__,
6047  {"tx_history", "beginning"},
6049  R"()",
6050  },
6051 
6052  // unl_list
6053  // --------------------------------------------------------------------
6054  {"unl_list: minimal.",
6055  __LINE__,
6056  {
6057  "unl_list",
6058  },
6060  R"({
6061  "method" : "unl_list",
6062  "params" : [
6063  {
6064  "api_version" : %MAX_API_VER%,
6065  }
6066  ]
6067  })"},
6068  {"unl_list: too many arguments.",
6069  __LINE__,
6070  {"unl_list", "extra"},
6072  R"({
6073  "method" : "unl_list",
6074  "params" : [
6075  {
6076  "error" : "badSyntax",
6077  "error_code" : 1,
6078  "error_message" : "Syntax error."
6079  }
6080  ]
6081  })"},
6082 
6083  // validation_create
6084  // -----------------------------------------------------------
6085  {"validation_create: minimal.",
6086  __LINE__,
6087  {
6088  "validation_create",
6089  },
6091  R"({
6092  "method" : "validation_create",
6093  "params" : [
6094  {
6095  "api_version" : %MAX_API_VER%,
6096  }
6097  ]
6098  })"},
6099  {"validation_create: with secret.",
6100  __LINE__,
6101  {"validation_create", "the form of the secret is not validated"},
6103  R"({
6104  "method" : "validation_create",
6105  "params" : [
6106  {
6107  "api_version" : %MAX_API_VER%,
6108  "secret" : "the form of the secret is not validated"
6109  }
6110  ]
6111  })"},
6112  {"validation_create: too many arguments.",
6113  __LINE__,
6114  {"validation_create", "the form of the secret is not validated", "extra"},
6116  R"({
6117  "method" : "validation_create",
6118  "params" : [
6119  {
6120  "error" : "badSyntax",
6121  "error_code" : 1,
6122  "error_message" : "Syntax error."
6123  }
6124  ]
6125  })"},
6126 
6127  // version
6128  // ---------------------------------------------------------------------
6129  {"version: minimal.",
6130  __LINE__,
6131  {
6132  "version",
6133  },
6135  R"({
6136  "method" : "version",
6137  "params" : [
6138  {
6139  "api_version" : %MAX_API_VER%,
6140  }
6141  ]
6142  })"},
6143  {"version: too many arguments.",
6144  __LINE__,
6145  {"version", "extra"},
6147  R"({
6148  "method" : "version",
6149  "params" : [
6150  {
6151  "error" : "badSyntax",
6152  "error_code" : 1,
6153  "error_message" : "Syntax error."
6154  }
6155  ]
6156  })"},
6157 
6158  // wallet_propose
6159  // --------------------------------------------------------------
6160  {"wallet_propose: minimal.",
6161  __LINE__,
6162  {
6163  "wallet_propose",
6164  },
6166  R"({
6167  "method" : "wallet_propose",
6168  "params" : [
6169  {
6170  "api_version" : %MAX_API_VER%,
6171  }
6172  ]
6173  })"},
6174  {"wallet_propose: with passphrase.",
6175  __LINE__,
6176  {"wallet_propose", "the form of the passphrase is not validated"},
6178  R"({
6179  "method" : "wallet_propose",
6180  "params" : [
6181  {
6182  "api_version" : %MAX_API_VER%,
6183  "passphrase" : "the form of the passphrase is not validated"
6184  }
6185  ]
6186  })"},
6187  {"wallet_propose: too many arguments.",
6188  __LINE__,
6189  {"wallet_propose", "the form of the passphrase is not validated", "extra"},
6191  R"({
6192  "method" : "wallet_propose",
6193  "params" : [
6194  {
6195  "error" : "badSyntax",
6196  "error_code" : 1,
6197  "error_message" : "Syntax error."
6198  }
6199  ]
6200  })"},
6201 
6202  // internal
6203  // --------------------------------------------------------------------
6204  {"internal: minimal.",
6205  __LINE__,
6206  {"internal", "command_name"},
6208  R"({
6209  "method" : "internal",
6210  "params" : [
6211  {
6212  "api_version" : %MAX_API_VER%,
6213  "internal_command" : "command_name",
6214  "params" : []
6215  }
6216  ]
6217  })"},
6218  {"internal: with parameters.",
6219  __LINE__,
6220  {"internal",
6221  "command_name",
6222  "string_arg",
6223  "1",
6224  "-1",
6225  "4294967296",
6226  "3.14159"},
6228  R"({
6229  "method" : "internal",
6230  "params" : [
6231  {
6232  "api_version" : %MAX_API_VER%,
6233  "internal_command" : "command_name",
6234  "params" : [ "string_arg", "1", "-1", "4294967296", "3.14159" ]
6235  }
6236  ]
6237  })"},
6238  {"internal: too few arguments.",
6239  __LINE__,
6240  {
6241  "internal",
6242  },
6244  R"({
6245  "method" : "internal",
6246  "params" : [
6247  {
6248  "error" : "badSyntax",
6249  "error_code" : 1,
6250  "error_message" : "Syntax error."
6251  }
6252  ]
6253  })"},
6254 
6255  // path_find
6256  // -------------------------------------------------------------------
6257  {"path_find: minimal.",
6258  __LINE__,
6259  {
6260  "path_find",
6261  },
6263  R"({
6264  "method" : "path_find",
6265  "params" : [
6266  {
6267  "error" : "noEvents",
6268  "error_code" : 7,
6269  "error_message" : "Current transport does not support events."
6270  }
6271  ]
6272  })"},
6273  {"path_find: with arguments.",
6274  __LINE__,
6275  {"path_find", "string_arg", "1", "-1", "4294967296", "3.14159"},
6277  R"({
6278  "method" : "path_find",
6279  "params" : [
6280  {
6281  "error" : "noEvents",
6282  "error_code" : 7,
6283  "error_message" : "Current transport does not support events."
6284  }
6285  ]
6286  })"},
6287 
6288  // subscribe
6289  // -------------------------------------------------------------------
6290  {"subscribe: minimal.",
6291  __LINE__,
6292  {
6293  "subscribe",
6294  },
6296  R"({
6297  "method" : "subscribe",
6298  "params" : [
6299  {
6300  "error" : "noEvents",
6301  "error_code" : 7,
6302  "error_message" : "Current transport does not support events."
6303  }
6304  ]
6305  })"},
6306  {"subscribe: with arguments.",
6307  __LINE__,
6308  {"subscribe", "string_arg", "1", "-1", "4294967296", "3.14159"},
6310  R"({
6311  "method" : "subscribe",
6312  "params" : [
6313  {
6314  "error" : "noEvents",
6315  "error_code" : 7,
6316  "error_message" : "Current transport does not support events."
6317  }
6318  ]
6319  })"},
6320 
6321  // unsubscribe
6322  // -----------------------------------------------------------------
6323  {"unsubscribe: minimal.",
6324  __LINE__,
6325  {
6326  "unsubscribe",
6327  },
6329  R"({
6330  "method" : "unsubscribe",
6331  "params" : [
6332  {
6333  "error" : "noEvents",
6334  "error_code" : 7,
6335  "error_message" : "Current transport does not support events."
6336  }
6337  ]
6338  })"},
6339  {"unsubscribe: with arguments.",
6340  __LINE__,
6341  {"unsubscribe", "string_arg", "1", "-1", "4294967296", "3.14159"},
6343  R"({
6344  "method" : "unsubscribe",
6345  "params" : [
6346  {
6347  "error" : "noEvents",
6348  "error_code" : 7,
6349  "error_message" : "Current transport does not support events."
6350  }
6351  ]
6352  })"},
6353 
6354  // unknown_command
6355  // -------------------------------------------------------------
6356  {"unknown_command: minimal.",
6357  __LINE__,
6358  {
6359  "unknown_command",
6360  },
6362  R"({
6363  "method" : "unknown_command",
6364  "params" : [
6365  {
6366  "api_version" : %MAX_API_VER%,
6367  }
6368  ]
6369  })"},
6370  {"unknown_command: with arguments.",
6371  __LINE__,
6372  {"unknown_command", "string_arg", "1", "-1", "4294967296", "3.14159"},
6374  R"({
6375  "method" : "unknown_command",
6376  "params" : [
6377  {
6378  "api_version" : %MAX_API_VER%,
6379  "params" : [ "string_arg", "1", "-1", "4294967296", "3.14159" ]
6380  }
6381  ]
6382  })"},
6383 };
6384 
6386 updateAPIVersionString(const char* const req)
6387 {
6388  static std::string version_str =
6390  static auto place_holder = "%MAX_API_VER%";
6391  std::string jr(req);
6392  boost::replace_all(jr, place_holder, version_str);
6393  return jr;
6394 }
6395 
6396 class RPCCall_test : public beast::unit_test::suite
6397 {
6398 public:
6399  void
6401  {
6402  testcase << "RPCCall";
6403 
6404  test::jtx::Env env(*this); // Used only for its Journal.
6405 
6406  // For each RPCCall test.
6407  for (RPCCallTestData const& rpcCallTest : rpcCallTestArray)
6408  {
6409  std::vector<std::string> const args{
6410  rpcCallTest.args.begin(), rpcCallTest.args.end()};
6411 
6412  // Note that, over the long term, none of these tests should
6413  // throw. But, for the moment, some of them do. So handle it.
6414  Json::Value got;
6415  try
6416  {
6417  got = cmdLineToJSONRPC(args, env.journal);
6418  }
6419  catch (std::bad_cast const&)
6420  {
6421  if ((rpcCallTest.throwsWhat == RPCCallTestData::bad_cast) &&
6422  (std::strlen(rpcCallTest.exp) == 0))
6423  {
6424  pass();
6425  }
6426  else
6427  {
6428  fail(rpcCallTest.description, __FILE__, rpcCallTest.line);
6429  }
6430  // Try the next test.
6431  continue;
6432  }
6433 
6434  Json::Value exp;
6435  Json::Reader{}.parse(updateAPIVersionString(rpcCallTest.exp), exp);
6436 
6437  // Lambda to remove the "params[0u]:error_code" field if present.
6438  // Error codes are not expected to be stable between releases.
6439  auto rmErrorCode = [](Json::Value& json) {
6440  if (json.isMember(jss::params) && json[jss::params].isArray() &&
6441  json[jss::params].size() > 0 &&
6442  json[jss::params][0u].isObject())
6443  {
6444  json[jss::params][0u].removeMember(jss::error_code);
6445  }
6446  };
6447  rmErrorCode(got);
6448  rmErrorCode(exp);
6449 
6450  // Pass if we didn't expect a throw and we got what we expected.
6451  if ((rpcCallTest.throwsWhat == RPCCallTestData::no_exception) &&
6452  (got == exp))
6453  {
6454  pass();
6455  }
6456  else
6457  {
6458  fail(rpcCallTest.description, __FILE__, rpcCallTest.line);
6459  }
6460  }
6461  }
6462 
6463  void
6464  run() override
6465  {
6466  testRPCCall();
6467  }
6468 };
6469 
6470 BEAST_DEFINE_TESTSUITE(RPCCall, app, ripple);
6471 
6472 } // namespace test
6473 } // 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:141
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:214
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:6400
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:1482
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:73
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:114
ripple::test::RPCCall_test::run
void run() override
Definition: RPCCall_test.cpp:6464
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:6386
ripple::test::RPCCall_test
Definition: RPCCall_test.cpp:6396
initializer_list