117 auto verifyErr = [
this](
Json::Value const& result,
char const* error,
char const* errorMsg) {
118 BEAST_EXPECT(result[jss::result][jss::status] == jss::error);
119 BEAST_EXPECT(result[jss::result][jss::error] == error);
120 BEAST_EXPECT(result[jss::result][jss::error_message] == errorMsg);
128 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
129 verifyErr(result,
"invalidParams",
"Missing field 'source_account'.");
134 args[jss::source_account] = 7.3;
135 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
136 verifyErr(result,
"invalidParams",
"Invalid field 'source_account', not a string.");
141 args[jss::source_account] =
"rG1QQv2nh2gr7RCZ!P8YYcBUKCCN633jCn";
142 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
143 verifyErr(result,
"actMalformed",
"Account malformed.");
149 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
150 verifyErr(result,
"invalidParams",
"Missing field 'destination_account'.");
155 args[jss::destination_account] = 7.3;
156 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
157 verifyErr(result,
"invalidParams",
"Invalid field 'destination_account', not a string.");
162 args[jss::destination_account] =
"rP6P9ypfAmc!pw8SZHNwM4nvZHFXDraQas";
163 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
164 verifyErr(result,
"actMalformed",
"Account malformed.");
169 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
170 verifyErr(result,
"invalidParams",
"Invalid field 'ledger_index', not string or number.");
175 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
176 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
181 args[jss::ledger_index] = 17;
182 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
183 verifyErr(result,
"lgrNotFound",
"ledgerNotFound");
188 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
189 verifyErr(result,
"srcActNotFound",
"Source account not found.");
196 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
197 verifyErr(result,
"dstActNotFound",
"Destination account not found.");
204 Json::Value const result{env.
rpc(
"json",
"deposit_authorized", args.toStyledString())};
218 BEAST_EXPECT(result[jss::status] ==
authorized ? jss::success : jss::error);
219 if (result.
isMember(jss::deposit_authorized))
220 BEAST_EXPECT(result[jss::deposit_authorized] ==
authorized);
222 BEAST_EXPECT(result.
isMember(jss::deposit_authorized) && (result[jss::deposit_authorized] ==
true));
224 BEAST_EXPECT(result.
isMember(jss::error) == !error.empty());
226 BEAST_EXPECT(result[jss::error].asString() == error);
230 BEAST_EXPECT(result[jss::source_account] == src.
human());
231 BEAST_EXPECT(result[jss::destination_account] == dst.
human());
233 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
234 BEAST_EXPECT(result[jss::credentials][i] == credentialIDs[i]);
238 BEAST_EXPECT(result[jss::request].isObject());
240 auto const& request = result[jss::request];
241 BEAST_EXPECT(request[jss::command] == jss::deposit_authorized);
242 BEAST_EXPECT(request[jss::source_account] == src.
human());
243 BEAST_EXPECT(request[jss::destination_account] == dst.
human());
245 for (
unsigned i = 0; i < credentialIDs.size(); ++i)
246 BEAST_EXPECT(request[jss::credentials][i] == credentialIDs[i]);
257 char const credType[] =
"abcde";
265 env.
fund(
XRP(1000), alice, becky, carol, diana);
273 std::string const credIdx = jv[jss::result][jss::index].asString();
284 testcase(
"deposit_authorized with credentials failure: empty array.");
289 auto const jv = env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
295 "deposit_authorized with credentials failure: not a string "
300 args[jss::credentials].append(1);
301 args[jss::credentials].append(3);
303 auto const jv = env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
309 "deposit_authorized with credentials failure: not a hex string "
314 args[jss::credentials].append(
"hello world");
316 auto const jv = env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
322 "deposit_authorized with credentials failure: not a credential "
329 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
332 auto const jv = env.
rpc(
"json",
"deposit_authorized", args.toStyledString());
338 {
"0127AB8B4B29CCDBB61AA51C0799A8A6BB80B86A9899807C11ED576AF8516"
345 "deposit_authorized with credentials not authorized: "
346 "credential not accepted");
347 auto const jv = env.
rpc(
348 "json",
"deposit_authorized",
depositAuthArgs(alice, becky,
"validated", {credIdx}).toStyledString());
357 testcase(
"deposit_authorized with duplicates in credentials");
358 auto const jv = env.
rpc(
360 "deposit_authorized",
361 depositAuthArgs(alice, becky,
"validated", {credIdx, credIdx}).toStyledString());
367 "18004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
369 "28004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
371 "38004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
373 "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
375 "58004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
377 "68004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
379 "78004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
381 "88004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
383 "98004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
387 testcase(
"deposit_authorized too long credentials");
388 auto const jv = env.
rpc(
389 "json",
"deposit_authorized",
depositAuthArgs(alice, becky,
"validated", credIds).toStyledString());
394 testcase(
"deposit_authorized with credentials");
395 auto const jv = env.
rpc(
396 "json",
"deposit_authorized",
depositAuthArgs(alice, becky,
"validated", {credIdx}).toStyledString());
409 std::string const credBecky = jv[jss::result][jss::index].asString();
411 testcase(
"deposit_authorized account without preauth");
413 "json",
"deposit_authorized",
depositAuthArgs(becky, alice,
"validated", {credBecky}).toStyledString());
425 std::string const credDiana = jv[jss::result][jss::index].asString();
429 "json",
"deposit_authorized",
depositAuthArgs(becky, alice,
"validated", {credDiana}).toStyledString());
434 testcase(
"deposit_authorized with expired credentials");
437 char const credType2[] =
"random";
438 std::uint32_t const x = env.
current()->header().parentCloseTime.time_since_epoch().count() + 40;
442 jv[sfExpiration.jsonName] = x;
448 std::string const credIdx2 = jv[jss::result][jss::index].asString();
462 "deposit_authorized",
463 depositAuthArgs(alice, becky,
"validated", {credIdx2}).toStyledString());
474 "deposit_authorized",
475 depositAuthArgs(alice, becky,
"validated", {credIdx2}).toStyledString());