@@ -144,176 +144,192 @@ class AccountTx_test : public beast::unit_test::suite
144
144
Json::Value jParms;
145
145
jParms[jss::api_version] = apiVersion;
146
146
147
- if (apiVersion < 2 )
148
- {
149
- BEAST_EXPECT (isErr (
150
- env.rpc (" json" , " account_tx" , to_string (jParms)),
151
- rpcINVALID_PARAMS));
147
+ BEAST_EXPECT (isErr (
148
+ env.rpc (" json" , " account_tx" , to_string (jParms)),
149
+ rpcINVALID_PARAMS));
152
150
153
- jParms[jss::account] = " 0xDEADBEEF" ;
151
+ jParms[jss::account] = " 0xDEADBEEF" ;
154
152
155
- BEAST_EXPECT (isErr (
156
- env.rpc (" json" , " account_tx" , to_string (jParms)),
157
- rpcACT_MALFORMED));
153
+ BEAST_EXPECT (isErr (
154
+ env.rpc (" json" , " account_tx" , to_string (jParms)),
155
+ rpcACT_MALFORMED));
158
156
159
- jParms[jss::account] = A1.human ();
160
- BEAST_EXPECT (
161
- hasTxs (env.rpc (" json" , " account_tx" , to_string (jParms))));
157
+ jParms[jss::account] = A1.human ();
158
+ BEAST_EXPECT (hasTxs (env.rpc (" json" , " account_tx" , to_string (jParms))));
162
159
163
- // Ledger min/max index
164
- {
165
- Json::Value p{jParms};
166
- p[jss::ledger_index_min] = -1 ;
167
- p[jss::ledger_index_max] = -1 ;
168
- BEAST_EXPECT (
169
- hasTxs (env. rpc ( " json " , " account_tx " , to_string (p))));
170
-
171
- p[jss::ledger_index_min ] = 0 ;
172
- p[jss::ledger_index_max] = 100 ;
160
+ // Ledger min/max index
161
+ {
162
+ Json::Value p{jParms};
163
+ p[jss::ledger_index_min] = -1 ;
164
+ p[jss::ledger_index_max] = -1 ;
165
+ BEAST_EXPECT ( hasTxs (env. rpc ( " json " , " account_tx " , to_string (p))));
166
+
167
+ p[jss::ledger_index_min] = 0 ;
168
+ p[jss::ledger_index_max ] = 100 ;
169
+ if (apiVersion < 2u )
173
170
BEAST_EXPECT (
174
171
hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
172
+ else
173
+ BEAST_EXPECT (isErr (
174
+ env.rpc (" json" , " account_tx" , to_string (p)),
175
+ rpcLGR_IDX_MALFORMED));
175
176
176
- p[jss::ledger_index_min] = 1 ;
177
- p[jss::ledger_index_max] = 2 ;
177
+ p[jss::ledger_index_min] = 1 ;
178
+ p[jss::ledger_index_max] = 2 ;
179
+ if (apiVersion < 2u )
178
180
BEAST_EXPECT (
179
181
noTxs (env.rpc (" json" , " account_tx" , to_string (p))));
180
-
181
- p[jss::ledger_index_min] = 2 ;
182
- p[jss::ledger_index_max] = 1 ;
182
+ else
183
183
BEAST_EXPECT (isErr (
184
184
env.rpc (" json" , " account_tx" , to_string (p)),
185
- (RPC::apiMaximumSupportedVersion == 1
186
- ? rpcLGR_IDXS_INVALID
187
- : rpcINVALID_LGR_RANGE)));
188
- }
185
+ rpcLGR_IDX_MALFORMED));
189
186
190
- // Ledger index min only
191
- {
192
- Json::Value p{jParms};
193
- p[jss::ledger_index_min] = -1 ;
194
- BEAST_EXPECT (
195
- hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
187
+ p[jss::ledger_index_min] = 2 ;
188
+ p[jss::ledger_index_max] = 1 ;
189
+ BEAST_EXPECT (isErr (
190
+ env.rpc (" json" , " account_tx" , to_string (p)),
191
+ (apiVersion == 1 ? rpcLGR_IDXS_INVALID
192
+ : rpcINVALID_LGR_RANGE)));
193
+ }
194
+ // Ledger index min only
195
+ {
196
+ Json::Value p{jParms};
197
+ p[jss::ledger_index_min] = -1 ;
198
+ BEAST_EXPECT (hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
196
199
197
- p[jss::ledger_index_min] = 1 ;
200
+ p[jss::ledger_index_min] = 1 ;
201
+ if (apiVersion < 2u )
198
202
BEAST_EXPECT (
199
203
hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
200
-
201
- p[jss::ledger_index_min] = env.current ()->info ().seq ;
204
+ else
202
205
BEAST_EXPECT (isErr (
203
206
env.rpc (" json" , " account_tx" , to_string (p)),
204
- (RPC::apiMaximumSupportedVersion == 1
205
- ? rpcLGR_IDXS_INVALID
206
- : rpcINVALID_LGR_RANGE)));
207
- }
207
+ rpcLGR_IDX_MALFORMED));
208
208
209
- // Ledger index max only
210
- {
211
- Json::Value p{jParms};
212
- p[jss::ledger_index_max] = - 1 ;
213
- BEAST_EXPECT (
214
- hasTxs (env. rpc ( " json " , " account_tx " , to_string (p))));
209
+ p[jss::ledger_index_min] = env. current ()-> info (). seq ;
210
+ BEAST_EXPECT ( isErr (
211
+ env. rpc ( " json " , " account_tx " , to_string (p)),
212
+ (apiVersion == 1 ? rpcLGR_IDXS_INVALID
213
+ : rpcINVALID_LGR_RANGE)));
214
+ }
215
215
216
- p[jss::ledger_index_max] = env.current ()->info ().seq ;
217
- BEAST_EXPECT (
218
- hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
216
+ // Ledger index max only
217
+ {
218
+ Json::Value p{jParms};
219
+ p[jss::ledger_index_max] = -1 ;
220
+ BEAST_EXPECT (hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
219
221
220
- p[jss::ledger_index_max] = 3 ;
222
+ p[jss::ledger_index_max] = env.current ()->info ().seq ;
223
+ if (apiVersion < 2u )
221
224
BEAST_EXPECT (
222
225
hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
226
+ else
227
+ BEAST_EXPECT (isErr (
228
+ env.rpc (" json" , " account_tx" , to_string (p)),
229
+ rpcLGR_IDX_MALFORMED));
223
230
224
- p[jss::ledger_index_max] = env.closed ()->info ().seq ;
225
- BEAST_EXPECT (
226
- hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
231
+ p[jss::ledger_index_max] = 3 ;
232
+ BEAST_EXPECT (hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
227
233
228
- p[jss::ledger_index_max] = env.closed ()->info ().seq - 1 ;
229
- BEAST_EXPECT (
230
- noTxs (env.rpc (" json" , " account_tx" , to_string (p))));
231
- }
234
+ p[jss::ledger_index_max] = env.closed ()->info ().seq ;
235
+ BEAST_EXPECT (hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
232
236
233
- // Ledger Sequence
234
- {
235
- Json::Value p{jParms};
237
+ p[jss::ledger_index_max] = env. closed ()-> info (). seq - 1 ;
238
+ BEAST_EXPECT ( noTxs (env. rpc ( " json " , " account_tx " , to_string (p))));
239
+ }
236
240
237
- p[jss::ledger_index] = env. closed ()-> info (). seq ;
238
- BEAST_EXPECT (
239
- hasTxs (env. rpc ( " json " , " account_tx " , to_string (p)))) ;
241
+ // Ledger Sequence
242
+ {
243
+ Json::Value p{jParms} ;
240
244
241
- p[jss::ledger_index] = env.closed ()->info ().seq - 1 ;
242
- BEAST_EXPECT (
243
- noTxs (env.rpc (" json" , " account_tx" , to_string (p))));
245
+ p[jss::ledger_index] = env.closed ()->info ().seq ;
246
+ BEAST_EXPECT (hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
244
247
245
- p[jss::ledger_index] = env.current ()->info ().seq ;
246
- BEAST_EXPECT (isErr (
247
- env.rpc (" json" , " account_tx" , to_string (p)),
248
- rpcLGR_NOT_VALIDATED));
248
+ p[jss::ledger_index] = env.closed ()->info ().seq - 1 ;
249
+ BEAST_EXPECT (noTxs (env.rpc (" json" , " account_tx" , to_string (p))));
249
250
250
- p[jss::ledger_index] = env.current ()->info ().seq + 1 ;
251
- BEAST_EXPECT (isErr (
252
- env.rpc (" json" , " account_tx" , to_string (p)),
253
- rpcLGR_NOT_FOUND));
254
- }
251
+ p[jss::ledger_index] = env.current ()->info ().seq ;
252
+ BEAST_EXPECT (isErr (
253
+ env.rpc (" json" , " account_tx" , to_string (p)),
254
+ rpcLGR_NOT_VALIDATED));
255
255
256
- // Ledger Hash
257
- {
258
- Json::Value p{jParms};
256
+ p[jss::ledger_index] = env.current ()->info ().seq + 1 ;
257
+ BEAST_EXPECT (isErr (
258
+ env.rpc (" json" , " account_tx" , to_string (p)), rpcLGR_NOT_FOUND));
259
+ }
259
260
260
- p[jss::ledger_hash] = to_string (env. closed ()-> info (). hash );
261
- BEAST_EXPECT (
262
- hasTxs (env. rpc ( " json " , " account_tx " , to_string (p)))) ;
261
+ // Ledger Hash
262
+ {
263
+ Json::Value p{jParms} ;
263
264
264
- p[jss::ledger_hash] =
265
- to_string ( env.closed ()-> info (). parentHash );
266
- BEAST_EXPECT (
267
- noTxs (env.rpc ( " json " , " account_tx " , to_string (p))) );
268
- }
265
+ p[jss::ledger_hash] = to_string (env. closed ()-> info (). hash );
266
+ BEAST_EXPECT ( hasTxs ( env.rpc ( " json " , " account_tx " , to_string (p))) );
267
+
268
+ p[jss::ledger_hash] = to_string (env.closed ()-> info (). parentHash );
269
+ BEAST_EXPECT ( noTxs (env. rpc ( " json " , " account_tx " , to_string (p))));
269
270
}
270
- else
271
+
272
+ // Ledger index max/min/index all specified
273
+ // ERRORS out with invalid Parenthesis
271
274
{
272
- // Ledger index max/min/index all specified
273
- // ERRORS out with invalid Parenthesis
274
- {
275
- jParms[jss::account] = " 0xDEADBEEF" ;
276
- jParms[jss::account] = A1.human ();
277
- Json::Value p{jParms};
275
+ jParms[jss::account] = " 0xDEADBEEF" ;
276
+ jParms[jss::account] = A1.human ();
277
+ Json::Value p{jParms};
278
278
279
- p[jss::ledger_index_max] = -1 ;
280
- p[jss::ledger_index_min] = -1 ;
281
- p[jss::ledger_index] = -1 ;
279
+ p[jss::ledger_index_max] = -1 ;
280
+ p[jss::ledger_index_min] = -1 ;
281
+ p[jss::ledger_index] = -1 ;
282
282
283
+ if (apiVersion < 2u )
284
+ BEAST_EXPECT (
285
+ hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
286
+ else
283
287
BEAST_EXPECT (isErr (
284
288
env.rpc (" json" , " account_tx" , to_string (p)),
285
289
rpcINVALID_PARAMS));
286
- }
287
-
288
- // Ledger index min/max only
289
- {
290
- Json::Value p{jParms};
291
- p[jss::ledger_index_max] = 100 ;
292
- p[jss::ledger_index_min] = 0 ;
293
- BEAST_EXPECT (isErr (
294
- env.rpc (" json" , " account_tx" , to_string (p)),
295
- rpcLGR_IDX_MALFORMED));
290
+ }
296
291
297
- p[jss::ledger_index_max] = -1 ;
298
- p[jss::ledger_index_min] = -1 ;
292
+ // Ledger index max only
293
+ {
294
+ Json::Value p{jParms};
295
+ p[jss::ledger_index_max] = env.current ()->info ().seq ;
296
+ if (apiVersion < 2u )
299
297
BEAST_EXPECT (
300
298
hasTxs (env.rpc (" json" , " account_tx" , to_string (p))));
301
-
302
- p[jss::ledger_index_min] = 2 ;
303
- p[jss::ledger_index_max] = 1 ;
299
+ else
304
300
BEAST_EXPECT (isErr (
305
301
env.rpc (" json" , " account_tx" , to_string (p)),
306
- rpcINVALID_LGR_RANGE));
302
+ rpcLGR_IDX_MALFORMED));
303
+ }
304
+ // test binary and forward for bool/non bool values
305
+ {
306
+ Json::Value p{jParms};
307
+ p[jss::binary] = " asdf" ;
308
+ if (apiVersion < 2u )
309
+ {
310
+ Json::Value result{env.rpc (" json" , " account_tx" , to_string (p))};
311
+ BEAST_EXPECT (result[jss::result][jss::status] == " success" );
307
312
}
313
+ else
314
+ BEAST_EXPECT (isErr (
315
+ env.rpc (" json" , " account_tx" , to_string (p)),
316
+ rpcINVALID_PARAMS));
308
317
309
- // Ledger index max only
310
- {
311
- Json::Value p{jParms};
312
- p[jss::ledger_index_max] = env.current ()->info ().seq ;
318
+ p[jss::binary] = true ;
319
+ Json::Value result{env.rpc (" json" , " account_tx" , to_string (p))};
320
+ BEAST_EXPECT (result[jss::result][jss::status] == " success" );
321
+
322
+ p[jss::forward] = " true" ;
323
+ if (apiVersion < 2u )
324
+ BEAST_EXPECT (result[jss::result][jss::status] == " success" );
325
+ else
313
326
BEAST_EXPECT (isErr (
314
327
env.rpc (" json" , " account_tx" , to_string (p)),
315
- rpcLGR_IDX_MALFORMED));
316
- }
328
+ rpcINVALID_PARAMS));
329
+
330
+ p[jss::forward] = false ;
331
+ result = env.rpc (" json" , " account_tx" , to_string (p));
332
+ BEAST_EXPECT (result[jss::result][jss::status] == " success" );
317
333
}
318
334
}
319
335
0 commit comments