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>
73 BEAST_EXPECT(objects.size() == 1);
76 auto const domain = objects.begin()->first;
101 Account const alice2(
"alice2");
102 Account const alice3(
"alice3");
103 Account const alice4(
"alice4");
104 Account const alice5(
"alice5");
105 Account const alice6(
"alice6");
106 Account const alice7(
"alice7");
107 Account const alice8(
"alice8");
108 Account const alice9(
"alice9");
109 Account const alice10(
"alice10");
110 Account const alice11(
"alice11");
111 Account const alice12(
"alice12");
112 auto const setFee(
drops(env.
current()->fees().increment));
120 {alice2,
"credential1"},
121 {alice3,
"credential2"},
122 {alice4,
"credential3"},
123 {alice5,
"credential4"},
124 {alice6,
"credential5"},
125 {alice7,
"credential6"},
126 {alice8,
"credential7"},
127 {alice9,
"credential8"},
128 {alice10,
"credential9"},
129 {alice11,
"credential10"},
130 {alice12,
"credential11"}};
132 credentials11.size() ==
138 Account const nobody(
"nobody");
140 {alice2,
"credential1"},
141 {alice3,
"credential2"},
142 {alice4,
"credential3"},
143 {nobody,
"credential4"},
144 {alice5,
"credential5"},
145 {alice6,
"credential6"},
146 {alice7,
"credential7"}};
155 {alice2,
"credential1"},
156 {alice3,
"credential2"},
157 {alice4,
"credential3"},
158 {alice5,
"credential4"},
160 auto txJsonMutable =
pdomain::setTx(account, credentials4, domain);
161 auto const credentialOrig = txJsonMutable[
"AcceptedCredentials"][2u];
164 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
170 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
171 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
172 [
"CredentialType"] =
"";
177 "Cred0123456789012345678901234567890123456789012345678901234567890";
179 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
180 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
181 [
"CredentialType"] =
std::string(longCredentialType);
186 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
192 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
201 {alice7,
"credential6"},
202 {alice2,
"credential1"},
203 {alice3,
"credential2"},
204 {alice2,
"credential1"},
205 {alice5,
"credential4"},
209 for (
auto const& c : credentialsDup)
210 human2Acc.
emplace(c.issuer.human(), c.issuer);
213 BEAST_EXPECT(sorted.size() == 4);
227 auto const fromObject =
230 BEAST_EXPECT(fromObject == sortedCreds);
237 {alice2,
"credential3"},
238 {alice3,
"credential2"},
239 {alice2,
"credential9"},
240 {alice5,
"credential4"},
241 {alice2,
"credential6"},
244 for (
auto const& c : credentialsSame)
245 human2Acc.
emplace(c.issuer.human(), c.issuer);
258 auto const fromObject =
261 BEAST_EXPECT(fromObject == sortedCreds);
273 const int accNum = 12;
274 Account const alice[accNum] = {
288 for (
auto const& c : alice)
289 human2Acc.
emplace(c.human(), c);
291 for (
int i = 0; i < accNum; ++i)
300 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
301 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
303 auto domain = objects.begin()->first;
304 BEAST_EXPECT(domain.isNonZero());
305 auto object = objects.begin()->second;
306 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
307 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
308 BEAST_EXPECT(
object[
"Sequence"] == tx[
"Sequence"]);
317 "Cred0123456789012345678901234567890123456789012345678901234567"
329 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
330 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
332 bool findSeq =
false;
333 for (
auto const& [domain,
object] :
336 findSeq =
object[
"Sequence"] == tx[
"Sequence"];
339 BEAST_EXPECT(domain.isNonZero());
341 object[
"LedgerEntryType"] ==
"PermissionedDomain");
342 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
349 BEAST_EXPECT(findSeq);
355 {alice[2],
"credential1"},
356 {alice[3],
"credential2"},
357 {alice[4],
"credential3"},
358 {alice[5],
"credential4"},
359 {alice[6],
"credential5"},
360 {alice[7],
"credential6"},
361 {alice[8],
"credential7"},
362 {alice[9],
"credential8"},
363 {alice[10],
"credential9"},
364 {alice[0],
"credential10"},
369 credentials10.size() ==
377 auto object = objects[domain2];
421 auto const acctDelFee(
drops(env.
current()->fees().increment));
426 while (deleteDelta + ownerSeq > env.
current()->seq())
439 while (deleteDelta + ownerSeq > env.
current()->seq())
454 auto const setFee(
drops(env.
current()->fees().increment));
461 BEAST_EXPECT(objects.size() == 1);
462 auto const domain = objects.begin()->first;
493 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainDelete");
509 using namespace test::jtx;
516 auto const acctReserve = env.
current()->fees().accountReserve(0);
517 auto const incReserve = env.
current()->fees().increment;
518 env.
fund(acctReserve, alice);
520 BEAST_EXPECT(env.
balance(alice) == acctReserve);
530 auto const baseFee = env.
current()->fees().base.drops();
536 acctReserve + incReserve +
drops(baseFee) -
drops(1));
566BEAST_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 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