3#include <xrpld/app/tx/detail/PermissionedDomainSet.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/jss.h>
39 | featurePermissionedDomains | featureCredentials};
43 | featurePermissionedDomains | featureCredentials};
51 Env env(*
this, features);
57 BEAST_EXPECT(objects.size() == 1);
60 auto const domain = objects.begin()->first;
69 amendments.set(featurePermissionedDomains);
70 amendments.reset(featureCredentials);
73 Env env(*
this, amendments);
100 Account const alice5(
"alice5");
101 Account const alice6(
"alice6");
102 Account const alice7(
"alice7");
103 Account const alice8(
"alice8");
104 Account const alice9(
"alice9");
105 Account const alice10(
"alice10");
106 Account const alice11(
"alice11");
107 Account const alice12(
"alice12");
108 auto const setFee(
drops(env.
current()->fees().increment));
115 {alice2,
"credential1"},
116 {alice3,
"credential2"},
117 {alice4,
"credential3"},
118 {alice5,
"credential4"},
119 {alice6,
"credential5"},
120 {alice7,
"credential6"},
121 {alice8,
"credential7"},
122 {alice9,
"credential8"},
123 {alice10,
"credential9"},
124 {alice11,
"credential10"},
125 {alice12,
"credential11"}};
130 Account const nobody(
"nobody");
132 {alice2,
"credential1"},
133 {alice3,
"credential2"},
134 {alice4,
"credential3"},
135 {nobody,
"credential4"},
136 {alice5,
"credential5"},
137 {alice6,
"credential6"},
138 {alice7,
"credential7"}};
145 {alice2,
"credential1"},
146 {alice3,
"credential2"},
147 {alice4,
"credential3"},
148 {alice5,
"credential4"},
151 auto const credentialOrig = txJsonMutable[
"AcceptedCredentials"][2u];
154 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(jss::Issuer);
155 BEAST_EXPECT(
exceptionExpected(env, txJsonMutable).starts_with(
"invalidParams"));
158 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
159 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential][
"CredentialType"] =
"";
164 "Cred0123456789012345678901234567890123456789012345678901234567890";
166 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
167 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential][
"CredentialType"] =
std::string(longCredentialType);
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);
209 BEAST_EXPECT(fromObject == sortedCreds);
216 {alice2,
"credential3"},
217 {alice3,
"credential2"},
218 {alice2,
"credential9"},
219 {alice5,
"credential4"},
220 {alice2,
"credential6"},
223 for (
auto const& c : credentialsSame)
224 human2Acc.
emplace(c.issuer.human(), c.issuer);
238 BEAST_EXPECT(fromObject == sortedCreds);
247 Env env(*
this, features);
250 int const accNum = 12;
251 Account const alice[accNum] = {
265 for (
auto const& c : alice)
266 human2Acc.
emplace(c.human(), c);
268 for (
int i = 0; i < accNum; ++i)
277 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
278 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
280 auto domain = objects.begin()->first;
281 BEAST_EXPECT(
domain.isNonZero());
282 auto object = objects.begin()->second;
283 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
284 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
285 BEAST_EXPECT(
object[
"Sequence"] == tx[
"Sequence"]);
292 "Cred0123456789012345678901234567890123456789012345678901234567"
303 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
304 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
306 bool findSeq =
false;
309 findSeq =
object[
"Sequence"] == tx[
"Sequence"];
312 BEAST_EXPECT(
domain.isNonZero());
313 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
314 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
319 BEAST_EXPECT(findSeq);
325 {alice[2],
"credential1"},
326 {alice[3],
"credential2"},
327 {alice[4],
"credential3"},
328 {alice[5],
"credential4"},
329 {alice[6],
"credential5"},
330 {alice[7],
"credential6"},
331 {alice[8],
"credential7"},
332 {alice[9],
"credential8"},
333 {alice[10],
"credential9"},
334 {alice[0],
"credential10"},
344 auto object = objects[domain2];
378 auto const acctDelFee(
drops(env.
current()->fees().increment));
383 while (deleteDelta + ownerSeq > env.
current()->seq())
394 while (deleteDelta + ownerSeq > env.
current()->seq())
405 Env env(*
this, features);
409 auto const setFee(
drops(env.
current()->fees().increment));
416 BEAST_EXPECT(objects.size() == 1);
417 auto const domain = objects.begin()->first;
444 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainDelete");
460 using namespace test::jtx;
462 Env env(*
this, features);
467 auto const acctReserve = env.
current()->fees().reserve;
468 auto const incReserve = env.
current()->fees().increment;
469 env.
fund(acctReserve, alice);
471 BEAST_EXPECT(env.
balance(alice) == acctReserve);
481 auto const baseFee = env.
current()->fees().base.drops();
485 BEAST_EXPECT(env.
balance(alice) == acctReserve + incReserve +
drops(baseFee) -
drops(1));
520BEAST_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.
constexpr std::uint32_t tfClawTwoAssets
@ tecINSUFFICIENT_RESERVE
std::size_t constexpr maxCredentialTypeLength
The maximum length of a CredentialType inside a Credential.