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