3#include <xrpl/protocol/Feature.h>
4#include <xrpl/protocol/jss.h>
5#include <xrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.h>
38 | featurePermissionedDomains | featureCredentials};
42 | featurePermissionedDomains | featureCredentials};
50 Env env(*
this, features);
56 BEAST_EXPECT(objects.size() == 1);
59 auto const domain = objects.begin()->first;
68 amendments.set(featurePermissionedDomains);
69 amendments.reset(featureCredentials);
72 Env env(*
this, amendments);
100 Account const alice6(
"alice6");
101 Account const alice7(
"alice7");
102 Account const alice8(
"alice8");
103 Account const alice9(
"alice9");
104 Account const alice10(
"alice10");
105 Account const alice11(
"alice11");
106 Account const alice12(
"alice12");
107 auto const setFee(
drops(env.
current()->fees().increment));
114 {alice2,
"credential1"},
115 {alice3,
"credential2"},
116 {alice4,
"credential3"},
117 {alice5,
"credential4"},
118 {alice6,
"credential5"},
119 {alice7,
"credential6"},
120 {alice8,
"credential7"},
121 {alice9,
"credential8"},
122 {alice10,
"credential9"},
123 {alice11,
"credential10"},
124 {alice12,
"credential11"}};
129 Account const nobody(
"nobody");
131 {alice2,
"credential1"},
132 {alice3,
"credential2"},
133 {alice4,
"credential3"},
134 {nobody,
"credential4"},
135 {alice5,
"credential5"},
136 {alice6,
"credential6"},
137 {alice7,
"credential7"}};
144 {alice2,
"credential1"},
145 {alice3,
"credential2"},
146 {alice4,
"credential3"},
147 {alice5,
"credential4"},
150 auto const credentialOrig = txJsonMutable[
"AcceptedCredentials"][2u];
153 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(jss::Issuer);
154 BEAST_EXPECT(
exceptionExpected(env, txJsonMutable).starts_with(
"invalidParams"));
157 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
158 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential][
"CredentialType"] =
"";
163 "Cred0123456789012345678901234567890123456789012345678901234567890";
165 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
166 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential][
"CredentialType"] =
168 BEAST_EXPECT(
exceptionExpected(env, txJsonMutable).starts_with(
"invalidParams"));
171 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
"CredentialType");
172 BEAST_EXPECT(
exceptionExpected(env, txJsonMutable).starts_with(
"invalidParams"));
175 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(jss::Issuer);
176 BEAST_EXPECT(
exceptionExpected(env, txJsonMutable).starts_with(
"invalidParams"));
182 {alice7,
"credential6"},
183 {alice2,
"credential1"},
184 {alice3,
"credential2"},
185 {alice2,
"credential1"},
186 {alice5,
"credential4"},
190 for (
auto const& c : credentialsDup)
191 human2Acc.
emplace(c.issuer.human(), c.issuer);
194 BEAST_EXPECT(sorted.size() == 4);
213 BEAST_EXPECT(fromObject == sortedCreds);
220 {alice2,
"credential3"},
221 {alice3,
"credential2"},
222 {alice2,
"credential9"},
223 {alice5,
"credential4"},
224 {alice2,
"credential6"},
227 for (
auto const& c : credentialsSame)
228 human2Acc.
emplace(c.issuer.human(), c.issuer);
246 BEAST_EXPECT(fromObject == sortedCreds);
255 Env env(*
this, features);
258 int const accNum = 12;
259 Account const alice[accNum] = {
273 for (
auto const& c : alice)
274 human2Acc.
emplace(c.human(), c);
276 for (
int i = 0; i < accNum; ++i)
285 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
286 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
288 auto domain = objects.begin()->first;
289 BEAST_EXPECT(
domain.isNonZero());
290 auto object = objects.begin()->second;
291 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
292 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
293 BEAST_EXPECT(
object[
"Sequence"] == tx[
"Sequence"]);
300 "Cred0123456789012345678901234567890123456789012345678901234567"
311 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
312 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
314 bool findSeq =
false;
317 findSeq =
object[
"Sequence"] == tx[
"Sequence"];
320 BEAST_EXPECT(
domain.isNonZero());
321 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
322 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
328 BEAST_EXPECT(findSeq);
334 {alice[2],
"credential1"},
335 {alice[3],
"credential2"},
336 {alice[4],
"credential3"},
337 {alice[5],
"credential4"},
338 {alice[6],
"credential5"},
339 {alice[7],
"credential6"},
340 {alice[8],
"credential7"},
341 {alice[9],
"credential8"},
342 {alice[10],
"credential9"},
343 {alice[0],
"credential10"},
353 auto object = objects[domain2];
390 auto const acctDelFee(
drops(env.
current()->fees().increment));
395 while (deleteDelta + ownerSeq > env.
current()->seq())
406 while (deleteDelta + ownerSeq > env.
current()->seq())
417 Env env(*
this, features);
421 auto const setFee(
drops(env.
current()->fees().increment));
428 BEAST_EXPECT(objects.size() == 1);
429 auto const domain = objects.begin()->first;
456 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainDelete");
472 using namespace test::jtx;
474 Env env(*
this, features);
479 auto const acctReserve = env.
current()->fees().reserve;
480 auto const incReserve = env.
current()->fees().increment;
481 env.
fund(acctReserve, alice);
483 BEAST_EXPECT(env.
balance(alice) == acctReserve);
493 auto const baseFee = env.
current()->fees().base.drops();
497 BEAST_EXPECT(env.
balance(alice) == acctReserve + incReserve +
drops(baseFee) -
drops(1));
532BEAST_DEFINE_TESTSUITE(PermissionedDomains, app,
xrpl);
testcase_t testcase
Memberspace for declaring test cases.
void testSet(FeatureBitset features)
void testEnabled(FeatureBitset features)
void testAccountReserve(FeatureBitset features)
void testBadData(Account const &account, Env &env, std::optional< uint256 > domain=std::nullopt)
void testDelete(FeatureBitset features)
FeatureBitset withoutFeature_
void run() override
Runs the suite.
void testCredentialsDisabled()
FeatureBitset withFeature_
Immutable cryptographic account descriptor.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
void set_parse_failure_expected(bool b)
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.
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
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.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Credentials credentialsFromJson(Json::Value const &object, std::unordered_map< std::string, Account > const &human2Acc)
Json::Value setTx(AccountID const &account, Credentials const &credentials, std::optional< uint256 > domain)
Json::Value deleteTx(AccountID const &account, uint256 const &domain)
uint256 getNewDomain(std::shared_ptr< STObject const > const &meta)
Credentials sortCredentials(Credentials const &input)
std::map< uint256, Json::Value > getObjects(Account const &account, Env &env, bool withType)
bool objectExists(uint256 const &objID, Env &env)
XRP_t const XRP
Converts to XRP Issue or 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.
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to 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.
@ tecINSUFFICIENT_RESERVE
std::size_t constexpr maxCredentialTypeLength
The maximum length of a CredentialType inside a Credential.