21#include <xrpld/app/tx/detail/PermissionedDomainSet.h>
22#include <xrpl/protocol/Feature.h>
23#include <xrpl/protocol/jss.h>
57 | featurePermissionedDomains | featureCredentials};
71 BEAST_EXPECT(objects.size() == 1);
74 auto const domain = objects.begin()->first;
83 amendments.set(featurePermissionedDomains);
84 amendments.reset(featureCredentials);
87 Env env(*
this, amendments);
114 Account const alice2(
"alice2");
115 Account const alice3(
"alice3");
116 Account const alice4(
"alice4");
117 Account const alice5(
"alice5");
118 Account const alice6(
"alice6");
119 Account const alice7(
"alice7");
120 Account const alice8(
"alice8");
121 Account const alice9(
"alice9");
122 Account const alice10(
"alice10");
123 Account const alice11(
"alice11");
124 Account const alice12(
"alice12");
125 auto const setFee(
drops(env.
current()->fees().increment));
133 {alice2,
"credential1"},
134 {alice3,
"credential2"},
135 {alice4,
"credential3"},
136 {alice5,
"credential4"},
137 {alice6,
"credential5"},
138 {alice7,
"credential6"},
139 {alice8,
"credential7"},
140 {alice9,
"credential8"},
141 {alice10,
"credential9"},
142 {alice11,
"credential10"},
143 {alice12,
"credential11"}};
145 credentials11.size() ==
151 Account const nobody(
"nobody");
153 {alice2,
"credential1"},
154 {alice3,
"credential2"},
155 {alice4,
"credential3"},
156 {nobody,
"credential4"},
157 {alice5,
"credential5"},
158 {alice6,
"credential6"},
159 {alice7,
"credential7"}};
168 {alice2,
"credential1"},
169 {alice3,
"credential2"},
170 {alice4,
"credential3"},
171 {alice5,
"credential4"},
173 auto txJsonMutable =
pdomain::setTx(account, credentials4, domain);
174 auto const credentialOrig = txJsonMutable[
"AcceptedCredentials"][2u];
177 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
183 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
184 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
185 [
"CredentialType"] =
"";
190 "Cred0123456789012345678901234567890123456789012345678901234567890";
192 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
193 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
194 [
"CredentialType"] =
std::string(longCredentialType);
199 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
205 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
214 {alice7,
"credential6"},
215 {alice2,
"credential1"},
216 {alice3,
"credential2"},
217 {alice2,
"credential1"},
218 {alice5,
"credential4"},
222 for (
auto const& c : credentialsDup)
223 human2Acc.
emplace(c.issuer.human(), c.issuer);
226 BEAST_EXPECT(sorted.size() == 4);
240 auto const fromObject =
243 BEAST_EXPECT(fromObject == sortedCreds);
250 {alice2,
"credential3"},
251 {alice3,
"credential2"},
252 {alice2,
"credential9"},
253 {alice5,
"credential4"},
254 {alice2,
"credential6"},
257 for (
auto const& c : credentialsSame)
258 human2Acc.
emplace(c.issuer.human(), c.issuer);
271 auto const fromObject =
274 BEAST_EXPECT(fromObject == sortedCreds);
286 const int accNum = 12;
287 Account const alice[accNum] = {
301 for (
auto const& c : alice)
302 human2Acc.
emplace(c.human(), c);
304 for (
int i = 0; i < accNum; ++i)
313 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
314 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
316 auto domain = objects.begin()->first;
317 BEAST_EXPECT(domain.isNonZero());
318 auto object = objects.begin()->second;
319 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
320 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
321 BEAST_EXPECT(
object[
"Sequence"] == tx[
"Sequence"]);
330 "Cred0123456789012345678901234567890123456789012345678901234567"
342 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
343 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
345 bool findSeq =
false;
346 for (
auto const& [domain,
object] :
349 findSeq =
object[
"Sequence"] == tx[
"Sequence"];
352 BEAST_EXPECT(domain.isNonZero());
354 object[
"LedgerEntryType"] ==
"PermissionedDomain");
355 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
362 BEAST_EXPECT(findSeq);
368 {alice[2],
"credential1"},
369 {alice[3],
"credential2"},
370 {alice[4],
"credential3"},
371 {alice[5],
"credential4"},
372 {alice[6],
"credential5"},
373 {alice[7],
"credential6"},
374 {alice[8],
"credential7"},
375 {alice[9],
"credential8"},
376 {alice[10],
"credential9"},
377 {alice[0],
"credential10"},
382 credentials10.size() ==
390 auto object = objects[domain2];
434 auto const acctDelFee(
drops(env.
current()->fees().increment));
439 while (deleteDelta + ownerSeq > env.
current()->seq())
452 while (deleteDelta + ownerSeq > env.
current()->seq())
467 auto const setFee(
drops(env.
current()->fees().increment));
474 BEAST_EXPECT(objects.size() == 1);
475 auto const domain = objects.begin()->first;
506 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainDelete");
522 using namespace test::jtx;
529 auto const acctReserve = env.
current()->fees().accountReserve(0);
530 auto const incReserve = env.
current()->fees().increment;
531 env.
fund(acctReserve, alice);
533 BEAST_EXPECT(env.
balance(alice) == acctReserve);
543 auto const baseFee = env.
current()->fees().base.drops();
549 acctReserve + incReserve +
drops(baseFee) -
drops(1));
580BEAST_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.
Json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
XRP_t const XRP
Converts to XRP Issue or STAmount.
FeatureBitset supported_amendments()
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