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())};
227 verifyErr(result,
"invalidParams",
"ledgerIndexMalformed");
233 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
234 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
239 args[jss::ledger_index] = 17;
241 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
242 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
248 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
249 verifyErr(result,
"srcActNotFound",
"Source account not found.");
257 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
259 result,
"dstActNotFound",
"Destination account not found.");
267 env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
282 result[jss::status] ==
authorized ? jss::success : jss::error);
283 if (result.
isMember(jss::deposit_authorized))
284 BEAST_EXPECT(result[jss::deposit_authorized] ==
authorized);
287 result.
isMember(jss::deposit_authorized) &&
288 (result[jss::deposit_authorized] ==
true));
290 BEAST_EXPECT(result.
isMember(jss::error) == !error.empty());
292 BEAST_EXPECT(result[jss::error].asString() == error);
296 BEAST_EXPECT(result[jss::source_account] == src.
human());
297 BEAST_EXPECT(result[jss::destination_account] == dst.
human());
299 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
300 BEAST_EXPECT(result[jss::credentials][i] == credentialIDs[i]);
304 BEAST_EXPECT(result[jss::request].isObject());
306 auto const& request = result[jss::request];
307 BEAST_EXPECT(request[jss::command] == jss::deposit_authorized);
308 BEAST_EXPECT(request[jss::source_account] == src.
human());
309 BEAST_EXPECT(request[jss::destination_account] == dst.
human());
311 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
312 BEAST_EXPECT(request[jss::credentials][i] == credentialIDs[i]);
323 char const credType[] =
"abcde";
331 env.
fund(
XRP(1000), alice, becky, carol, diana);
339 std::string const credIdx = jv[jss::result][jss::index].asString();
351 "deposit_authorized with credentials failure: empty array.");
357 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
359 jv[jss::result], alice, becky,
false, {},
"invalidParams");
364 "deposit_authorized with credentials failure: not a string "
369 args[jss::credentials].append(1);
370 args[jss::credentials].append(3);
373 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
375 jv[jss::result], alice, becky,
false, {},
"invalidParams");
380 "deposit_authorized with credentials failure: not a hex string "
385 args[jss::credentials].append(
"hello world");
388 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
400 "deposit_authorized with credentials failure: not a credential "
407 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
411 env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
417 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
424 "deposit_authorized with credentials not authorized: "
425 "credential not accepted");
426 auto const jv = env.
rpc(
428 "deposit_authorized",
445 testcase(
"deposit_authorized with duplicates in credentials");
446 auto const jv = env.
rpc(
448 "deposit_authorized",
462 "18004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
464 "28004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
466 "38004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
468 "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
470 "58004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
472 "68004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
474 "78004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
476 "88004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
478 "98004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
482 testcase(
"deposit_authorized too long credentials");
483 auto const jv = env.
rpc(
485 "deposit_authorized",
489 jv[jss::result], alice, becky,
false, credIds,
"invalidParams");
493 testcase(
"deposit_authorized with credentials");
494 auto const jv = env.
rpc(
496 "deposit_authorized",
500 jv[jss::result], alice, becky,
true, {credIdx});
513 jv[jss::result][jss::index].asString();
515 testcase(
"deposit_authorized account without preauth");
518 "deposit_authorized",
522 jv[jss::result], becky, alice,
true, {credBecky});
534 jv[jss::result][jss::index].asString();
539 "deposit_authorized",
552 testcase(
"deposit_authorized with expired credentials");
555 char const credType2[] =
"fghijk";
558 .parentCloseTime.time_since_epoch()
564 jv[sfExpiration.jsonName] = x;
570 std::string const credIdx2 = jv[jss::result][jss::index].asString();
584 "deposit_authorized",
588 jv[jss::result], alice, becky,
true, {credIdx2});
598 "deposit_authorized",