22#include <xrpld/app/tx/detail/PermissionedDomainSet.h>
24#include <xrpl/protocol/Feature.h>
25#include <xrpl/protocol/jss.h>
59 | featurePermissionedDomains | featureCredentials};
73 BEAST_EXPECT(objects.size() == 1);
76 auto const domain = objects.begin()->first;
85 amendments.set(featurePermissionedDomains);
86 amendments.reset(featureCredentials);
89 Env env(*
this, amendments);
116 Account const alice2(
"alice2");
117 Account const alice3(
"alice3");
118 Account const alice4(
"alice4");
119 Account const alice5(
"alice5");
120 Account const alice6(
"alice6");
121 Account const alice7(
"alice7");
122 Account const alice8(
"alice8");
123 Account const alice9(
"alice9");
124 Account const alice10(
"alice10");
125 Account const alice11(
"alice11");
126 Account const alice12(
"alice12");
127 auto const setFee(
drops(env.
current()->fees().increment));
135 {alice2,
"credential1"},
136 {alice3,
"credential2"},
137 {alice4,
"credential3"},
138 {alice5,
"credential4"},
139 {alice6,
"credential5"},
140 {alice7,
"credential6"},
141 {alice8,
"credential7"},
142 {alice9,
"credential8"},
143 {alice10,
"credential9"},
144 {alice11,
"credential10"},
145 {alice12,
"credential11"}};
147 credentials11.size() ==
153 Account const nobody(
"nobody");
155 {alice2,
"credential1"},
156 {alice3,
"credential2"},
157 {alice4,
"credential3"},
158 {nobody,
"credential4"},
159 {alice5,
"credential5"},
160 {alice6,
"credential6"},
161 {alice7,
"credential7"}};
170 {alice2,
"credential1"},
171 {alice3,
"credential2"},
172 {alice4,
"credential3"},
173 {alice5,
"credential4"},
176 auto const credentialOrig = txJsonMutable[
"AcceptedCredentials"][2u];
179 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
185 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
186 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
187 [
"CredentialType"] =
"";
192 "Cred0123456789012345678901234567890123456789012345678901234567890";
194 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
195 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
196 [
"CredentialType"] =
std::string(longCredentialType);
201 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
207 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
216 {alice7,
"credential6"},
217 {alice2,
"credential1"},
218 {alice3,
"credential2"},
219 {alice2,
"credential1"},
220 {alice5,
"credential4"},
224 for (
auto const& c : credentialsDup)
225 human2Acc.
emplace(c.issuer.human(), c.issuer);
228 BEAST_EXPECT(sorted.size() == 4);
242 auto const fromObject =
245 BEAST_EXPECT(fromObject == sortedCreds);
252 {alice2,
"credential3"},
253 {alice3,
"credential2"},
254 {alice2,
"credential9"},
255 {alice5,
"credential4"},
256 {alice2,
"credential6"},
259 for (
auto const& c : credentialsSame)
260 human2Acc.
emplace(c.issuer.human(), c.issuer);
273 auto const fromObject =
276 BEAST_EXPECT(fromObject == sortedCreds);
288 int const accNum = 12;
289 Account const alice[accNum] = {
303 for (
auto const& c : alice)
304 human2Acc.
emplace(c.human(), c);
306 for (
int i = 0; i < accNum; ++i)
315 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
316 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
318 auto domain = objects.begin()->first;
319 BEAST_EXPECT(
domain.isNonZero());
320 auto object = objects.begin()->second;
321 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
322 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
323 BEAST_EXPECT(
object[
"Sequence"] == tx[
"Sequence"]);
332 "Cred0123456789012345678901234567890123456789012345678901234567"
344 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
345 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
347 bool findSeq =
false;
348 for (
auto const& [
domain,
object] :
351 findSeq =
object[
"Sequence"] == tx[
"Sequence"];
354 BEAST_EXPECT(
domain.isNonZero());
356 object[
"LedgerEntryType"] ==
"PermissionedDomain");
357 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
364 BEAST_EXPECT(findSeq);
370 {alice[2],
"credential1"},
371 {alice[3],
"credential2"},
372 {alice[4],
"credential3"},
373 {alice[5],
"credential4"},
374 {alice[6],
"credential5"},
375 {alice[7],
"credential6"},
376 {alice[8],
"credential7"},
377 {alice[9],
"credential8"},
378 {alice[10],
"credential9"},
379 {alice[0],
"credential10"},
384 credentials10.size() ==
392 auto object = objects[domain2];
436 auto const acctDelFee(
drops(env.
current()->fees().increment));
441 while (deleteDelta + ownerSeq > env.
current()->seq())
454 while (deleteDelta + ownerSeq > env.
current()->seq())
469 auto const setFee(
drops(env.
current()->fees().increment));
476 BEAST_EXPECT(objects.size() == 1);
477 auto const domain = objects.begin()->first;
508 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainDelete");
524 using namespace test::jtx;
531 auto const acctReserve = env.
current()->fees().accountReserve(0);
532 auto const incReserve = env.
current()->fees().increment;
533 env.
fund(acctReserve, alice);
535 BEAST_EXPECT(env.
balance(alice) == acctReserve);
545 auto const baseFee = env.
current()->fees().base.drops();
551 acctReserve + incReserve +
drops(baseFee) -
drops(1));
582BEAST_DEFINE_TESTSUITE(PermissionedDomains, app,
ripple);
testcase_t testcase
Memberspace for declaring test cases.
void run() override
Runs the suite.
FeatureBitset withFeature_
FeatureBitset withoutFeature_
void testBadData(Account const &account, Env &env, std::optional< uint256 > domain=std::nullopt)
void testCredentialsDisabled()
void testAccountReserve()
Immutable cryptographic account descriptor.
A transaction testing environment.
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
void set_parse_failure_expected(bool b)
Set the expected result code for a JTx The test will fail if the code doesn't match.
Credentials sortCredentials(Credentials const &input)
Credentials credentialsFromJson(Json::Value const &object, std::unordered_map< std::string, Account > const &human2Acc)
bool objectExists(uint256 const &objID, Env &env)
Json::Value deleteTx(AccountID const &account, uint256 const &domain)
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)
uint256 getNewDomain(std::shared_ptr< STObject const > const &meta)
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
FeatureBitset testable_amendments()
Json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
XRP_t const XRP
Converts to XRP Issue or STAmount.
static std::string exceptionExpected(Env &env, Json::Value const &jv)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::size_t constexpr maxPermissionedDomainCredentialsArraySize
The maximum number of credentials can be passed in array for permissioned domain.
constexpr std::uint32_t tfClawTwoAssets
std::size_t constexpr maxCredentialTypeLength
The maximum length of a CredentialType inside a Credential.
@ tecINSUFFICIENT_RESERVE