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