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  // node_to_shard
4305  // -------------------------------------------------------------------
4306  {"node_to_shard: status.",
4307  __LINE__,
4308  {"node_to_shard", "status"},
4310  R"({
4311  "method" : "node_to_shard",
4312  "params" : [
4313  {
4314  "api_version" : %MAX_API_VER%,
4315  "action" : "status"
4316  }
4317  ]
4318  })"},
4319  {"node_to_shard: start.",
4320  __LINE__,
4321  {"node_to_shard", "start"},
4323  R"({
4324  "method" : "node_to_shard",
4325  "params" : [
4326  {
4327  "api_version" : %MAX_API_VER%,
4328  "action" : "start"
4329  }
4330  ]
4331  })"},
4332  {"node_to_shard: stop.",
4333  __LINE__,
4334  {"node_to_shard", "stop"},
4336  R"({
4337  "method" : "node_to_shard",
4338  "params" : [
4339  {
4340  "api_version" : %MAX_API_VER%,
4341  "action" : "stop"
4342  }
4343  ]
4344  })"},
4345  {"node_to_shard: too many arguments.",
4346  __LINE__,
4347  {"node_to_shard", "start", "stop"},
4349  R"({
4350  "method" : "node_to_shard",
4351  "params" : [
4352  {
4353  "error" : "badSyntax",
4354  "error_code" : 1,
4355  "error_message" : "Syntax error."
4356  }
4357  ]
4358  })"},
4359  {"node_to_shard: invalid argument.",
4360  __LINE__,
4361  {"node_to_shard", "invalid"},
4363  R"({
4364  "method" : "node_to_shard",
4365  "params" : [
4366  {
4367  "api_version" : %MAX_API_VER%,
4368  "action" : "invalid"
4369  }
4370  ]
4371  })"},
4372 
4373  // owner_info
4374  // ------------------------------------------------------------------
4375  {"owner_info: minimal.",
4376  __LINE__,
4377  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
4379  R"({
4380  "method" : "owner_info",
4381  "params" : [
4382  {
4383  "api_version" : %MAX_API_VER%,
4384  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
4385  }
4386  ]
4387  })"},
4388  {"owner_info: with numeric ledger index.",
4389  __LINE__,
4390  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "987654321"},
4392  R"({
4393  "method" : "owner_info",
4394  "params" : [
4395  {
4396  "api_version" : %MAX_API_VER%,
4397  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4398  "ledger_index" : 987654321
4399  }
4400  ]
4401  })"},
4402  {"owner_info: with text ledger index.",
4403  __LINE__,
4404  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "validated"},
4406  R"({
4407  "method" : "owner_info",
4408  "params" : [
4409  {
4410  "api_version" : %MAX_API_VER%,
4411  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4412  "ledger_index" : "validated"
4413  }
4414  ]
4415  })"},
4416  {"owner_info: with ledger hash.",
4417  __LINE__,
4418  {"owner_info",
4419  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4420  "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"},
4422  R"({
4423  "method" : "owner_info",
4424  "params" : [
4425  {
4426  "api_version" : %MAX_API_VER%,
4427  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4428  "ledger_hash" : "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
4429  }
4430  ]
4431  })"},
4432  {"owner_info: strict.",
4433  __LINE__,
4434  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "strict"},
4436  R"({
4437  "method" : "owner_info",
4438  "params" : [
4439  {
4440  "api_version" : %MAX_API_VER%,
4441  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4442  "strict" : 1
4443  }
4444  ]
4445  })"},
4446  {"owner_info: with ledger index and strict.",
4447  __LINE__,
4448  {"owner_info",
4449  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4450  "validated",
4451  "strict"},
4453  R"({
4454  "method" : "owner_info",
4455  "params" : [
4456  {
4457  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4458  "api_version" : %MAX_API_VER%,
4459  "ledger_index" : "validated",
4460  "strict" : 1
4461  }
4462  ]
4463  })"},
4464  {"owner_info: too few arguments.",
4465  __LINE__,
4466  {
4467  "owner_info",
4468  },
4470  R"({
4471  "method" : "owner_info",
4472  "params" : [
4473  {
4474  "error" : "badSyntax",
4475  "error_code" : 1,
4476  "error_message" : "Syntax error."
4477  }
4478  ]
4479  })"},
4480  {"owner_info: too many arguments.",
4481  __LINE__,
4482  {
4483  "owner_info",
4484  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4485  "current",
4486  "extra",
4487  "strict",
4488  },
4490  R"({
4491  "method" : "owner_info",
4492  "params" : [
4493  {
4494  "error" : "badSyntax",
4495  "error_code" : 1,
4496  "error_message" : "Syntax error."
4497  }
4498  ]
4499  })"},
4500  {
4501  "owner_info: invalid accountID.",
4502  __LINE__,
4503  {
4504  "owner_info",
4505  "", // Note: very few values are detected as bad!
4506  },
4508  R"({
4509  "method" : "owner_info",
4510  "params" : [
4511  {
4512  "error" : "actMalformed",
4513  "error_code" : 35,
4514  "error_message" : "Account malformed."
4515  }
4516  ]
4517  })",
4518  },
4519  {
4520  // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
4521  // cannot currently occur because jvParseLedger() always returns true.
4522  "owner_info: invalid ledger selection.",
4523  __LINE__,
4524  {"owner_info", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "no_ledger"},
4526  R"({
4527  "method" : "owner_info",
4528  "params" : [
4529  {
4530  "api_version" : %MAX_API_VER%,
4531  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4532  "ledger_index" : 0
4533  }
4534  ]
4535  })",
4536  },
4537  {
4538  // Note: there is code in place to return rpcLGR_IDX_MALFORMED. That
4539  // cannot currently occur because jvParseLedger() always returns true.
4540  "owner_info: invalid ledger selection and strict.",
4541  __LINE__,
4542  {"owner_info",
4543  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4544  "no_ledger",
4545  "strict"},
4547  R"({
4548  "method" : "owner_info",
4549  "params" : [
4550  {
4551  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
4552  "api_version" : %MAX_API_VER%,
4553  "ledger_index" : 0,
4554  "strict" : 1
4555  }
4556  ]
4557  })",
4558  },
4559 
4560  // peers
4561  // -----------------------------------------------------------------------
4562  {"peers: minimal.",
4563  __LINE__,
4564  {
4565  "peers",
4566  },
4568  R"({
4569  "method" : "peers",
4570  "params" : [
4571  {
4572  "api_version" : %MAX_API_VER%,
4573  }
4574  ]
4575  })"},
4576  {"peers: too many arguments.",
4577  __LINE__,
4578  {"peers", "extra"},
4580  R"({
4581  "method" : "peers",
4582  "params" : [
4583  {
4584  "error" : "badSyntax",
4585  "error_code" : 1,
4586  "error_message" : "Syntax error."
4587  }
4588  ]
4589  })"},
4590 
4591  // peer_reservations_add
4592  // -------------------------------------------------------
4593  {"peer_reservations_add: minimal.",
4594  __LINE__,
4595  {"peer_reservations_add", "public_key_string"},
4597  R"({
4598  "method" : "peer_reservations_add",
4599  "params" : [
4600  {
4601  "api_version" : %MAX_API_VER%,
4602  "public_key" : "public_key_string"
4603  }
4604  ]
4605  })"},
4606  {"peer_reservations_add: with description.",
4607  __LINE__,
4608  {"peer_reservations_add", "public_key_string", "public_key_description"},
4610  R"({
4611  "method" : "peer_reservations_add",
4612  "params" : [
4613  {
4614  "api_version" : %MAX_API_VER%,
4615  "description" : "public_key_description",
4616  "public_key" : "public_key_string"
4617  }
4618  ]
4619  })"},
4620  {"peer_reservations_add: too few arguments.",
4621  __LINE__,
4622  {"peer_reservations_add"},
4624  R"({
4625  "method" : "peer_reservations_add",
4626  "params" : [
4627  {
4628  "error" : "badSyntax",
4629  "error_code" : 1,
4630  "error_message" : "Syntax error."
4631  }
4632  ]
4633  })"},
4634  {"peer_reservations_add: too many arguments.",
4635  __LINE__,
4636  {"peer_reservations_add",
4637  "public_key_string",
4638  "public_key_description",
4639  "spare"},
4641  R"({
4642  "method" : "peer_reservations_add",
4643  "params" : [
4644  {
4645  "error" : "badSyntax",
4646  "error_code" : 1,
4647  "error_message" : "Syntax error."
4648  }
4649  ]
4650  })"},
4651 
4652  // peer_reservations_del
4653  // -------------------------------------------------------
4654  {"peer_reservations_del: minimal.",
4655  __LINE__,
4656  {"peer_reservations_del", "public_key_string"},
4658  R"({
4659  "method" : "peer_reservations_del",
4660  "params" : [
4661  {
4662  "api_version" : %MAX_API_VER%,
4663  "public_key" : "public_key_string"
4664  }
4665  ]
4666  })"},
4667  {"peer_reservations_del: too few arguments.",
4668  __LINE__,
4669  {"peer_reservations_del"},
4671  R"({
4672  "method" : "peer_reservations_del",
4673  "params" : [
4674  {
4675  "error" : "badSyntax",
4676  "error_code" : 1,
4677  "error_message" : "Syntax error."
4678  }
4679  ]
4680  })"},
4681  {"peer_reservations_del: too many arguments.",
4682  __LINE__,
4683  {"peer_reservations_del",
4684  "public_key_string",
4685  "public_key_description",
4686  "spare"},
4688  R"({
4689  "method" : "peer_reservations_del",
4690  "params" : [
4691  {
4692  "error" : "badSyntax",
4693  "error_code" : 1,
4694  "error_message" : "Syntax error."
4695  }
4696  ]
4697  })"},
4698 
4699  // ping
4700  // ------------------------------------------------------------------------
4701  {"ping: minimal.",
4702  __LINE__,
4703  {
4704  "ping",
4705  },
4707  R"({
4708  "method" : "ping",
4709  "params" : [
4710  {
4711  "api_version" : %MAX_API_VER%,
4712  }
4713  ]
4714  })"},
4715  {"ping: too many arguments.",
4716  __LINE__,
4717  {"ping", "extra"},
4719  R"({
4720  "method" : "ping",
4721  "params" : [
4722  {
4723  "error" : "badSyntax",
4724  "error_code" : 1,
4725  "error_message" : "Syntax error."
4726  }
4727  ]
4728  })"},
4729 
4730  // print
4731  // -----------------------------------------------------------------------
4732  {"print: minimal.",
4733  __LINE__,
4734  {
4735  "print",
4736  },
4738  R"({
4739  "method" : "print",
4740  "params" : [
4741  {
4742  "api_version" : %MAX_API_VER%,
4743  }
4744  ]
4745  })"},
4746  {// The docs indicate that no arguments are allowed. So should this error?
4747  "print: extra argument.",
4748  __LINE__,
4749  {"print", "extra"},
4751  R"({
4752  "method" : "print",
4753  "params" : [
4754  {
4755  "api_version" : %MAX_API_VER%,
4756  "params" : [ "extra" ]
4757  }
4758  ]
4759  })"},
4760  {"print: too many arguments.",
4761  __LINE__,
4762  {"print", "extra1", "extra2"},
4764  R"({
4765  "method" : "print",
4766  "params" : [
4767  {
4768  "error" : "badSyntax",
4769  "error_code" : 1,
4770  "error_message" : "Syntax error."
4771  }
4772  ]
4773  })"},
4774 
4775  // random
4776  // ----------------------------------------------------------------------
4777  {"random: minimal.",
4778  __LINE__,
4779  {
4780  "random",
4781  },
4783  R"({
4784  "method" : "random",
4785  "params" : [
4786  {
4787  "api_version" : %MAX_API_VER%,
4788  }
4789  ]
4790  })"},
4791  {"random: too many arguments.",
4792  __LINE__,
4793  {"random", "extra"},
4795  R"({
4796  "method" : "random",
4797  "params" : [
4798  {
4799  "error" : "badSyntax",
4800  "error_code" : 1,
4801  "error_message" : "Syntax error."
4802  }
4803  ]
4804  })"},
4805 
4806  // ripple_path_find
4807  // ------------------------------------------------------------
4808  {"ripple_path_find: minimal.",
4809  __LINE__,
4810  {
4811  "ripple_path_find",
4812  R"({"json_argument":true})",
4813  },
4815  R"({
4816  "method" : "ripple_path_find",
4817  "params" : [
4818  {
4819  "api_version" : %MAX_API_VER%,
4820  "json_argument" : true
4821  }
4822  ]
4823  })"},
4824  {"ripple_path_find: ledger index.",
4825  __LINE__,
4826  {"ripple_path_find", R"({"json_argument":true})", "4294967295"},
4828  R"({
4829  "method" : "ripple_path_find",
4830  "params" : [
4831  {
4832  "api_version" : %MAX_API_VER%,
4833  "json_argument" : true,
4834  "ledger_index" : 4294967295
4835  }
4836  ]
4837  })"},
4838  {"ripple_path_find: text ledger index.",
4839  __LINE__,
4840  {"ripple_path_find", R"({"json_argument":true})", "closed"},
4842  R"({
4843  "method" : "ripple_path_find",
4844  "params" : [
4845  {
4846  "api_version" : %MAX_API_VER%,
4847  "json_argument" : true,
4848  "ledger_index" : "closed"
4849  }
4850  ]
4851  })"},
4852  {"ripple_path_find: ledger hash.",
4853  __LINE__,
4854  {"ripple_path_find",
4855  R"({"json_argument":true})",
4856  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"},
4858  R"({
4859  "method" : "ripple_path_find",
4860  "params" : [
4861  {
4862  "api_version" : %MAX_API_VER%,
4863  "json_argument" : true,
4864  "ledger_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
4865  }
4866  ]
4867  })"},
4868 
4869  {"ripple_path_find: too few arguments.",
4870  __LINE__,
4871  {
4872  "ripple_path_find",
4873  },
4875  R"({
4876  "method" : "ripple_path_find",
4877  "params" : [
4878  {
4879  "error" : "badSyntax",
4880  "error_code" : 1,
4881  "error_message" : "Syntax error."
4882  }
4883  ]
4884  })"},
4885  {"ripple_path_find: too many arguments.",
4886  __LINE__,
4887  {"ripple_path_find", R"({"json_argument":true})", "current", "extra"},
4889  R"({
4890  "method" : "ripple_path_find",
4891  "params" : [
4892  {
4893  "error" : "badSyntax",
4894  "error_code" : 1,
4895  "error_message" : "Syntax error."
4896  }
4897  ]
4898  })"},
4899  {"ripple_path_find: invalid json (note extra comma).",
4900  __LINE__,
4901  {
4902  "ripple_path_find",
4903  R"({"json_argument":true,})",
4904  },
4906  R"({
4907  "method" : "ripple_path_find",
4908  "params" : [
4909  {
4910  "error" : "invalidParams",
4911  "error_code" : 31,
4912  "error_message" : "Invalid parameters."
4913  }
4914  ]
4915  })"},
4916  {"ripple_path_find: ledger index too small.",
4917  __LINE__,
4918  {"ripple_path_find", R"({"json_argument":true})", "-1"},
4920  R"({
4921  "method" : "ripple_path_find",
4922  "params" : [
4923  {
4924  "api_version" : %MAX_API_VER%,
4925  "json_argument" : true,
4926  "ledger_index" : 0
4927  }
4928  ]
4929  })"},
4930  {"ripple_path_find: ledger index too big.",
4931  __LINE__,
4932  {"ripple_path_find", R"({"json_argument":true})", "4294967296"},
4934  R"({
4935  "method" : "ripple_path_find",
4936  "params" : [
4937  {
4938  "api_version" : %MAX_API_VER%,
4939  "json_argument" : true,
4940  "ledger_index" : 0
4941  }
4942  ]
4943  })"},
4944  {"ripple_path_find: invalid text ledger index.",
4945  __LINE__,
4946  {"ripple_path_find", R"({"json_argument":true})", "cur"},
4948  R"({
4949  "method" : "ripple_path_find",
4950  "params" : [
4951  {
4952  "api_version" : %MAX_API_VER%,
4953  "json_argument" : true,
4954  "ledger_index" : 0
4955  }
4956  ]
4957  })"},
4958 
4959  // sign
4960  // ------------------------------------------------------------------------
4961  {"sign: minimal.",
4962  __LINE__,
4963  {
4964  "sign",
4965  "my_secret",
4966  R"({"json_argument":true})",
4967  },
4969  R"({
4970  "method" : "sign",
4971  "params" : [
4972  {
4973  "api_version" : %MAX_API_VER%,
4974  "secret" : "my_secret",
4975  "tx_json" : {
4976  "json_argument" : true
4977  }
4978  }
4979  ]
4980  })"},
4981  {"sign: offline.",
4982  __LINE__,
4983  {"sign", "my_secret", R"({"json_argument":true})", "offline"},
4985  R"({
4986  "method" : "sign",
4987  "params" : [
4988  {
4989  "api_version" : %MAX_API_VER%,
4990  "offline" : true,
4991  "secret" : "my_secret",
4992  "tx_json" : {
4993  "json_argument" : true
4994  }
4995  }
4996  ]
4997  })"},
4998  {"sign: too few arguments.",
4999  __LINE__,
5000  {"sign", "contents_of_blob"},
5002  R"({
5003  "method" : "sign",
5004  "params" : [
5005  {
5006  "error" : "badSyntax",
5007  "error_code" : 1,
5008  "error_message" : "Syntax error."
5009  }
5010  ]
5011  })"},
5012  {"sign: too many arguments.",
5013  __LINE__,
5014  {"sign", "my_secret", R"({"json_argument":true})", "offline", "extra"},
5016  R"({
5017  "method" : "sign",
5018  "params" : [
5019  {
5020  "error" : "badSyntax",
5021  "error_code" : 1,
5022  "error_message" : "Syntax error."
5023  }
5024  ]
5025  })"},
5026  {"sign: invalid JSON (note extra comma).",
5027  __LINE__,
5028  {
5029  "sign",
5030  "my_secret",
5031  R"({"json_argument":true,})",
5032  },
5034  R"({
5035  "method" : "sign",
5036  "params" : [
5037  {
5038  "error" : "invalidParams",
5039  "error_code" : 31,
5040  "error_message" : "Invalid parameters."
5041  }
5042  ]
5043  })"},
5044  {"sign: invalid final argument.",
5045  __LINE__,
5046  {"sign", "my_secret", R"({"json_argument":true})", "offlin"},
5048  R"({
5049  "method" : "sign",
5050  "params" : [
5051  {
5052  "error" : "invalidParams",
5053  "error_code" : 31,
5054  "error_message" : "Invalid parameters."
5055  }
5056  ]
5057  })"},
5058 
5059  // sign_for
5060  // --------------------------------------------------------------------
5061  {"sign_for: minimal.",
5062  __LINE__,
5063  {
5064  "sign_for",
5065  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5066  "my_secret",
5067  R"({"json_argument":true})",
5068  },
5070  R"({
5071  "method" : "sign_for",
5072  "params" : [
5073  {
5074  "api_version" : %MAX_API_VER%,
5075  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5076  "secret" : "my_secret",
5077  "tx_json" : {
5078  "json_argument" : true
5079  }
5080  }
5081  ]
5082  })"},
5083  {"sign_for: offline.",
5084  __LINE__,
5085  {"sign_for",
5086  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5087  "my_secret",
5088  R"({"json_argument":true})",
5089  "offline"},
5091  R"({
5092  "method" : "sign_for",
5093  "params" : [
5094  {
5095  "api_version" : %MAX_API_VER%,
5096  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5097  "offline" : true,
5098  "secret" : "my_secret",
5099  "tx_json" : {
5100  "json_argument" : true
5101  }
5102  }
5103  ]
5104  })"},
5105  {"sign_for: too few arguments.",
5106  __LINE__,
5107  {
5108  "sign_for",
5109  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5110  "my_secret",
5111  },
5113  R"({
5114  "method" : "sign_for",
5115  "params" : [
5116  {
5117  "error" : "badSyntax",
5118  "error_code" : 1,
5119  "error_message" : "Syntax error."
5120  }
5121  ]
5122  })"},
5123  {"sign_for: too many arguments.",
5124  __LINE__,
5125  {"sign_for",
5126  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5127  "my_secret",
5128  R"({"json_argument":true})",
5129  "offline",
5130  "extra"},
5132  R"({
5133  "method" : "sign_for",
5134  "params" : [
5135  {
5136  "error" : "badSyntax",
5137  "error_code" : 1,
5138  "error_message" : "Syntax error."
5139  }
5140  ]
5141  })"},
5142  {"sign_for: invalid json (note extra comma).",
5143  __LINE__,
5144  {
5145  "sign_for",
5146  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5147  "my_secret",
5148  R"({"json_argument":true,})",
5149  },
5151  R"({
5152  "method" : "sign_for",
5153  "params" : [
5154  {
5155  "error" : "invalidParams",
5156  "error_code" : 31,
5157  "error_message" : "Invalid parameters."
5158  }
5159  ]
5160  })"},
5161  {"sign_for: invalid final argument.",
5162  __LINE__,
5163  {"sign_for",
5164  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5165  "my_secret",
5166  R"({"json_argument":true})",
5167  "ofline"},
5169  R"({
5170  "method" : "sign_for",
5171  "params" : [
5172  {
5173  "error" : "invalidParams",
5174  "error_code" : 31,
5175  "error_message" : "Invalid parameters."
5176  }
5177  ]
5178  })"},
5179 
5180  // submit
5181  // ----------------------------------------------------------------------
5182  {"submit: blob.",
5183  __LINE__,
5184  {"submit", "the blob is unvalidated and may be any length..."},
5186  R"({
5187  "method" : "submit",
5188  "params" : [
5189  {
5190  "api_version" : %MAX_API_VER%,
5191  "tx_blob" : "the blob is unvalidated and may be any length..."
5192  }
5193  ]
5194  })"},
5195  {"submit: json.",
5196  __LINE__,
5197  {
5198  "submit",
5199  "my_secret",
5200  R"({"json_argument":true})",
5201  },
5203  R"({
5204  "method" : "submit",
5205  "params" : [
5206  {
5207  "api_version" : %MAX_API_VER%,
5208  "secret" : "my_secret",
5209  "tx_json" : {
5210  "json_argument" : true
5211  }
5212  }
5213  ]
5214  })"},
5215  {"submit: too few arguments.",
5216  __LINE__,
5217  {
5218  "submit",
5219  },
5221  R"({
5222  "method" : "submit",
5223  "params" : [
5224  {
5225  "error" : "badSyntax",
5226  "error_code" : 1,
5227  "error_message" : "Syntax error."
5228  }
5229  ]
5230  })"},
5231  {// Note: I believe this _ought_ to be detected as too many arguments.
5232  "submit: four arguments.",
5233  __LINE__,
5234  {"submit", "my_secret", R"({"json_argument":true})", "offline"},
5236  R"({
5237  "method" : "submit",
5238  "params" : [
5239  {
5240  "api_version" : %MAX_API_VER%,
5241  "offline" : true,
5242  "secret" : "my_secret",
5243  "tx_json" : {
5244  "json_argument" : true
5245  }
5246  }
5247  ]
5248  })"},
5249  {"submit: too many arguments.",
5250  __LINE__,
5251  {"submit", "my_secret", R"({"json_argument":true})", "offline", "extra"},
5253  R"({
5254  "method" : "submit",
5255  "params" : [
5256  {
5257  "error" : "badSyntax",
5258  "error_code" : 1,
5259  "error_message" : "Syntax error."
5260  }
5261  ]
5262  })"},
5263  {"submit: invalid json (note extra comma).",
5264  __LINE__,
5265  {
5266  "submit",
5267  "my_secret",
5268  R"({"json_argument":true,})",
5269  },
5271  R"({
5272  "method" : "submit",
5273  "params" : [
5274  {
5275  "error" : "invalidParams",
5276  "error_code" : 31,
5277  "error_message" : "Invalid parameters."
5278  }
5279  ]
5280  })"},
5281  {"submit: last argument not \"offline\".",
5282  __LINE__,
5283  {"submit", "my_secret", R"({"json_argument":true})", "offlne"},
5285  R"({
5286  "method" : "submit",
5287  "params" : [
5288  {
5289  "error" : "invalidParams",
5290  "error_code" : 31,
5291  "error_message" : "Invalid parameters."
5292  }
5293  ]
5294  })"},
5295 
5296  // submit_multisigned
5297  // ----------------------------------------------------------
5298  {"submit_multisigned: json.",
5299  __LINE__,
5300  {
5301  "submit_multisigned",
5302  R"({"json_argument":true})",
5303  },
5305  R"({
5306  "method" : "submit_multisigned",
5307  "params" : [
5308  {
5309  "api_version" : %MAX_API_VER%,
5310  "tx_json" : {
5311  "json_argument" : true
5312  }
5313  }
5314  ]
5315  })"},
5316  {"submit_multisigned: too few arguments.",
5317  __LINE__,
5318  {
5319  "submit_multisigned",
5320  },
5322  R"({
5323  "method" : "submit_multisigned",
5324  "params" : [
5325  {
5326  "error" : "badSyntax",
5327  "error_code" : 1,
5328  "error_message" : "Syntax error."
5329  }
5330  ]
5331  })"},
5332  {"submit_multisigned: too many arguments.",
5333  __LINE__,
5334  {"submit_multisigned", R"({"json_argument":true})", "extra"},
5336  R"({
5337  "method" : "submit_multisigned",
5338  "params" : [
5339  {
5340  "error" : "badSyntax",
5341  "error_code" : 1,
5342  "error_message" : "Syntax error."
5343  }
5344  ]
5345  })"},
5346  {"submit_multisigned: invalid json (note extra comma).",
5347  __LINE__,
5348  {
5349  "submit_multisigned",
5350  R"({"json_argument":true,})",
5351  },
5353  R"({
5354  "method" : "submit_multisigned",
5355  "params" : [
5356  {
5357  "error" : "invalidParams",
5358  "error_code" : 31,
5359  "error_message" : "Invalid parameters."
5360  }
5361  }
5362  ]
5363  })"},
5364 
5365  // server_info
5366  // -----------------------------------------------------------------
5367  {"server_info: minimal.",
5368  __LINE__,
5369  {
5370  "server_info",
5371  },
5373  R"({
5374  "method" : "server_info",
5375  "params" : [
5376  {
5377  "api_version" : %MAX_API_VER%,
5378  }
5379  ]
5380  })"},
5381  {"server_info: counters.",
5382  __LINE__,
5383  {"server_info", "counters"},
5385  R"({
5386  "method" : "server_info",
5387  "params" : [
5388  {
5389  "api_version" : %MAX_API_VER%,
5390  "counters" : true
5391  }
5392  ]
5393  })"},
5394  {"server_info: too many arguments.",
5395  __LINE__,
5396  {"server_info", "counters", "extra"},
5398  R"({
5399  "method" : "server_info",
5400  "params" : [
5401  {
5402  "error" : "badSyntax",
5403  "error_code" : 1,
5404  "error_message" : "Syntax error."
5405  }
5406  ]
5407  })"},
5408  {"server_info: non-counters argument.",
5409  __LINE__,
5410  {"server_info", "counter"},
5412  R"({
5413  "method" : "server_info",
5414  "params" : [
5415  {
5416  "api_version" : %MAX_API_VER%,
5417  }
5418  ]
5419  })"},
5420 
5421  // server_state
5422  // ----------------------------------------------------------------
5423  {"server_state: minimal.",
5424  __LINE__,
5425  {
5426  "server_state",
5427  },
5429  R"({
5430  "method" : "server_state",
5431  "params" : [
5432  {
5433  "api_version" : %MAX_API_VER%,
5434  }
5435  ]
5436  })"},
5437  {"server_state: counters.",
5438  __LINE__,
5439  {"server_state", "counters"},
5441  R"({
5442  "method" : "server_state",
5443  "params" : [
5444  {
5445  "api_version" : %MAX_API_VER%,
5446  "counters" : true
5447  }
5448  ]
5449  })"},
5450  {"server_state: too many arguments.",
5451  __LINE__,
5452  {"server_state", "counters", "extra"},
5454  R"({
5455  "method" : "server_state",
5456  "params" : [
5457  {
5458  "error" : "badSyntax",
5459  "error_code" : 1,
5460  "error_message" : "Syntax error."
5461  }
5462  ]
5463  })"},
5464  {"server_state: non-counters argument.",
5465  __LINE__,
5466  {"server_state", "counter"},
5468  R"({
5469  "method" : "server_state",
5470  "params" : [
5471  {
5472  "api_version" : %MAX_API_VER%,
5473  }
5474  ]
5475  })"},
5476 
5477  // stop
5478  // ------------------------------------------------------------------------
5479  {"stop: minimal.",
5480  __LINE__,
5481  {
5482  "stop",
5483  },
5485  R"({
5486  "method" : "stop",
5487  "params" : [
5488  {
5489  "api_version" : %MAX_API_VER%,
5490  }
5491  ]
5492  })"},
5493  {"stop: too many arguments.",
5494  __LINE__,
5495  {"stop", "extra"},
5497  R"({
5498  "method" : "stop",
5499  "params" : [
5500  {
5501  "error" : "badSyntax",
5502  "error_code" : 1,
5503  "error_message" : "Syntax error."
5504  }
5505  ]
5506  })"},
5507 
5508  // transaction_entry
5509  // -----------------------------------------------------------
5510  {"transaction_entry: ledger index.",
5511  __LINE__,
5512  {"transaction_entry",
5513  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5514  "4294967295"},
5516  R"({
5517  "method" : "transaction_entry",
5518  "params" : [
5519  {
5520  "api_version" : %MAX_API_VER%,
5521  "ledger_index" : 4294967295,
5522  "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5523  }
5524  ]
5525  })"},
5526  {"transaction_entry: text ledger index.",
5527  __LINE__,
5528  {"transaction_entry",
5529  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5530  "current"},
5532  R"({
5533  "method" : "transaction_entry",
5534  "params" : [
5535  {
5536  "api_version" : %MAX_API_VER%,
5537  "ledger_index" : "current",
5538  "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5539  }
5540  ]
5541  })"},
5542  {"transaction_entry: ledger hash.",
5543  __LINE__,
5544  {"transaction_entry",
5545  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5546  "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210"},
5548  R"({
5549  "method" : "transaction_entry",
5550  "params" : [
5551  {
5552  "api_version" : %MAX_API_VER%,
5553  "ledger_hash" : "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210",
5554  "tx_hash" : "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV"
5555  }
5556  ]
5557  })"},
5558  {"transaction_entry: too few arguments.",
5559  __LINE__,
5560  {
5561  "transaction_entry",
5562  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5563  },
5565  R"({
5566  "method" : "transaction_entry",
5567  "params" : [
5568  {
5569  "error" : "badSyntax",
5570  "error_code" : 1,
5571  "error_message" : "Syntax error."
5572  }
5573  ]
5574  })"},
5575  {"transaction_entry: too many arguments.",
5576  __LINE__,
5577  {"transaction_entry",
5578  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5579  "validated",
5580  "extra"},
5582  R"({
5583  "method" : "transaction_entry",
5584  "params" : [
5585  {
5586  "error" : "badSyntax",
5587  "error_code" : 1,
5588  "error_message" : "Syntax error."
5589  }
5590  ]
5591  })"},
5592  {"transaction_entry: short tx_hash.",
5593  __LINE__,
5594  {
5595  "transaction_entry",
5596  "123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5597  "validated",
5598  },
5600  R"({
5601  "method" : "transaction_entry",
5602  "params" : [
5603  {
5604  "error" : "invalidParams",
5605  "error_code" : 31,
5606  "error_message" : "Invalid parameters."
5607  }
5608  ]
5609  })"},
5610  {"transaction_entry: long tx_hash.",
5611  __LINE__,
5612  {
5613  "transaction_entry",
5614  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUVW",
5615  "validated",
5616  },
5618  R"({
5619  "method" : "transaction_entry",
5620  "params" : [
5621  {
5622  "error" : "invalidParams",
5623  "error_code" : 31,
5624  "error_message" : "Invalid parameters."
5625  }
5626  ]
5627  })"},
5628  {"transaction_entry: small ledger index.",
5629  __LINE__,
5630  {
5631  "transaction_entry",
5632  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5633  "0",
5634  },
5636  R"({
5637  "method" : "transaction_entry",
5638  "params" : [
5639  {
5640  "error" : "invalidParams",
5641  "error_code" : 31,
5642  "error_message" : "Invalid parameters."
5643  }
5644  ]
5645  })"},
5646  {"transaction_entry: large ledger index.",
5647  __LINE__,
5648  {
5649  "transaction_entry",
5650  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5651  "4294967296",
5652  },
5654  R"({
5655  "method" : "transaction_entry",
5656  "params" : [
5657  {
5658  "error" : "invalidParams",
5659  "error_code" : 31,
5660  "error_message" : "Invalid parameters."
5661  }
5662  ]
5663  })"},
5664  {"transaction_entry: short ledger hash.",
5665  __LINE__,
5666  {
5667  "transaction_entry",
5668  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5669  "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA987654321",
5670  },
5672  R"({
5673  "method" : "transaction_entry",
5674  "params" : [
5675  {
5676  "error" : "invalidParams",
5677  "error_code" : 31,
5678  "error_message" : "Invalid parameters."
5679  }
5680  ]
5681  })"},
5682  {"transaction_entry: long ledger hash.",
5683  __LINE__,
5684  {
5685  "transaction_entry",
5686  "0123456789ABCDEFGHIJKLMNOPQRSTUV0123456789ABCDEFGHIJKLMNOPQRSTUV",
5687  "VUTSRQPONMLKJIHGFEDCBA9876543210VUTSRQPONMLKJIHGFEDCBA9876543210Z",
5688  },
5690  R"({
5691  "method" : "transaction_entry",
5692  "params" : [
5693  {
5694  "error" : "invalidParams",
5695  "error_code" : 31,
5696  "error_message" : "Invalid parameters."
5697  }
5698  ]
5699  })"},
5700 
5701  // tx
5702  // --------------------------------------------------------------------------
5703  {"tx: minimal.",
5704  __LINE__,
5705  {"tx", "transaction_hash_is_not_validated"},
5707  R"({
5708  "method" : "tx",
5709  "params" : [
5710  {
5711  "api_version" : %MAX_API_VER%,
5712  "transaction" : "transaction_hash_is_not_validated"
5713  }
5714  ]
5715  })"},
5716  {"tx: binary.",
5717  __LINE__,
5718  {"tx", "transaction_hash_is_not_validated", "binary"},
5720  R"({
5721  "method" : "tx",
5722  "params" : [
5723  {
5724  "api_version" : %MAX_API_VER%,
5725  "binary" : true,
5726  "transaction" : "transaction_hash_is_not_validated"
5727  }
5728  ]
5729  })"},
5730  {"tx: too few arguments.",
5731  __LINE__,
5732  {
5733  "tx",
5734  },
5736  R"({
5737  "method" : "tx",
5738  "params" : [
5739  {
5740  "error" : "badSyntax",
5741  "error_code" : 1,
5742  "error_message" : "Syntax error."
5743  }
5744  ]
5745  })"},
5746  {"tx: too many arguments.",
5747  __LINE__,
5748  {"tx", "transaction_hash_is_not_validated", "binary", "1", "2", "extra"},
5750  R"({
5751  "method" : "tx",
5752  "params" : [
5753  {
5754  "error" : "badSyntax",
5755  "error_code" : 1,
5756  "error_message" : "Syntax error."
5757  }
5758  ]
5759  })"},
5760  {"tx: invalid final argument is apparently ignored.",
5761  __LINE__,
5762  {"tx", "transaction_hash_is_not_validated", "bin"},
5764  R"({
5765  "method" : "tx",
5766  "params" : [
5767  {
5768  "api_version" : %MAX_API_VER%,
5769  "transaction" : "transaction_hash_is_not_validated"
5770  }
5771  ]
5772  })"},
5773 
5774  // tx_account
5775  // ------------------------------------------------------------------
5776  {"tx_account: minimal.",
5777  __LINE__,
5778  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"},
5780  R"({
5781  "method" : "tx_account",
5782  "params" : [
5783  {
5784  "api_version" : %MAX_API_VER%,
5785  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5786  }
5787  ]
5788  })"},
5789  {"tx_account: ledger_index .",
5790  __LINE__,
5791  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "4294967295"},
5793  R"({
5794  "method" : "tx_account",
5795  "params" : [
5796  {
5797  "api_version" : %MAX_API_VER%,
5798  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5799  "ledger_index" : 4294967295
5800  }
5801  ]
5802  })"},
5803  {"tx_account: ledger_index plus trailing params.",
5804  __LINE__,
5805  {"tx_account",
5806  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5807  "707",
5808  "forward",
5809  "binary",
5810  "count"},
5812  R"({
5813  "method" : "tx_account",
5814  "params" : [
5815  {
5816  "api_version" : %MAX_API_VER%,
5817  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5818  "binary" : true,
5819  "count" : true,
5820  "forward" : true,
5821  "ledger_index" : 707
5822  }
5823  ]
5824  })"},
5825  {"tx_account: ledger_index_min and _max.",
5826  __LINE__,
5827  {"tx_account",
5828  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5829  "2147483647",
5830  "2147483647"},
5832  R"({
5833  "method" : "tx_account",
5834  "params" : [
5835  {
5836  "api_version" : %MAX_API_VER%,
5837  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5838  "ledger_index_max" : 2147483647,
5839  "ledger_index_min" : 2147483647
5840  }
5841  ]
5842  })"},
5843  {"tx_account: ledger_index_min and _max plus trailing params.",
5844  __LINE__,
5845  {"tx_account",
5846  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5847  "33333",
5848  "2147483647",
5849  "binary",
5850  "count",
5851  "forward"},
5853  R"({
5854  "method" : "tx_account",
5855  "params" : [
5856  {
5857  "api_version" : %MAX_API_VER%,
5858  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5859  "binary" : true,
5860  "count" : true,
5861  "forward" : true,
5862  "ledger_index_max" : 2147483647,
5863  "ledger_index_min" : 33333
5864  }
5865  ]
5866  })"},
5867  {"tx_account: ledger_index_min and _max plus limit.",
5868  __LINE__,
5869  {"tx_account",
5870  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5871  "-1",
5872  "2147483647",
5873  "2147483647"},
5875  R"({
5876  "method" : "tx_account",
5877  "params" : [
5878  {
5879  "api_version" : %MAX_API_VER%,
5880  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5881  "ledger_index_max" : 2147483647,
5882  "ledger_index_min" : -1,
5883  "limit" : 2147483647
5884  }
5885  ]
5886  })"},
5887  {"tx_account: ledger_index_min and _max, limit, trailing args.",
5888  __LINE__,
5889  {"tx_account",
5890  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5891  "1",
5892  "1",
5893  "-1",
5894  "count",
5895  "forward",
5896  "binary"},
5898  R"({
5899  "method" : "tx_account",
5900  "params" : [
5901  {
5902  "api_version" : %MAX_API_VER%,
5903  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5904  "binary" : true,
5905  "count" : true,
5906  "forward" : true,
5907  "ledger_index_max" : 1,
5908  "ledger_index_min" : 1,
5909  "limit" : -1
5910  }
5911  ]
5912  })"},
5913  {"tx_account: too few arguments.",
5914  __LINE__,
5915  {
5916  "tx_account",
5917  },
5919  R"({
5920  "method" : "tx_account",
5921  "params" : [
5922  {
5923  "error" : "badSyntax",
5924  "error_code" : 1,
5925  "error_message" : "Syntax error."
5926  }
5927  ]
5928  })"},
5929  {"tx_account: too many arguments.",
5930  __LINE__,
5931  {"tx_account",
5932  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5933  "589",
5934  "590",
5935  "67",
5936  "extra",
5937  "descending",
5938  "count",
5939  "binary"},
5941  R"({
5942  "method" : "tx_account",
5943  "params" : [
5944  {
5945  "error" : "badSyntax",
5946  "error_code" : 1,
5947  "error_message" : "Syntax error."
5948  }
5949  ]
5950  })"},
5951  {
5952  "tx_account: invalid accountID.",
5953  __LINE__,
5954  {"tx_account", "rHb9CJAWyB4rj9!VRWn96DkukG4bwdtyTh"},
5956  R"({
5957  "method" : "tx_account",
5958  "params" : [
5959  {
5960  "error" : "actMalformed",
5961  "error_code" : 35,
5962  "error_message" : "Account malformed."
5963  }
5964  ]
5965  })",
5966  },
5967  {
5968  // Note: not currently detected as bad input.
5969  "tx_account: invalid ledger.",
5970  __LINE__,
5971  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-478.7"},
5973  R"({
5974  "method" : "tx_account",
5975  "params" : [
5976  {
5977  "api_version" : %MAX_API_VER%,
5978  "account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
5979  "ledger_index" : 0
5980  }
5981  ]
5982  })",
5983  },
5984  {
5985  "tx_account: max less than min.",
5986  __LINE__,
5987  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "580", "579"},
5990  R"({
5991  "method" : "tx_account",
5992  "params" : [
5993  {
5994  "error" : "lgrIdxsInvalid",
5995  "error_code" : 55,
5996  "error_message" : "Ledger indexes invalid."
5997  }
5998  ]
5999  })"
6000  :
6001  R"({
6002  "method" : "tx_account",
6003  "params" : [
6004  {
6005  "error" : "notSynced",
6006  "error_code" : 55,
6007  "error_message" : "Not synced to the network."
6008  }
6009  ]
6010  })",
6011  },
6012  {
6013  // Note: this really shouldn't throw, but does at the moment.
6014  "tx_account: min large but still valid.",
6015  __LINE__,
6016  {"tx_account",
6017  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
6018  "2147483648",
6019  "2147483648"},
6021  R"()",
6022  },
6023  {
6024  // Note: this really shouldn't throw, but does at the moment.
6025  "tx_account: max large but still valid.",
6026  __LINE__,
6027  {"tx_account",
6028  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
6029  "2147483647",
6030  "2147483648"},
6032  R"()",
6033  },
6034  {
6035  // Note: this really shouldn't throw, but does at the moment.
6036  "tx_account: large limit.",
6037  __LINE__,
6038  {"tx_account",
6039  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
6040  "-1",
6041  "-1",
6042  "2147483648"},
6044  R"()",
6045  },
6046  {
6047  // Note: this really shouldn't throw, but does at the moment.
6048  "tx_account: non-integer min.",
6049  __LINE__,
6050  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Binary", "-1"},
6052  R"()",
6053  },
6054  {
6055  // Note: this really shouldn't throw, but does at the moment.
6056  "tx_account: non-integer max.",
6057  __LINE__,
6058  {"tx_account", "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "-1", "counts"},
6060  R"()",
6061  },
6062  {
6063  // Note: this really shouldn't throw, but does at the moment.
6064  "tx_account: non-integer limit.",
6065  __LINE__,
6066  {"tx_account",
6067  "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
6068  "-1",
6069  "-1",
6070  "decending"},
6072  R"()",
6073  },
6074 
6075  // tx_history
6076  // ------------------------------------------------------------------
6077  {"tx_history: minimal.",
6078  __LINE__,
6079  {"tx_history", "0"},
6081  R"({
6082  "method" : "tx_history",
6083  "params" : [
6084  {
6085  "api_version" : %MAX_API_VER%,
6086  "start" : 0
6087  }
6088  ]
6089  })"},
6090  {"tx_history: too few arguments.",
6091  __LINE__,
6092  {
6093  "tx_history",
6094  },
6096  R"({
6097  "method" : "tx_history",
6098  "params" : [
6099  {
6100  "error" : "badSyntax",
6101  "error_code" : 1,
6102  "error_message" : "Syntax error."
6103  }
6104  ]
6105  })"},
6106  {"tx_history: too many arguments.",
6107  __LINE__,
6108  {"tx_history", "0", "1"},
6110  R"({
6111  "method" : "tx_history",
6112  "params" : [
6113  {
6114  "error" : "badSyntax",
6115  "error_code" : 1,
6116  "error_message" : "Syntax error."
6117  }
6118  ]
6119  })"},
6120  {
6121  // Note: this really shouldn't throw, but does at the moment.
6122  "tx_history: start too small.",
6123  __LINE__,
6124  {"tx_history", "-1"},
6126  R"()",
6127  },
6128  {
6129  // Note: this really shouldn't throw, but does at the moment.
6130  "tx_history: start too big.",
6131  __LINE__,
6132  {"tx_history", "4294967296"},
6134  R"()",
6135  },
6136  {
6137  // Note: this really shouldn't throw, but does at the moment.
6138  "tx_history: start not integer.",
6139  __LINE__,
6140  {"tx_history", "beginning"},
6142  R"()",
6143  },
6144 
6145  // unl_list
6146  // --------------------------------------------------------------------
6147  {"unl_list: minimal.",
6148  __LINE__,
6149  {
6150  "unl_list",
6151  },
6153  R"({
6154  "method" : "unl_list",
6155  "params" : [
6156  {
6157  "api_version" : %MAX_API_VER%,
6158  }
6159  ]
6160  })"},
6161  {"unl_list: too many arguments.",
6162  __LINE__,
6163  {"unl_list", "extra"},
6165  R"({
6166  "method" : "unl_list",
6167  "params" : [
6168  {
6169  "error" : "badSyntax",
6170  "error_code" : 1,
6171  "error_message" : "Syntax error."
6172  }
6173  ]
6174  })"},
6175 
6176  // validation_create
6177  // -----------------------------------------------------------
6178  {"validation_create: minimal.",
6179  __LINE__,
6180  {
6181  "validation_create",
6182  },
6184  R"({
6185  "method" : "validation_create",
6186  "params" : [
6187  {
6188  "api_version" : %MAX_API_VER%,
6189  }
6190  ]
6191  })"},
6192  {"validation_create: with secret.",
6193  __LINE__,
6194  {"validation_create", "the form of the secret is not validated"},
6196  R"({
6197  "method" : "validation_create",
6198  "params" : [
6199  {
6200  "api_version" : %MAX_API_VER%,
6201  "secret" : "the form of the secret is not validated"
6202  }
6203  ]
6204  })"},
6205  {"validation_create: too many arguments.",
6206  __LINE__,
6207  {"validation_create", "the form of the secret is not validated", "extra"},
6209  R"({
6210  "method" : "validation_create",
6211  "params" : [
6212  {
6213  "error" : "badSyntax",
6214  "error_code" : 1,
6215  "error_message" : "Syntax error."
6216  }
6217  ]
6218  })"},
6219 
6220  // version
6221  // ---------------------------------------------------------------------
6222  {"version: minimal.",
6223  __LINE__,
6224  {
6225  "version",
6226  },
6228  R"({
6229  "method" : "version",
6230  "params" : [
6231  {
6232  "api_version" : %MAX_API_VER%,
6233  }
6234  ]
6235  })"},
6236  {"version: too many arguments.",
6237  __LINE__,
6238  {"version", "extra"},
6240  R"({
6241  "method" : "version",
6242  "params" : [
6243  {
6244  "error" : "badSyntax",
6245  "error_code" : 1,
6246  "error_message" : "Syntax error."
6247  }
6248  ]
6249  })"},
6250 
6251  // wallet_propose
6252  // --------------------------------------------------------------
6253  {"wallet_propose: minimal.",
6254  __LINE__,
6255  {
6256  "wallet_propose",
6257  },
6259  R"({
6260  "method" : "wallet_propose",
6261  "params" : [
6262  {
6263  "api_version" : %MAX_API_VER%,
6264  }
6265  ]
6266  })"},
6267  {"wallet_propose: with passphrase.",
6268  __LINE__,
6269  {"wallet_propose", "the form of the passphrase is not validated"},
6271  R"({
6272  "method" : "wallet_propose",
6273  "params" : [
6274  {
6275  "api_version" : %MAX_API_VER%,
6276  "passphrase" : "the form of the passphrase is not validated"
6277  }
6278  ]
6279  })"},
6280  {"wallet_propose: too many arguments.",
6281  __LINE__,
6282  {"wallet_propose", "the form of the passphrase is not validated", "extra"},
6284  R"({
6285  "method" : "wallet_propose",
6286  "params" : [
6287  {
6288  "error" : "badSyntax",
6289  "error_code" : 1,
6290  "error_message" : "Syntax error."
6291  }
6292  ]
6293  })"},
6294 
6295  // internal
6296  // --------------------------------------------------------------------
6297  {"internal: minimal.",
6298  __LINE__,
6299  {"internal", "command_name"},
6301  R"({
6302  "method" : "internal",
6303  "params" : [
6304  {
6305  "api_version" : %MAX_API_VER%,
6306  "internal_command" : "command_name",
6307  "params" : []
6308  }
6309  ]
6310  })"},
6311  {"internal: with parameters.",
6312  __LINE__,
6313  {"internal",
6314  "command_name",
6315  "string_arg",
6316  "1",
6317  "-1",
6318  "4294967296",
6319  "3.14159"},
6321  R"({
6322  "method" : "internal",
6323  "params" : [
6324  {
6325  "api_version" : %MAX_API_VER%,
6326  "internal_command" : "command_name",
6327  "params" : [ "string_arg", "1", "-1", "4294967296", "3.14159" ]
6328  }
6329  ]
6330  })"},
6331  {"internal: too few arguments.",
6332  __LINE__,
6333  {
6334  "internal",
6335  },
6337  R"({
6338  "method" : "internal",
6339  "params" : [
6340  {
6341  "error" : "badSyntax",
6342  "error_code" : 1,
6343  "error_message" : "Syntax error."
6344  }
6345  ]
6346  })"},
6347 
6348  // path_find
6349  // -------------------------------------------------------------------
6350  {"path_find: minimal.",
6351  __LINE__,
6352  {
6353  "path_find",
6354  },
6356  R"({
6357  "method" : "path_find",
6358  "params" : [
6359  {
6360  "error" : "noEvents",
6361  "error_code" : 7,
6362  "error_message" : "Current transport does not support events."
6363  }
6364  ]
6365  })"},
6366  {"path_find: with arguments.",
6367  __LINE__,
6368  {"path_find", "string_arg", "1", "-1", "4294967296", "3.14159"},
6370  R"({
6371  "method" : "path_find",
6372  "params" : [
6373  {
6374  "error" : "noEvents",
6375  "error_code" : 7,
6376  "error_message" : "Current transport does not support events."
6377  }
6378  ]
6379  })"},
6380 
6381  // subscribe
6382  // -------------------------------------------------------------------
6383  {"subscribe: minimal.",
6384  __LINE__,
6385  {
6386  "subscribe",
6387  },
6389  R"({
6390  "method" : "subscribe",
6391  "params" : [
6392  {
6393  "error" : "noEvents",
6394  "error_code" : 7,
6395  "error_message" : "Current transport does not support events."
6396  }
6397  ]
6398  })"},
6399  {"subscribe: with arguments.",
6400  __LINE__,
6401  {"subscribe", "string_arg", "1", "-1", "4294967296", "3.14159"},
6403  R"({
6404  "method" : "subscribe",
6405  "params" : [
6406  {
6407  "error" : "noEvents",
6408  "error_code" : 7,
6409  "error_message" : "Current transport does not support events."
6410  }
6411  ]
6412  })"},
6413 
6414  // unsubscribe
6415  // -----------------------------------------------------------------
6416  {"unsubscribe: minimal.",
6417  __LINE__,
6418  {
6419  "unsubscribe",
6420  },
6422  R"({
6423  "method" : "unsubscribe",
6424  "params" : [
6425  {
6426  "error" : "noEvents",
6427  "error_code" : 7,
6428  "error_message" : "Current transport does not support events."
6429  }
6430  ]
6431  })"},
6432  {"unsubscribe: with arguments.",
6433  __LINE__,
6434  {"unsubscribe", "string_arg", "1", "-1", "4294967296", "3.14159"},
6436  R"({
6437  "method" : "unsubscribe",
6438  "params" : [
6439  {
6440  "error" : "noEvents",
6441  "error_code" : 7,
6442  "error_message" : "Current transport does not support events."
6443  }
6444  ]
6445  })"},
6446 
6447  // unknown_command
6448  // -------------------------------------------------------------
6449  {"unknown_command: minimal.",
6450  __LINE__,
6451  {
6452  "unknown_command",
6453  },
6455  R"({
6456  "method" : "unknown_command",
6457  "params" : [
6458  {
6459  "api_version" : %MAX_API_VER%,
6460  }
6461  ]
6462  })"},
6463  {"unknown_command: with arguments.",
6464  __LINE__,
6465  {"unknown_command", "string_arg", "1", "-1", "4294967296", "3.14159"},
6467  R"({
6468  "method" : "unknown_command",
6469  "params" : [
6470  {
6471  "api_version" : %MAX_API_VER%,
6472  "params" : [ "string_arg", "1", "-1", "4294967296", "3.14159" ]
6473  }
6474  ]
6475  })"},
6476 };
6477 
6479 updateAPIVersionString(const char* const req)
6480 {
6481  static std::string version_str =
6483  static auto place_holder = "%MAX_API_VER%";
6484  std::string jr(req);
6485  boost::replace_all(jr, place_holder, version_str);
6486  return jr;
6487 }
6488 
6489 class RPCCall_test : public beast::unit_test::suite
6490 {
6491 public:
6492  void
6494  {
6495  testcase << "RPCCall";
6496 
6497  test::jtx::Env env(*this); // Used only for its Journal.
6498 
6499  // For each RPCCall test.
6500  for (RPCCallTestData const& rpcCallTest : rpcCallTestArray)
6501  {
6502  std::vector<std::string> const args{
6503  rpcCallTest.args.begin(), rpcCallTest.args.end()};
6504 
6505  // Note that, over the long term, none of these tests should
6506  // throw. But, for the moment, some of them do. So handle it.
6507  Json::Value got;
6508  try
6509  {
6510  got = cmdLineToJSONRPC(args, env.journal);
6511  }
6512  catch (std::bad_cast const&)
6513  {
6514  if ((rpcCallTest.throwsWhat == RPCCallTestData::bad_cast) &&
6515  (std::strlen(rpcCallTest.exp) == 0))
6516  {
6517  pass();
6518  }
6519  else
6520  {
6521  fail(rpcCallTest.description, __FILE__, rpcCallTest.line);
6522  }
6523  // Try the next test.
6524  continue;
6525  }
6526 
6527  Json::Value exp;
6528  Json::Reader{}.parse(updateAPIVersionString(rpcCallTest.exp), exp);
6529 
6530  // Lambda to remove the "params[0u]:error_code" field if present.
6531  // Error codes are not expected to be stable between releases.
6532  auto rmErrorCode = [](Json::Value& json) {
6533  if (json.isMember(jss::params) && json[jss::params].isArray() &&
6534  json[jss::params].size() > 0 &&
6535  json[jss::params][0u].isObject())
6536  {
6537  json[jss::params][0u].removeMember(jss::error_code);
6538  }
6539  };
6540  rmErrorCode(got);
6541  rmErrorCode(exp);
6542 
6543  // Pass if we didn't expect a throw and we got what we expected.
6544  if ((rpcCallTest.throwsWhat == RPCCallTestData::no_exception) &&
6545  (got == exp))
6546  {
6547  pass();
6548  }
6549  else
6550  {
6551  fail(rpcCallTest.description, __FILE__, rpcCallTest.line);
6552  }
6553  }
6554  }
6555 
6556  void
6557  run() override
6558  {
6559  testRPCCall();
6560  }
6561 };
6562 
6563 BEAST_DEFINE_TESTSUITE(RPCCall, app, ripple);
6564 
6565 } // namespace test
6566 } // namespace ripple
ripple::test::jtx::json
Inject raw JSON.
Definition: jtx_json.h:31
std::strlen
T strlen(T... args)
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:144
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:6493
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::test::RPCCallTestData::Exception
Exception
Definition: RPCCall_test.cpp:40
ripple::test::RPCCallTestData
Definition: RPCCall_test.cpp:32
ripple::cmdLineToJSONRPC
Json::Value cmdLineToJSONRPC(std::vector< std::string > const &args, beast::Journal j)
Given a rippled command line, return the corresponding JSON.
Definition: RPCCall.cpp:1490
ripple::test::RPCCallTestData::exp
char const *const exp
Definition: RPCCall_test.cpp:44
ripple::test::RPCCallTestData::description
char const *const description
Definition: RPCCall_test.cpp:34
std::vector::begin
T begin(T... args)
ripple::test::RPCCallTestData::RPCCallTestData
RPCCallTestData()=delete
Json::Reader::parse
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Definition: json_reader.cpp:74
ripple::RPC::apiMaximumSupportedVersion
constexpr unsigned int apiMaximumSupportedVersion
Definition: RPCHelpers.h:244
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:116
ripple::test::RPCCall_test::run
void run() override
Definition: RPCCall_test.cpp:6557
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:6479
ripple::test::RPCCall_test
Definition: RPCCall_test.cpp:6489
initializer_list
ripple::test::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(DeliverMin, app, ripple)