21#include <xrpld/app/tx/detail/PermissionedDomainSet.h>
22#include <xrpld/ledger/ApplyViewImpl.h>
23#include <xrpl/basics/Blob.h>
24#include <xrpl/basics/Slice.h>
25#include <xrpl/protocol/Feature.h>
26#include <xrpl/protocol/Issue.h>
27#include <xrpl/protocol/jss.h>
60 | featurePermissionedDomains | featureCredentials};
74 BEAST_EXPECT(objects.size() == 1);
77 auto const domain = objects.begin()->first;
86 amendments.set(featurePermissionedDomains);
87 amendments.reset(featureCredentials);
90 Env env(*
this, amendments);
117 Account const alice2(
"alice2");
118 Account const alice3(
"alice3");
119 Account const alice4(
"alice4");
120 Account const alice5(
"alice5");
121 Account const alice6(
"alice6");
122 Account const alice7(
"alice7");
123 Account const alice8(
"alice8");
124 Account const alice9(
"alice9");
125 Account const alice10(
"alice10");
126 Account const alice11(
"alice11");
127 Account const alice12(
"alice12");
128 auto const setFee(
drops(env.
current()->fees().increment));
136 {alice2,
"credential1"},
137 {alice3,
"credential2"},
138 {alice4,
"credential3"},
139 {alice5,
"credential4"},
140 {alice6,
"credential5"},
141 {alice7,
"credential6"},
142 {alice8,
"credential7"},
143 {alice9,
"credential8"},
144 {alice10,
"credential9"},
145 {alice11,
"credential10"},
146 {alice12,
"credential11"}};
148 credentials11.size() ==
154 Account const nobody(
"nobody");
156 {alice2,
"credential1"},
157 {alice3,
"credential2"},
158 {alice4,
"credential3"},
159 {nobody,
"credential4"},
160 {alice5,
"credential5"},
161 {alice6,
"credential6"},
162 {alice7,
"credential7"}};
171 {alice2,
"credential1"},
172 {alice3,
"credential2"},
173 {alice4,
"credential3"},
174 {alice5,
"credential4"},
176 auto txJsonMutable =
pdomain::setTx(account, credentials4, domain);
177 auto const credentialOrig = txJsonMutable[
"AcceptedCredentials"][2u];
180 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
186 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
187 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
188 [
"CredentialType"] =
"";
193 "Cred0123456789012345678901234567890123456789012345678901234567890";
195 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
196 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
197 [
"CredentialType"] =
std::string(longCredentialType);
202 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
208 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
217 {alice7,
"credential6"},
218 {alice2,
"credential1"},
219 {alice3,
"credential2"},
220 {alice2,
"credential1"},
221 {alice5,
"credential4"},
225 for (
auto const& c : credentialsDup)
226 human2Acc.
emplace(c.issuer.human(), c.issuer);
229 BEAST_EXPECT(sorted.size() == 4);
243 auto const fromObject =
246 BEAST_EXPECT(fromObject == sortedCreds);
253 {alice2,
"credential3"},
254 {alice3,
"credential2"},
255 {alice2,
"credential9"},
256 {alice5,
"credential4"},
257 {alice2,
"credential6"},
260 for (
auto const& c : credentialsSame)
261 human2Acc.
emplace(c.issuer.human(), c.issuer);
274 auto const fromObject =
277 BEAST_EXPECT(fromObject == sortedCreds);
289 const int accNum = 12;
290 Account const alice[accNum] = {
304 for (
auto const& c : alice)
305 human2Acc.
emplace(c.human(), c);
307 for (
int i = 0; i < accNum; ++i)
316 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
317 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
319 auto domain = objects.begin()->first;
320 BEAST_EXPECT(domain.isNonZero());
321 auto object = objects.begin()->second;
322 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
323 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
324 BEAST_EXPECT(
object[
"Sequence"] == tx[
"Sequence"]);
333 "Cred0123456789012345678901234567890123456789012345678901234567"
345 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
346 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
348 bool findSeq =
false;
349 for (
auto const& [domain,
object] :
352 findSeq =
object[
"Sequence"] == tx[
"Sequence"];
355 BEAST_EXPECT(domain.isNonZero());
357 object[
"LedgerEntryType"] ==
"PermissionedDomain");
358 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
365 BEAST_EXPECT(findSeq);
371 {alice[2],
"credential1"},
372 {alice[3],
"credential2"},
373 {alice[4],
"credential3"},
374 {alice[5],
"credential4"},
375 {alice[6],
"credential5"},
376 {alice[7],
"credential6"},
377 {alice[8],
"credential7"},
378 {alice[9],
"credential8"},
379 {alice[10],
"credential9"},
380 {alice[0],
"credential10"},
385 credentials10.size() ==
393 auto object = objects[domain2];
437 auto const acctDelFee(
drops(env.
current()->fees().increment));
442 while (deleteDelta + ownerSeq > env.
current()->seq())
455 while (deleteDelta + ownerSeq > env.
current()->seq())
470 auto const setFee(
drops(env.
current()->fees().increment));
477 BEAST_EXPECT(objects.size() == 1);
478 auto const domain = objects.begin()->first;
509 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainDelete");
525 using namespace test::jtx;
532 auto const acctReserve = env.
current()->fees().accountReserve(0);
533 auto const incReserve = env.
current()->fees().increment;
534 env.
fund(acctReserve, alice);
536 BEAST_EXPECT(env.
balance(alice) == acctReserve);
546 auto const baseFee = env.
current()->fees().base.drops();
552 acctReserve + incReserve +
drops(baseFee) -
drops(1));
583BEAST_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