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