2#include <test/jtx/Oracle.h>
3#include <test/jtx/attester.h>
4#include <test/jtx/delegate.h>
5#include <test/jtx/multisign.h>
6#include <test/jtx/xchain_bridge.h>
8#include <xrpld/app/tx/apply.h>
10#include <xrpl/beast/unit_test.h>
11#include <xrpl/json/json_value.h>
12#include <xrpl/protocol/AccountID.h>
13#include <xrpl/protocol/ErrorCodes.h>
14#include <xrpl/protocol/STXChainBridge.h>
15#include <xrpl/protocol/jss.h>
17#include <source_location>
65 Throw<std::runtime_error>(
"`mappings` is missing field " +
std::string(fieldName.
c_str()));
86 return "hex string or object";
90 return "length-2 array of Accounts";
96 Throw<std::runtime_error>(
"unknown type " +
std::to_string(
static_cast<uint8_t
>(typeID)));
109 if (BEAST_EXPECT(jv.
isMember(jss::status)))
110 BEAST_EXPECTS(jv[jss::status] ==
"error",
std::to_string(location.line()));
111 if (BEAST_EXPECT(jv.
isMember(jss::error)))
113 jv[jss::error] == err,
114 "Expected error " + err +
", received " + jv[jss::error].asString() +
", at line " +
119 jv[jss::error_message] ==
Json::nullValue || jv[jss::error_message] ==
"",
120 "Expected no error message, received \"" + jv[jss::error_message].asString() +
"\", at line " +
123 else if (BEAST_EXPECT(jv.
isMember(jss::error_message)))
125 jv[jss::error_message] == msg,
126 "Expected error message \"" + msg +
"\", received \"" + jv[jss::error_message].asString() +
135 obj[jss::account] =
"rhigTLJJyXXSRUyRCQtqi1NoAZZzZnS4KU";
136 obj[jss::ledger_index] =
"validated";
141 arr[0u] =
"rhigTLJJyXXSRUyRCQtqi1NoAZZzZnS4KU";
142 arr[1u] =
"validated";
156 "0123456789ABCDEFGH",
157 "rJxKV9e9p6wiPw!!!!xrJ4X1n98LosPL1sgcJW",
158 "rPSTrR5yEr11uMkfsz1kHCp9jK4aoa3Avv",
159 "n9K2isxwTxcSHJKxMkJznDoWXAUs7NNy49H9Fknz1pC7oHAH3kH9",
162 "5233D68B4D44388F98559DE42903767803EFA7C1F8D01413FC16EE6B01403D"
176 if (indexSet.
find(i) == indexSet.
end())
184 static auto const& badAccountValues = remove({12});
185 static auto const& badArrayValues = remove({17, 20});
186 static auto const& badBlobValues = remove({3, 7, 8, 16});
187 static auto const& badCurrencyValues = remove({14});
188 static auto const& badHashValues = remove({2, 3, 7, 8, 16});
189 static auto const& badFixedHashValues = remove({1, 2, 3, 4, 7, 8, 16});
190 static auto const& badIndexValues = remove({12, 16, 18, 19});
191 static auto const& badUInt32Values = remove({2, 3});
192 static auto const& badUInt64Values = remove({2, 3});
193 static auto const& badIssueValues = remove({});
198 return badAccountValues;
201 return badArrayValues;
203 return badBlobValues;
205 return badCurrencyValues;
207 return badHashValues;
209 return badIndexValues;
211 return badFixedHashValues;
213 return badIssueValues;
215 return badUInt32Values;
217 return badUInt64Values;
219 Throw<std::runtime_error>(
"unknown type " +
std::to_string(
static_cast<uint8_t
>(fieldType)));
228 arr[0u] =
"rhigTLJJyXXSRUyRCQtqi1NoAZZzZnS4KU";
229 arr[1u] =
"r4MrUGTdB57duTnRs6KbsRGQXgkseGb1b5";
234 arr[jss::currency] =
"XRP";
242 return "r4MrUGTdB57duTnRs6KbsRGQXgkseGb1b5";
250 return "5233D68B4D44388F98559DE42903767803EFA7C1F8D01413FC16EE6"
255 return "5233D68B4D44388F98559DE42903767803EFA7C1F8D01413FC16EE6"
258 return twoAccountArray;
264 Throw<std::runtime_error>(
"unknown type " +
std::to_string(
static_cast<uint8_t
>(typeID)));
283 env.
rpc(apiVersion,
"json",
"ledger_entry",
to_string(correctRequest))[jss::result];
287 checkErrorValue(jrr,
"invalidParams",
"No ledger_entry params provided.", location);
289 auto tryField = [&](
Json::Value fieldValue) ->
void {
290 correctRequest[fieldName] = fieldValue;
292 env.
rpc(apiVersion,
"json",
"ledger_entry",
to_string(correctRequest))[jss::result];
298 for (
auto const& value : badValues)
323 correctRequest[parentFieldName].
removeMember(fieldName);
325 env.
rpc(apiVersion,
"json",
"ledger_entry",
to_string(correctRequest))[jss::result];
330 env.
rpc(apiVersion,
"json",
"ledger_entry",
to_string(correctRequest))[jss::result];
333 auto tryField = [&](
Json::Value fieldValue) ->
void {
334 correctRequest[parentFieldName][fieldName] = fieldValue;
337 env.
rpc(apiVersion,
"json",
"ledger_entry",
to_string(correctRequest))[jss::result];
343 for (
auto const& value : badValues)
379 for (
auto const& subfield : subfields)
381 correctOutput[parentField][subfield.fieldName] =
getCorrectValue(subfield.fieldName);
384 for (
auto const& subfield : subfields)
386 auto const fieldType =
getFieldType(subfield.fieldName);
393 subfield.malformedErrorMsg,
403 using namespace test::jtx;
411 jvParams[jss::account_root] = alice.human();
412 jvParams[jss::ledger_hash] =
413 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
415 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
421 jvParams[jss::account_root] = alice.human();
425 auto tryField = [&](
Json::Value fieldValue) ->
void {
426 jvParams[jss::ledger_hash] = fieldValue;
428 env.
rpc(apiVersion,
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
429 checkErrorValue(jrr,
"invalidParams",
"Invalid field 'ledger_hash', not hex string.");
433 for (
auto const& value : badValues)
443 jvParams[jss::ledger_index] =
"validated";
444 jvParams[jss::index] =
445 "00000000000000000000000000000000000000000000000000000000000000"
447 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams))[jss::result];
455 jvParams[jss::features] =
456 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
458 jvParams[jss::api_version] = apiVersion;
464 checkErrorValue(jrr,
"invalidParams",
"No ledger_entry params provided.");
473 using namespace test::jtx;
476 cfg->FEES.reference_fee = 10;
477 Env env{*
this, std::move(cfg)};
487 BEAST_EXPECT(jrr[jss::ledger_hash] ==
ledgerHash);
488 BEAST_EXPECT(jrr[jss::ledger_index] == 3);
495 jvParams[jss::account_root] = alice.human();
498 BEAST_EXPECT(jrr.
isMember(jss::node));
499 BEAST_EXPECT(jrr[jss::node][jss::Account] == alice.human());
500 BEAST_EXPECT(jrr[jss::node][sfBalance.jsonName] ==
"10000000000");
501 accountRootIndex = jrr[jss::index].
asString();
504 constexpr char alicesAcctRootBinary[]{
505 "1100612200800000240000000425000000032D00000000559CE54C3B934E4"
506 "73A995B477E92EC229F99CED5B62BF4D2ACE4DC42719103AE2F6240000002"
507 "540BE4008114AE123A8556F3CF91154711376AFB0F894F832B3D"};
511 jvParams[jss::account_root] = alice.human();
512 jvParams[jss::binary] = 1;
515 BEAST_EXPECT(jrr.
isMember(jss::node_binary));
516 BEAST_EXPECT(jrr[jss::node_binary] == alicesAcctRootBinary);
521 jvParams[jss::index] = accountRootIndex;
523 BEAST_EXPECT(!jrr.
isMember(jss::node_binary));
524 BEAST_EXPECT(jrr.
isMember(jss::node));
525 BEAST_EXPECT(jrr[jss::node][jss::Account] == alice.human());
526 BEAST_EXPECT(jrr[jss::node][sfBalance.jsonName] ==
"10000000000");
531 jvParams[jss::index] = accountRootIndex;
532 jvParams[jss::binary] = 0;
534 BEAST_EXPECT(jrr.
isMember(jss::node));
535 BEAST_EXPECT(jrr[jss::node][jss::Account] == alice.human());
536 BEAST_EXPECT(jrr[jss::node][sfBalance.jsonName] ==
"10000000000");
541 jvParams[jss::account] = alice.human();
544 BEAST_EXPECT(jrr.
isMember(jss::node));
545 BEAST_EXPECT(jrr[jss::node][jss::Account] == alice.human());
546 BEAST_EXPECT(jrr[jss::node][sfBalance.jsonName] ==
"10000000000");
547 accountRootIndex = jrr[jss::index].
asString();
568 using namespace test::jtx;
585 "714D104A72F9B4369F97ABF044EE"));
588 "21192D63DE53FFB46E43B9DC8373"));
591 "CC3E51F522F978041E4B57D9158C"));
594 "0F094B02226C1C14AD2858962ED4"));
595 sle->setFieldV256(sfAmendments,
STVector256(enabledAmendments));
601 majority1.setFieldH256(
604 "647693B50C5E87A80DFD6FCFAC50"));
605 majority1.setFieldU32(sfCloseTime, 779561310);
606 majorities.
push_back(std::move(majority1));
609 majority2.setFieldH256(
612 "E40AD19554A5EBECDCEC8A1F77FE"));
613 majority2.setFieldU32(sfCloseTime, 779561310);
614 majorities.
push_back(std::move(majority2));
616 sle->setFieldArray(sfMajorities, majorities);
627 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::Amendments);
638 using namespace test::jtx;
645 AMM amm(env, alice,
XRP(10), alice[
"USD"](1000));
650 jvParams[jss::amm] =
to_string(amm.ammID());
651 auto const result = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
653 result.isObject() && result.isMember(jss::result) && !result[jss::result].isMember(jss::error) &&
654 result[jss::result].isMember(jss::node) &&
655 result[jss::result][jss::node].isMember(sfLedgerEntryType.jsonName) &&
656 result[jss::result][jss::node][sfLedgerEntryType.jsonName] == jss::AMM);
664 obj[jss::currency] =
"XRP";
665 ammParams[jss::asset] = obj;
669 obj[jss::currency] =
"USD";
670 obj[jss::issuer] = alice.human();
671 ammParams[jss::asset2] = obj;
673 jvParams[jss::amm] = ammParams;
674 auto const result = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
676 result.isObject() && result.isMember(jss::result) && !result[jss::result].isMember(jss::error) &&
677 result[jss::result].isMember(jss::node) &&
678 result[jss::result][jss::node].isMember(sfLedgerEntryType.jsonName) &&
679 result[jss::result][jss::node][sfLedgerEntryType.jsonName] == jss::AMM);
687 {jss::asset,
"malformedRequest"},
688 {jss::asset2,
"malformedRequest"},
696 using namespace test::jtx;
711 jvParams[jss::check] =
to_string(checkId.key);
714 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::Check);
715 BEAST_EXPECT(jrr[jss::node][sfSendMax.jsonName] ==
"100000000");
723 jvParams[jss::account_root] = alice.human();
725 accountRootIndex = jrr[jss::index].
asString();
728 jvParams[jss::check] = accountRootIndex;
731 checkErrorValue(jrr,
"unexpectedLedgerType",
"Unexpected ledger type.");
744 using namespace test::jtx;
747 Account const issuer{
"issuer"};
750 char const credType[] =
"abcde";
752 env.
fund(
XRP(5000), issuer, alice, bob);
764 jv[jss::result].
isMember(jss::node) &&
765 jv[jss::result][jss::node].
isMember(sfLedgerEntryType.jsonName) &&
766 jv[jss::result][jss::node][sfLedgerEntryType.jsonName] == jss::Credential);
773 jv[jss::result].
isMember(jss::node) &&
774 jv[jss::result][jss::node].
isMember(sfLedgerEntryType.jsonName) &&
775 jv[jss::result][jss::node][sfLedgerEntryType.jsonName] == jss::Credential);
782 "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B"
793 {jss::subject,
"malformedRequest"},
794 {jss::issuer,
"malformedRequest"},
795 {jss::credential_type,
"malformedRequest"},
805 using namespace test::jtx;
810 env.
fund(
XRP(10000), alice, bob);
819 jvParams[jss::delegate][jss::account] = alice.human();
820 jvParams[jss::delegate][jss::authorize] = bob.human();
823 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::Delegate);
824 BEAST_EXPECT(jrr[jss::node][sfAccount.jsonName] == alice.human());
825 BEAST_EXPECT(jrr[jss::node][sfAuthorize.jsonName] == bob.human());
826 delegateIndex = jrr[jss::node][jss::index].
asString();
831 jvParams[jss::delegate] = delegateIndex;
834 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::Delegate);
835 BEAST_EXPECT(jrr[jss::node][sfAccount.jsonName] == alice.human());
836 BEAST_EXPECT(jrr[jss::node][sfAuthorize.jsonName] == bob.human());
845 {jss::account,
"malformedAddress"},
846 {jss::authorize,
"malformedAddress"},
856 using namespace test::jtx;
862 env.
fund(
XRP(10000), alice, becky);
873 jvParams[jss::deposit_preauth][jss::owner] = alice.human();
874 jvParams[jss::deposit_preauth][jss::authorized] = becky.human();
878 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::DepositPreauth);
879 BEAST_EXPECT(jrr[jss::node][sfAccount.jsonName] == alice.human());
880 BEAST_EXPECT(jrr[jss::node][sfAuthorize.jsonName] == becky.human());
881 depositPreauthIndex = jrr[jss::node][jss::index].
asString();
886 jvParams[jss::deposit_preauth] = depositPreauthIndex;
890 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::DepositPreauth);
891 BEAST_EXPECT(jrr[jss::node][sfAccount.jsonName] == alice.human());
892 BEAST_EXPECT(jrr[jss::node][sfAuthorize.jsonName] == becky.human());
898 jss::deposit_preauth,
900 {jss::owner,
"malformedOwner"},
901 {jss::authorized,
"malformedAuthorized",
false},
909 testcase(
"Deposit Preauth with credentials");
911 using namespace test::jtx;
914 Account const issuer{
"issuer"};
917 char const credType[] =
"abcde";
919 env.
fund(
XRP(5000), issuer, alice, bob);
933 jvParams[jss::ledger_index] = jss::validated;
934 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
936 jvParams[jss::deposit_preauth][jss::authorized_credentials] =
Json::arrayValue;
937 auto& arr(jvParams[jss::deposit_preauth][jss::authorized_credentials]);
940 jo[jss::issuer] = issuer.human();
942 arr.append(std::move(jo));
943 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
946 jrr.isObject() && jrr.isMember(jss::result) && !jrr[jss::result].isMember(jss::error) &&
947 jrr[jss::result].isMember(jss::node) &&
948 jrr[jss::result][jss::node].isMember(sfLedgerEntryType.jsonName) &&
949 jrr[jss::result][jss::node][sfLedgerEntryType.jsonName] == jss::DepositPreauth);
955 jvParams[jss::ledger_index] = jss::validated;
956 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
958 auto tryField = [&](
Json::Value fieldValue) ->
void {
961 jo[jss::issuer] = fieldValue;
964 jvParams[jss::deposit_preauth][jss::authorized_credentials] = arr;
969 checkErrorValue(jrr,
"malformedAuthorizedCredentials", expectedErrMsg);
973 for (
auto const& value : badValues)
983 jvParams[jss::ledger_index] = jss::validated;
984 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
986 jvParams[jss::deposit_preauth][jss::authorized_credentials] =
Json::arrayValue;
987 auto& arr(jvParams[jss::deposit_preauth][jss::authorized_credentials]);
990 jo[jss::issuer] = issuer.human();
993 arr.append(std::move(jo));
994 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
997 "malformedAuthorizedCredentials",
1004 jvParams[jss::ledger_index] = jss::validated;
1005 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
1007 auto tryField = [&](
Json::Value fieldValue) ->
void {
1010 jo[jss::issuer] = issuer.human();
1011 jo[jss::credential_type] = fieldValue;
1013 jvParams[jss::deposit_preauth][jss::authorized_credentials] = arr;
1016 auto const expectedErrMsg = fieldValue.
isNull()
1019 checkErrorValue(jrr,
"malformedAuthorizedCredentials", expectedErrMsg);
1023 for (
auto const& value : badValues)
1033 jvParams[jss::ledger_index] = jss::validated;
1034 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
1035 jvParams[jss::deposit_preauth][jss::authorized] = alice.human();
1037 jvParams[jss::deposit_preauth][jss::authorized_credentials] =
Json::arrayValue;
1038 auto& arr(jvParams[jss::deposit_preauth][jss::authorized_credentials]);
1041 jo[jss::issuer] = issuer.human();
1043 arr.append(std::move(jo));
1045 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
1049 "Must have exactly one of `authorized` and "
1050 "`authorized_credentials`.");
1056 jvParams[jss::ledger_index] = jss::validated;
1057 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
1061 jss::deposit_preauth,
1062 jss::authorized_credentials,
1064 "malformedAuthorizedCredentials",
1071 jvParams[jss::ledger_index] = jss::validated;
1072 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
1073 jvParams[jss::deposit_preauth][jss::authorized_credentials] =
Json::arrayValue;
1074 auto& arr(jvParams[jss::deposit_preauth][jss::authorized_credentials]);
1075 arr.append(
"foobar");
1077 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
1080 "malformedAuthorizedCredentials",
1081 "Invalid field 'authorized_credentials', not array.");
1087 jvParams[jss::ledger_index] = jss::validated;
1088 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
1089 jvParams[jss::deposit_preauth][jss::authorized_credentials] =
Json::arrayValue;
1090 auto& arr(jvParams[jss::deposit_preauth][jss::authorized_credentials]);
1093 arr.
append(std::move(payload));
1095 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
1098 "malformedAuthorizedCredentials",
1099 "Invalid field 'authorized_credentials', not array.");
1105 jvParams[jss::ledger_index] = jss::validated;
1106 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
1107 jvParams[jss::deposit_preauth][jss::authorized_credentials] =
Json::arrayValue;
1109 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
1112 "malformedAuthorizedCredentials",
1113 "Invalid field 'authorized_credentials', array empty.");
1119 "cred1",
"cred2",
"cred3",
"cred4",
"cred5",
"cred6",
"cred7",
"cred8",
"cred9"};
1123 jvParams[jss::ledger_index] = jss::validated;
1124 jvParams[jss::deposit_preauth][jss::owner] = bob.human();
1125 jvParams[jss::deposit_preauth][jss::authorized_credentials] =
Json::arrayValue;
1127 auto& arr(jvParams[jss::deposit_preauth][jss::authorized_credentials]);
1129 for (
auto cred : credTypes)
1132 jo[jss::issuer] = issuer.human();
1134 arr.append(std::move(jo));
1137 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(jvParams));
1140 "malformedAuthorizedCredentials",
1141 "Invalid field 'authorized_credentials', array too long.");
1149 using namespace test::jtx;
1153 auto const USD = gw[
"USD"];
1154 env.
fund(
XRP(10000), alice, gw);
1157 env.
trust(USD(1000), alice);
1162 for (
int d = 1'000'032; d >= 1'000'000; --d)
1172 BEAST_EXPECT(jrr[jss::ledger_hash] ==
ledgerHash);
1173 BEAST_EXPECT(jrr[jss::ledger_index] == 5);
1176 std::string const dirRootIndex =
"A33EC6BB85FB5674074C4A3A43373BB17645308F3EAE1933E3E35252162B217D";
1180 jvParams[jss::directory] = dirRootIndex;
1183 BEAST_EXPECT(jrr[jss::node][sfIndexes.jsonName].
size() == 32);
1189 jvParams[jss::directory][jss::dir_root] = dirRootIndex;
1191 BEAST_EXPECT(jrr[jss::index] == dirRootIndex);
1197 jvParams[jss::directory][jss::owner] = alice.human();
1200 BEAST_EXPECT(jrr[jss::index] == dirRootIndex);
1206 jvParams[jss::directory][jss::dir_root] = dirRootIndex;
1207 jvParams[jss::directory][jss::sub_index] = 1;
1209 BEAST_EXPECT(jrr[jss::index] != dirRootIndex);
1210 BEAST_EXPECT(jrr[jss::node][sfIndexes.jsonName].
size() == 2);
1216 jvParams[jss::directory][jss::owner] = alice.human();
1217 jvParams[jss::directory][jss::sub_index] = 1;
1220 BEAST_EXPECT(jrr[jss::index] != dirRootIndex);
1221 BEAST_EXPECT(jrr[jss::node][sfIndexes.jsonName].
size() == 2);
1233 jvParams[jss::directory][jss::dir_root] = dirRootIndex;
1251 jvParams[jss::directory][jss::owner] = alice.human();
1252 jvParams[jss::directory][jss::dir_root] = dirRootIndex;
1255 checkErrorValue(jrr,
"malformedRequest",
"Must have exactly one of `owner` and `dir_root` fields.");
1261 jvParams[jss::directory][jss::sub_index] = 1;
1264 checkErrorValue(jrr,
"malformedRequest",
"Must have exactly one of `owner` and `dir_root` fields.");
1272 using namespace test::jtx;
1284 jv[jss::TransactionType] = jss::EscrowCreate;
1285 jv[jss::Account] = account.human();
1286 jv[jss::Destination] = to.human();
1288 jv[sfFinishAfter.jsonName] = cancelAfter.time_since_epoch().count() + 2;
1292 using namespace std::chrono_literals;
1293 env(escrowCreate(alice, alice,
XRP(333), env.
now() + 2s));
1302 jvParams[jss::escrow][jss::owner] = alice.human();
1303 jvParams[jss::escrow][jss::seq] = env.
seq(alice) - 1;
1305 BEAST_EXPECT(jrr[jss::node][jss::Amount] ==
XRP(333).value().getText());
1306 escrowIndex = jrr[jss::index].
asString();
1311 jvParams[jss::escrow] = escrowIndex;
1314 BEAST_EXPECT(jrr[jss::node][jss::Amount] ==
XRP(333).value().getText());
1318 runLedgerEntryTest(env, jss::escrow, {{jss::owner,
"malformedOwner"}, {jss::seq,
"malformedSeq"}});
1326 using namespace test::jtx;
1335 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::FeeSettings);
1346 using namespace test::jtx;
1355 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::LedgerHashes);
1366 using namespace test::jtx;
1370 Account const issuer{
"issuer"};
1372 env.
fund(
XRP(1000), issuer, buyer);
1382 jvParams[jss::nft_offer] =
to_string(offerID);
1384 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::NFTokenOffer);
1385 BEAST_EXPECT(jrr[jss::node][sfOwner.jsonName] == issuer.human());
1386 BEAST_EXPECT(jrr[jss::node][sfNFTokenID.jsonName] ==
to_string(nftokenID0));
1387 BEAST_EXPECT(jrr[jss::node][sfAmount.jsonName] ==
"1");
1398 using namespace test::jtx;
1402 Account const issuer{
"issuer"};
1409 BEAST_EXPECT(env.
le(nftpage) !=
nullptr);
1415 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::NFTokenPage);
1426 using namespace test::jtx;
1443 "ED58F6770DB5DD77E59D28CB650EC3816E2FC95021BB56E720C9A1"
1445 disabledValidator.setFieldVL(sfPublicKey, *pubKeyBlob);
1446 disabledValidator.setFieldU32(sfFirstLedgerSequence, 91371264);
1447 disabledValidators.
push_back(std::move(disabledValidator));
1449 sle->setFieldArray(sfDisabledValidators, disabledValidators);
1453 "A95160CC6D351341B9"
1455 sle->setFieldU32(sfPreviousTxnLgrSeq, 91442944);
1466 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::NegativeUNL);
1477 using namespace test::jtx;
1481 auto const USD = gw[
"USD"];
1482 env.
fund(
XRP(10000), alice, gw);
1485 env(
offer(alice, USD(321),
XRP(322)));
1494 jvParams[jss::offer][jss::account] = alice.human();
1495 jvParams[jss::offer][jss::seq] = env.
seq(alice) - 1;
1498 BEAST_EXPECT(jrr[jss::node][jss::TakerGets] ==
"322000000");
1499 offerIndex = jrr[jss::index].
asString();
1504 jvParams[jss::offer] = offerIndex;
1506 BEAST_EXPECT(jrr[jss::node][jss::TakerGets] ==
"322000000");
1511 runLedgerEntryTest(env, jss::offer, {{jss::account,
"malformedAddress"}, {jss::seq,
"malformedRequest"}});
1519 using namespace test::jtx;
1534 jv[jss::TransactionType] = jss::PaymentChannelCreate;
1535 jv[jss::Account] = account.human();
1536 jv[jss::Destination] = to.human();
1538 jv[sfSettleDelay.jsonName] = settleDelay.count();
1539 jv[sfPublicKey.jsonName] =
strHex(pk.slice());
1543 env(payChanCreate(alice, env.
master,
XRP(57), 18s, alice.pk()));
1552 jvParams[jss::payment_channel] =
to_string(payChanIndex);
1555 BEAST_EXPECT(jrr[jss::node][sfAmount.jsonName] ==
"57000000");
1556 BEAST_EXPECT(jrr[jss::node][sfBalance.jsonName] ==
"0");
1557 BEAST_EXPECT(jrr[jss::node][sfSettleDelay.jsonName] == 18);
1578 using namespace test::jtx;
1582 auto const USD = gw[
"USD"];
1583 env.
fund(
XRP(10000), alice, gw);
1586 env.
trust(USD(999), alice);
1589 env(
pay(gw, alice, USD(97)));
1593 for (
auto const& fieldName : {jss::ripple_state, jss::state})
1601 jvParams[fieldName][jss::accounts][0u] = alice.human();
1602 jvParams[fieldName][jss::accounts][1u] = gw.human();
1603 jvParams[fieldName][jss::currency] =
"USD";
1606 BEAST_EXPECT(jrr[jss::node][sfBalance.jsonName][jss::value] ==
"-97");
1607 BEAST_EXPECT(jrr[jss::node][sfHighLimit.jsonName][jss::value] ==
"999");
1615 {jss::accounts,
"malformedRequest"},
1616 {jss::currency,
"malformedCurrency"},
1624 jvParams[fieldName][jss::accounts][0u] = alice.human();
1625 jvParams[fieldName][jss::currency] =
"USD";
1631 "Invalid field 'accounts', not length-2 array of "
1639 jvParams[fieldName][jss::accounts][0u] = alice.human();
1640 jvParams[fieldName][jss::accounts][1u] = gw.human();
1641 jvParams[fieldName][jss::accounts][2u] = alice.human();
1642 jvParams[fieldName][jss::currency] =
"USD";
1648 "Invalid field 'accounts', not length-2 array of "
1655 auto tryField = [&](
Json::Value badAccount) ->
void {
1659 jvParams[fieldName][jss::accounts][0u] = badAccount;
1660 jvParams[fieldName][jss::accounts][1u] = gw.human();
1661 jvParams[fieldName][jss::currency] =
"USD";
1671 jvParams[fieldName][jss::accounts][0u] = alice.human();
1672 jvParams[fieldName][jss::accounts][1u] = badAccount;
1673 jvParams[fieldName][jss::currency] =
"USD";
1682 for (
auto const& value : badValues)
1693 jvParams[fieldName][jss::accounts][0u] = alice.human();
1694 jvParams[fieldName][jss::accounts][1u] = alice.human();
1695 jvParams[fieldName][jss::currency] =
"USD";
1698 checkErrorValue(jrr,
"malformedRequest",
"Cannot have a trustline to self.");
1707 using namespace test::jtx;
1716 using namespace test::jtx;
1743 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::Ticket);
1744 BEAST_EXPECT(jrr[jss::node][sfTicketSequence.jsonName] == tkt1);
1750 jvParams[jss::ticket][jss::account] = env.
master.
human();
1751 jvParams[jss::ticket][jss::ticket_seq] = tkt1 + 1;
1760 jvParams[jss::ticket][jss::account] = env.
master.
human();
1761 jvParams[jss::ticket][jss::ticket_seq] = tkt1 + 2;
1772 checkErrorValue(jrr,
"unexpectedLedgerType",
"Unexpected ledger type.");
1781 {jss::account,
"malformedAddress"},
1782 {jss::ticket_seq,
"malformedRequest"},
1791 using namespace test::jtx;
1802 jv[jss::TransactionType] = jss::DIDSet;
1803 jv[jss::Account] = account.human();
1809 env(didCreate(alice));
1817 jvParams[jss::did] = alice.human();
1820 BEAST_EXPECT(jrr[jss::node][sfDIDDocument.jsonName] ==
strHex(
std::string{
"data"}));
1841 testcase(
"Invalid Oracle Ledger Entry");
1848 Oracle oracle(env, {.owner = owner, .fee =
static_cast<int>(env.
current()->fees().base.drops())});
1856 {jss::account,
"malformedAccount"},
1857 {jss::oracle_document_id,
"malformedDocumentID"},
1870 auto const baseFee =
static_cast<int>(env.
current()->fees().base.drops());
1873 for (
int i = 0; i < 10; ++i)
1878 Oracle oracle(env, {.owner = owner, .documentID = i, .fee = baseFee});
1882 Oracle oracle1(env, {.owner = owner, .documentID = i + 10, .fee = baseFee});
1884 oracles.
push_back(oracle1.documentID());
1886 for (
int i = 0; i < accounts.
size(); ++i)
1888 auto const jv = [&]() {
1891 return Oracle::ledgerEntry(env, accounts[i], oracles[i]);
1893 return Oracle::ledgerEntry(env, accounts[i],
std::to_string(oracles[i]));
1897 BEAST_EXPECT(jv[jss::node][jss::Owner] ==
to_string(accounts[i]));
1910 using namespace test::jtx;
1916 MPTTester mptAlice(env, alice, {.holders = {bob}});
1923 mptAlice.authorize({.account = bob, .holderCount = 1});
1927 std::string const badMptID =
"00000193B9DDCAF401B5B3B26875986043F82CD0D13B4315";
1931 jvParams[jss::mpt_issuance] =
strHex(mptAlice.issuanceID());
1934 BEAST_EXPECT(jrr[jss::node][sfMPTokenMetadata.jsonName] ==
strHex(
std::string{
"123"}));
1935 BEAST_EXPECT(jrr[jss::node][jss::mpt_issuance_id] ==
strHex(mptAlice.issuanceID()));
1940 jvParams[jss::mpt_issuance] = badMptID;
1949 jvParams[jss::mptoken][jss::account] = bob.
human();
1950 jvParams[jss::mptoken][jss::mpt_issuance_id] =
strHex(mptAlice.issuanceID());
1953 BEAST_EXPECT(jrr[jss::node][sfMPTokenIssuanceID.jsonName] ==
strHex(mptAlice.issuanceID()));
1959 jvParams[jss::mptoken][jss::account] = bob.
human();
1960 jvParams[jss::mptoken][jss::mpt_issuance_id] = badMptID;
1977 using namespace test::jtx;
1980 Account const issuer{
"issuer"};
1984 env.
fund(
XRP(5000), issuer, alice, bob);
1987 auto const seq = env.
seq(alice);
1991 if (!BEAST_EXPECT(objects.size() == 1))
1997 params[jss::ledger_index] = jss::validated;
1998 params[jss::permissioned_domain][jss::account] = alice.human();
1999 params[jss::permissioned_domain][jss::seq] =
seq;
2000 auto jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2003 jv[jss::result].
isMember(jss::node) &&
2004 jv[jss::result][jss::node].
isMember(sfLedgerEntryType.jsonName) &&
2005 jv[jss::result][jss::node][sfLedgerEntryType.jsonName] == jss::PermissionedDomain);
2011 params[jss::ledger_index] = jss::validated;
2012 params[jss::permissioned_domain] = pdIdx;
2013 jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2016 jv[jss::result].
isMember(jss::node) &&
2017 jv[jss::result][jss::node].
isMember(sfLedgerEntryType.jsonName) &&
2018 jv[jss::result][jss::node][sfLedgerEntryType.jsonName] == jss::PermissionedDomain);
2024 params[jss::ledger_index] = jss::validated;
2025 params[jss::permissioned_domain] =
2026 "12F1F1F1F180D67377B2FAB292A31C922470326268D2B9B74CD1E582645B9A"
2028 auto const jrr = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2029 checkErrorValue(jrr[jss::result],
"entryNotFound",
"Entry not found.");
2035 jss::permissioned_domain,
2037 {jss::account,
"malformedAddress"},
2038 {jss::seq,
"malformedRequest"},
2047 using namespace test::jtx;
2069 auto checkResult = [&](
bool good,
2076 jv.isObject() && jv.isMember(jss::result) && !jv[jss::result].isMember(jss::error) &&
2077 jv[jss::result].isMember(jss::node) &&
2078 jv[jss::result][jss::node].isMember(sfLedgerEntryType.jsonName) &&
2079 jv[jss::result][jss::node][sfLedgerEntryType.jsonName] == expectedType,
2085 jv.isObject() && jv.isMember(jss::result) && jv[jss::result].isMember(jss::error) &&
2086 !jv[jss::result].isMember(jss::node) &&
2087 jv[jss::result][jss::error] == expectedError.value_or(
"entryNotFound"),
2104 Keylet const& expectedKey,
2106 testcase << expectedType.c_str() << (good ?
"" :
" not") <<
" found";
2108 auto const hexKey =
strHex(expectedKey.key);
2114 params[jss::ledger_index] = jss::validated;
2116 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2117 checkResult(
false, jv, expectedType,
"malformedRequest");
2118 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2124 params[jss::ledger_index] = jss::validated;
2125 params[field] =
"arbitrary string";
2126 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2127 checkResult(
false, jv, expectedType,
"malformedRequest");
2128 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2134 params[jss::ledger_index] = jss::validated;
2135 params[field] =
false;
2136 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2137 checkResult(
false, jv, expectedType,
"invalidParams");
2138 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2146 params[jss::ledger_index] = jss::validated;
2147 params[field] = badKey;
2148 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2149 checkResult(
false, jv, expectedType,
"entryNotFound");
2150 BEAST_EXPECTS(jv[jss::result][jss::index] == badKey,
to_string(jv));
2156 params[jss::ledger_index] = jss::validated;
2157 params[jss::index] = field;
2158 params[jss::api_version] = 2;
2159 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2160 checkResult(
false, jv, expectedType,
"malformedRequest");
2161 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2169 params[jss::ledger_index] = jss::validated;
2170 params[field] =
true;
2171 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2173 std::string const pdIdx = jv[jss::result][jss::index].asString();
2174 BEAST_EXPECTS(hexKey == pdIdx,
to_string(jv));
2175 checkResult(good, jv, expectedType);
2184 params[jss::ledger_index] = jss::validated;
2185 params[field] = hexKey;
2186 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2187 checkResult(good, jv, expectedType);
2188 BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
2195 params[jss::ledger_index] = jss::validated;
2196 params[jss::index] = field;
2197 params[jss::api_version] = 2;
2198 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2199 checkResult(
false, jv, expectedType,
"malformedRequest");
2200 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2206 params[jss::ledger_index] = jss::validated;
2207 params[jss::index] = field;
2208 params[jss::api_version] = 3;
2209 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2211 BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
2212 checkResult(good, jv, expectedType);
2218 params[jss::ledger_index] = jss::validated;
2219 params[jss::index] = pdIdx;
2220 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2222 BEAST_EXPECT(jv[jss::result][jss::index].asString() == hexKey);
2223 checkResult(good, jv, expectedType);
2228 test(jss::fee, jss::FeeSettings,
keylet::fees(),
true);
2232 test(jss::hashes, jss::LedgerHashes,
keylet::skip(),
true);
2238 using namespace test::jtx;
2260 auto checkResult = [&](
bool good,
2267 jv.isObject() && jv.isMember(jss::result) && !jv[jss::result].isMember(jss::error) &&
2268 jv[jss::result].isMember(jss::node) &&
2269 jv[jss::result][jss::node].isMember(sfLedgerEntryType.jsonName) &&
2270 jv[jss::result][jss::node][sfLedgerEntryType.jsonName] == jss::LedgerHashes,
2273 jv[jss::result].isMember(jss::node) && jv[jss::result][jss::node].isMember(
"Hashes") &&
2274 jv[jss::result][jss::node][
"Hashes"].size() == expectedCount,
2275 to_string(jv[jss::result][jss::node][
"Hashes"].size()));
2280 jv.isObject() && jv.isMember(jss::result) && jv[jss::result].isMember(jss::error) &&
2281 !jv[jss::result].isMember(jss::node) &&
2282 jv[jss::result][jss::error] == expectedError.value_or(
"entryNotFound"),
2297 auto test = [&](
Json::Value ledger,
Keylet const& expectedKey,
bool good,
int expectedCount = 0) {
2299 << (good ?
"" :
" not") <<
" found";
2301 auto const hexKey =
strHex(expectedKey.key);
2307 params[jss::ledger_index] = jss::validated;
2309 auto jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2310 checkResult(
false, jv, 0,
"malformedRequest");
2311 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2317 params[jss::ledger_index] = jss::validated;
2318 params[jss::hashes] =
"arbitrary string";
2319 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2320 checkResult(
false, jv, 0,
"malformedRequest");
2321 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2327 params[jss::ledger_index] = jss::validated;
2328 params[jss::hashes] =
"10";
2329 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2330 checkResult(
false, jv, 0,
"malformedRequest");
2331 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2337 params[jss::ledger_index] = jss::validated;
2338 params[jss::hashes] =
false;
2339 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2340 checkResult(
false, jv, 0,
"invalidParams");
2341 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2347 params[jss::ledger_index] = jss::validated;
2348 params[jss::hashes] = -1;
2349 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2350 checkResult(
false, jv, 0,
"internal");
2351 BEAST_EXPECT(!jv[jss::result].isMember(jss::index));
2358 params[jss::ledger_index] = jss::validated;
2359 params[jss::hashes] = badKey;
2360 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2361 checkResult(
false, jv, 0,
"entryNotFound");
2362 BEAST_EXPECT(jv[jss::result][jss::index] == badKey);
2369 params[jss::ledger_index] = jss::validated;
2370 params[jss::hashes] = ledger;
2371 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2372 checkResult(good, jv, expectedCount);
2374 std::string const pdIdx = jv[jss::result][jss::index].asString();
2375 BEAST_EXPECTS(hexKey == pdIdx,
strHex(pdIdx));
2381 params[jss::ledger_index] = jss::validated;
2382 params[jss::hashes] = hexKey;
2383 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2384 checkResult(good, jv, expectedCount);
2387 hexKey == jv[jss::result][jss::index].asString(),
strHex(jv[jss::result][jss::index].asString()));
2393 params[jss::ledger_index] = jss::validated;
2394 params[jss::index] = hexKey;
2395 auto const jv = env.
rpc(
"json",
"ledger_entry",
to_string(params));
2396 checkResult(good, jv, expectedCount);
2399 hexKey == jv[jss::result][jss::index].asString(),
strHex(jv[jss::result][jss::index].asString()));
2411 for (
auto i = env.
current()->seq(); i <= 250; ++i)
2422 for (
auto i = env.
current()->seq(); i <= 260; ++i)
2437 using namespace test::jtx;
2453 BEAST_EXPECT(jrr[jss::node][sfLedgerEntryType.jsonName] == jss::Check);
2454 BEAST_EXPECT(jrr[jss::node][sfSendMax.jsonName] ==
"100000000");
2499 if (BEAST_EXPECT(jv.
isMember(jss::status)))
2500 BEAST_EXPECT(jv[jss::status] ==
"error");
2501 if (BEAST_EXPECT(jv.
isMember(jss::error)))
2502 BEAST_EXPECT(jv[jss::error] == err);
2505 BEAST_EXPECT(jv[jss::error_message] ==
Json::nullValue || jv[jss::error_message] ==
"");
2507 else if (BEAST_EXPECT(jv.
isMember(jss::error_message)))
2508 BEAST_EXPECT(jv[jss::error_message] == msg);
2515 using namespace test::jtx;
2529 jvParams[jss::bridge] =
jvb;
2532 BEAST_EXPECT(jrr.
isMember(jss::node));
2533 auto r = jrr[jss::node];
2535 BEAST_EXPECT(r.isMember(jss::Account));
2538 BEAST_EXPECT(r.isMember(jss::Flags));
2540 BEAST_EXPECT(r.isMember(sfLedgerEntryType.jsonName));
2541 BEAST_EXPECT(r[sfLedgerEntryType.jsonName] == jss::Bridge);
2544 BEAST_EXPECT(r.isMember(sfXChainAccountCreateCount.jsonName));
2545 BEAST_EXPECT(r[sfXChainAccountCreateCount.jsonName].asInt() == 0);
2548 BEAST_EXPECT(r.isMember(sfXChainAccountClaimCount.jsonName));
2549 BEAST_EXPECT(r[sfXChainAccountClaimCount.jsonName].asInt() == 0);
2551 BEAST_EXPECT(r.isMember(jss::index));
2552 bridge_index = r[jss::index].asString();
2558 jvParams[jss::index] = bridge_index;
2561 BEAST_EXPECT(jrr.
isMember(jss::node));
2562 BEAST_EXPECT(jrr[jss::node] == mcBridge);
2569 jvParams[jss::bridge] =
jvb;
2586 jvParams[jss::bridge] =
jvb;
2589 BEAST_EXPECT(jrr.
isMember(jss::node));
2590 auto r = jrr[jss::node];
2593 BEAST_EXPECT(r.isMember(sfXChainClaimID.jsonName));
2594 BEAST_EXPECT(r[sfXChainClaimID.jsonName].asInt() == 2);
2601 testcase(
"ledger_entry: xchain_claim_id");
2602 using namespace test::jtx;
2619 jvParams[jss::xchain_owned_claim_id][jss::xchain_owned_claim_id] = 1;
2622 BEAST_EXPECT(jrr.
isMember(jss::node));
2623 auto r = jrr[jss::node];
2625 BEAST_EXPECT(r.isMember(jss::Account));
2627 BEAST_EXPECT(r[sfLedgerEntryType.jsonName] == jss::XChainOwnedClaimID);
2628 BEAST_EXPECT(r[sfXChainClaimID.jsonName].asInt() == 1);
2629 BEAST_EXPECT(r[sfOwnerNode.jsonName].asInt() == 0);
2636 jvParams[jss::xchain_owned_claim_id][jss::xchain_owned_claim_id] = 2;
2639 BEAST_EXPECT(jrr.
isMember(jss::node));
2640 auto r = jrr[jss::node];
2642 BEAST_EXPECT(r.isMember(jss::Account));
2643 BEAST_EXPECT(r[jss::Account] ==
scBob.
human());
2644 BEAST_EXPECT(r[sfLedgerEntryType.jsonName] == jss::XChainOwnedClaimID);
2645 BEAST_EXPECT(r[sfXChainClaimID.jsonName].asInt() == 2);
2646 BEAST_EXPECT(r[sfOwnerNode.jsonName].asInt() == 0);
2653 testcase(
"ledger_entry: xchain_create_account_claim_id");
2654 using namespace test::jtx;
2664 auto const amt =
XRP(1000);
2670 size_t constexpr num_attest = 3;
2683 for (
size_t i = 0; i < num_attest; ++i)
2685 scEnv(attestations[i]);
2692 jvParams[jss::xchain_owned_create_account_claim_id] =
jvXRPBridgeRPC;
2693 jvParams[jss::xchain_owned_create_account_claim_id][jss::xchain_owned_create_account_claim_id] = 1;
2696 BEAST_EXPECT(jrr.
isMember(jss::node));
2697 auto r = jrr[jss::node];
2699 BEAST_EXPECT(r.isMember(jss::Account));
2702 BEAST_EXPECT(r.isMember(sfXChainAccountCreateCount.jsonName));
2703 BEAST_EXPECT(r[sfXChainAccountCreateCount.jsonName].asInt() == 1);
2705 BEAST_EXPECT(r.isMember(sfXChainCreateAccountAttestations.jsonName));
2706 auto attest = r[sfXChainCreateAccountAttestations.jsonName];
2707 BEAST_EXPECT(attest.isArray());
2708 BEAST_EXPECT(attest.size() == 3);
2709 BEAST_EXPECT(attest[
Json::Value::UInt(0)].isMember(sfXChainCreateAccountProofSig.jsonName));
2711 for (
size_t i = 0; i < num_attest; ++i)
2714 BEAST_EXPECT(a[i].isMember(jss::Amount) && a[i][jss::Amount].asInt() == 1000 *
drop_per_xrp);
2715 BEAST_EXPECT(a[i].isMember(jss::Destination) && a[i][jss::Destination] ==
scCarol.
human());
2717 a[i].isMember(sfAttestationSignerAccount.jsonName) &&
2719 return a[i][sfAttestationSignerAccount.jsonName] == s.account.human();
2722 a[i].isMember(sfAttestationRewardAccount.jsonName) &&
2724 return a[i][sfAttestationRewardAccount.jsonName] == account.human();
2727 a[i].isMember(sfWasLockingChainSend.jsonName) && a[i][sfWasLockingChainSend.jsonName] == 1);
2729 a[i].isMember(sfSignatureReward.jsonName) &&
2738 scEnv(attestations[i]);
2744 jvParams[jss::xchain_owned_create_account_claim_id] =
jvXRPBridgeRPC;
2745 jvParams[jss::xchain_owned_create_account_claim_id][jss::xchain_owned_create_account_claim_id] = 1;
2762BEAST_DEFINE_TESTSUITE(LedgerEntry_XChain,
rpc,
xrpl);
Lightweight wrapper to tag static string.
constexpr char const * c_str() const
Value & append(Value const &value)
Append value to array at the end.
UInt size() const
Number of values in array or object.
std::string toStyledString() const
void clear()
Remove all object members and array elements.
Value removeMember(char const *key)
Remove and return the named member.
std::string asString() const
Returns the unquoted string value.
bool isNull() const
isNull() tests to see if this field is null.
bool isMember(char const *key) const
Return true if the object has a member named key.
A generic endpoint for log messages.
testcase_t testcase
Memberspace for declaring test cases.
void fail(String const &reason, char const *file, int line)
Record a failure.
bool modify(modify_type const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
void rawInsert(std::shared_ptr< SLE > const &sle) override
Unconditionally insert a state item.
void push_back(STObject const &object)
static STObject makeInnerObject(SField const &name)
virtual OpenLedger & openLedger()=0
static base_uint fromVoid(void const *data)
void testCreateAccountClaimID()
void run() override
Runs the suite.
void checkErrorValue(Json::Value const &jv, std::string const &err, std::string const &msg)
void checkErrorValue(Json::Value const &jv, std::string const &err, std::string const &msg, std::source_location const location=std::source_location::current())
void testOracleLedgerEntry()
void testMalformedSubfield(test::jtx::Env &env, Json::Value correctRequest, Json::StaticString parentFieldName, Json::StaticString fieldName, FieldType typeID, std::string const &expectedError, bool required=true, std::source_location const location=std::source_location::current())
void run() override
Runs the suite.
void testMalformedField(test::jtx::Env &env, Json::Value correctRequest, Json::StaticString const fieldName, FieldType const typeID, std::string const &expectedError, bool required=true, std::source_location const location=std::source_location::current())
void testDepositPreauth()
void runLedgerEntryTest(test::jtx::Env &env, Json::StaticString const &parentField, std::source_location const location=std::source_location::current())
void runLedgerEntryTest(test::jtx::Env &env, Json::StaticString const &parentField, std::vector< Subfield > const &subfields, std::source_location const location=std::source_location::current())
void testFixed()
Test the ledger entry types that don't take parameters.
void testPermissionedDomain()
void testDepositPreauthCred()
Json::Value getCorrectValue(Json::StaticString fieldName)
void testInvalidOracleLedgerEntry()
std::vector< Json::Value > getBadValues(FieldType fieldType)
Convenience class to test AMM functionality.
Immutable cryptographic account descriptor.
std::string const & human() const
Returns the human readable public key.
static Account const master
The master account.
AccountID id() const
Returns the Account ID.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
NetClock::time_point now()
Returns the current network time.
void create(MPTCreate const &arg=MPTCreate{})
Oracle class facilitates unit-testing of the Price Oracle feature.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Sets the optional Destination field on an NFTokenOffer.
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
std::string expected_field_message(std::string const &name, std::string const &type)
std::string missing_field_message(std::string const &name)
Keylet const & skip() noexcept
The index of the "short" skip list.
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Keylet const & amendments() noexcept
The index of the amendment table.
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Json::Value create(A const &account, A const &dest, STAmount const &sendMax)
Create a check.
Json::Value ledgerEntry(jtx::Env &env, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Json::Value set(jtx::Account const &account, jtx::Account const &authorize, std::vector< std::string > const &permissions)
Json::Value authCredentials(jtx::Account const &account, std::vector< AuthorizeCredentials > const &auth)
Json::Value auth(Account const &account, Account const &auth)
Preauthorize for deposit.
Json::Value setTx(AccountID const &account, Credentials const &credentials, std::optional< uint256 > domain)
std::map< uint256, Json::Value > getObjects(Account const &account, Env &env, bool withType)
Json::Value create(Account const &account, std::uint32_t count)
Create one of more tickets.
Json::Value mint(jtx::Account const &account, std::uint32_t nfTokenTaxon)
Mint an NFToken.
Json::Value createOffer(jtx::Account const &account, uint256 const &nftokenID, STAmount const &amount)
Create an NFTokenOffer.
uint256 getNextID(jtx::Env const &env, jtx::Account const &issuer, std::uint32_t nfTokenTaxon, std::uint16_t flags, std::uint16_t xferFee)
Get the next NFTokenID that will be issued.
Json::Value sidechain_xchain_account_create(Account const &acc, Json::Value const &bridge, Account const &dst, AnyAmount const &amt, AnyAmount const &reward)
constexpr std::size_t UT_XCHAIN_DEFAULT_NUM_SIGNERS
XRP_t const XRP
Converts to XRP Issue or STAmount.
require_t required(Args const &... args)
Compose many condition functors into one.
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
JValueVec create_account_attestations(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, jtx::AnyAmount const &rewardAmount, std::vector< jtx::Account > const &rewardAccounts, bool wasLockingChainSend, std::uint64_t createCount, jtx::Account const &dst, std::vector< jtx::signer > const &signers, std::size_t const numAtts, std::size_t const fromIdx)
Json::Value xchain_create_claim_id(Account const &acc, Json::Value const &bridge, STAmount const &reward, Account const &otherChainSource)
FeatureBitset testable_amendments()
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
std::vector< std::pair< Json::StaticString, FieldType > > mappings
FieldType getFieldType(Json::StaticString fieldName)
static uint256 ledgerHash(LedgerHeader const &info)
std::string getTypeName(FieldType typeID)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr std::uint32_t const tfTransferable
constexpr std::uint32_t const tfMPTCanTransfer
std::string to_string(base_uint< Bits, Tag > const &a)
std::string strHex(FwdIt begin, FwdIt end)
constexpr std::uint32_t const tfMPTRequireAuth
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
constexpr std::uint32_t asfDepositAuth
constexpr std::uint32_t const tfMPTCanTrade
constexpr std::uint32_t const tfMPTCanLock
constexpr std::uint32_t const tfMPTCanClawback
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
std::size_t constexpr maxCredentialsArraySize
The maximum number of credentials can be passed in array.
void forAllApiVersions(Fn const &fn, Args &&... args)
constexpr std::uint32_t const tfSellNFToken
constexpr std::uint32_t const tfMPTCanEscrow
A pair of SHAMap key and LedgerEntryType.
Json::StaticString fieldName
std::string malformedErrorMsg
void createBridgeObjects(Env &mcEnv, Env &scEnv)
Json::Value const jvXRPBridgeRPC
std::vector< Account > const payee
std::vector< signer > const signers
FeatureBitset const features
static constexpr int drop_per_xrp
Set the sequence number on a JTx.
A signer in a SignerList.