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