153 auto verifyErr = [
this](
156 char const* errorMsg) {
157 BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
158 BEAST_EXPECT(result[jss::result][jss::error] == error);
159 BEAST_EXPECT(result[jss::result][jss::error_message] == errorMsg);
168 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
170 result,
"invalidParams",
"Missing field 'source_account'.");
175 args[jss::source_account] = 7.3;
177 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
181 "Invalid field 'source_account', not a string.");
186 args[jss::source_account] =
"rG1QQv2nh2gr7RCZ!P8YYcBUKCCN633jCn";
188 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
189 verifyErr(result,
"actMalformed",
"Account malformed.");
196 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
200 "Missing field 'destination_account'.");
205 args[jss::destination_account] = 7.3;
207 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
211 "Invalid field 'destination_account', not a string.");
216 args[jss::destination_account] =
217 "rP6P9ypfAmc!pw8SZHNwM4nvZHFXDraQas";
219 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
220 verifyErr(result,
"actMalformed",
"Account malformed.");
226 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
230 "Invalid field 'ledger_index', not string or number.");
236 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
237 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
242 args[jss::ledger_index] = 17;
244 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
245 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
251 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
252 verifyErr(result,
"srcActNotFound",
"Source account not found.");
260 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
262 result,
"dstActNotFound",
"Destination account not found.");
270 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
285 result[jss::status] ==
authorized ? jss::success : jss::error);
286 if (result.
isMember(jss::deposit_authorized))
287 BEAST_EXPECT(result[jss::deposit_authorized] ==
authorized);
290 result.
isMember(jss::deposit_authorized) &&
291 (result[jss::deposit_authorized] ==
true));
293 BEAST_EXPECT(result.
isMember(jss::error) == !error.empty());
295 BEAST_EXPECT(result[jss::error].asString() == error);
299 BEAST_EXPECT(result[jss::source_account] == src.
human());
300 BEAST_EXPECT(result[jss::destination_account] == dst.
human());
302 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
303 BEAST_EXPECT(result[jss::credentials][i] == credentialIDs[i]);
307 BEAST_EXPECT(result[jss::request].isObject());
309 auto const& request = result[jss::request];
310 BEAST_EXPECT(request[jss::command] == jss::deposit_authorized);
311 BEAST_EXPECT(request[jss::source_account] == src.
human());
312 BEAST_EXPECT(request[jss::destination_account] == dst.
human());
314 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
315 BEAST_EXPECT(request[jss::credentials][i] == credentialIDs[i]);
326 char const credType[] =
"abcde";
334 env.
fund(
XRP(1000), alice, becky, carol, diana);
342 std::string const credIdx = jv[jss::result][jss::index].asString();
354 "deposit_authorized with credentials failure: empty array.");
360 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
362 jv[jss::result], alice, becky,
false, {},
"invalidParams");
367 "deposit_authorized with credentials failure: not a string "
372 args[jss::credentials].append(1);
373 args[jss::credentials].append(3);
376 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
378 jv[jss::result], alice, becky,
false, {},
"invalidParams");
383 "deposit_authorized with credentials failure: not a hex string "
388 args[jss::credentials].append(
"hello world");
391 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
403 "deposit_authorized with credentials failure: not a credential "
410 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
414 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
420 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
427 "deposit_authorized with credentials not authorized: "
428 "credential not accepted");
429 auto const jv = env.
rpc(
431 "deposit_authorized",
448 testcase(
"deposit_authorized with duplicates in credentials");
449 auto const jv = env.
rpc(
451 "deposit_authorized",
465 "18004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
467 "28004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
469 "38004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
471 "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
473 "58004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
475 "68004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
477 "78004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
479 "88004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
481 "98004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
485 testcase(
"deposit_authorized too long credentials");
486 auto const jv = env.
rpc(
488 "deposit_authorized",
492 jv[jss::result], alice, becky,
false, credIds,
"invalidParams");
496 testcase(
"deposit_authorized with credentials");
497 auto const jv = env.
rpc(
499 "deposit_authorized",
503 jv[jss::result], alice, becky,
true, {credIdx});
516 jv[jss::result][jss::index].asString();
518 testcase(
"deposit_authorized account without preauth");
521 "deposit_authorized",
525 jv[jss::result], becky, alice,
true, {credBecky});
537 jv[jss::result][jss::index].asString();
542 "deposit_authorized",
555 testcase(
"deposit_authorized with expired credentials");
558 char const credType2[] =
"random";
561 .parentCloseTime.time_since_epoch()
567 jv[sfExpiration.jsonName] = x;
573 std::string const credIdx2 = jv[jss::result][jss::index].asString();
587 "deposit_authorized",
591 jv[jss::result], alice, becky,
true, {credIdx2});
601 "deposit_authorized",