3#include <xrpld/app/tx/detail/PermissionedDomainSet.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/jss.h>
40 | featurePermissionedDomains | featureCredentials};
54 BEAST_EXPECT(objects.size() == 1);
57 auto const domain = objects.begin()->first;
66 amendments.set(featurePermissionedDomains);
67 amendments.reset(featureCredentials);
70 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));
116 {alice2,
"credential1"},
117 {alice3,
"credential2"},
118 {alice4,
"credential3"},
119 {alice5,
"credential4"},
120 {alice6,
"credential5"},
121 {alice7,
"credential6"},
122 {alice8,
"credential7"},
123 {alice9,
"credential8"},
124 {alice10,
"credential9"},
125 {alice11,
"credential10"},
126 {alice12,
"credential11"}};
128 credentials11.size() ==
134 Account const nobody(
"nobody");
136 {alice2,
"credential1"},
137 {alice3,
"credential2"},
138 {alice4,
"credential3"},
139 {nobody,
"credential4"},
140 {alice5,
"credential5"},
141 {alice6,
"credential6"},
142 {alice7,
"credential7"}};
151 {alice2,
"credential1"},
152 {alice3,
"credential2"},
153 {alice4,
"credential3"},
154 {alice5,
"credential4"},
157 auto const credentialOrig = txJsonMutable[
"AcceptedCredentials"][2u];
160 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
166 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
167 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
168 [
"CredentialType"] =
"";
173 "Cred0123456789012345678901234567890123456789012345678901234567890";
175 txJsonMutable[
"AcceptedCredentials"][2u] = credentialOrig;
176 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential]
177 [
"CredentialType"] =
std::string(longCredentialType);
182 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
188 txJsonMutable[
"AcceptedCredentials"][2u][jss::Credential].removeMember(
197 {alice7,
"credential6"},
198 {alice2,
"credential1"},
199 {alice3,
"credential2"},
200 {alice2,
"credential1"},
201 {alice5,
"credential4"},
205 for (
auto const& c : credentialsDup)
206 human2Acc.
emplace(c.issuer.human(), c.issuer);
209 BEAST_EXPECT(sorted.size() == 4);
223 auto const fromObject =
226 BEAST_EXPECT(fromObject == sortedCreds);
233 {alice2,
"credential3"},
234 {alice3,
"credential2"},
235 {alice2,
"credential9"},
236 {alice5,
"credential4"},
237 {alice2,
"credential6"},
240 for (
auto const& c : credentialsSame)
241 human2Acc.
emplace(c.issuer.human(), c.issuer);
254 auto const fromObject =
257 BEAST_EXPECT(fromObject == sortedCreds);
269 int const accNum = 12;
270 Account const alice[accNum] = {
284 for (
auto const& c : alice)
285 human2Acc.
emplace(c.human(), c);
287 for (
int i = 0; i < accNum; ++i)
296 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
297 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
299 auto domain = objects.begin()->first;
300 BEAST_EXPECT(
domain.isNonZero());
301 auto object = objects.begin()->second;
302 BEAST_EXPECT(
object[
"LedgerEntryType"] ==
"PermissionedDomain");
303 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
304 BEAST_EXPECT(
object[
"Sequence"] == tx[
"Sequence"]);
313 "Cred0123456789012345678901234567890123456789012345678901234567"
325 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainSet");
326 BEAST_EXPECT(tx[
"Account"] == alice[0].human());
328 bool findSeq =
false;
329 for (
auto const& [
domain,
object] :
332 findSeq =
object[
"Sequence"] == tx[
"Sequence"];
335 BEAST_EXPECT(
domain.isNonZero());
337 object[
"LedgerEntryType"] ==
"PermissionedDomain");
338 BEAST_EXPECT(
object[
"Owner"] == alice[0].human());
345 BEAST_EXPECT(findSeq);
351 {alice[2],
"credential1"},
352 {alice[3],
"credential2"},
353 {alice[4],
"credential3"},
354 {alice[5],
"credential4"},
355 {alice[6],
"credential5"},
356 {alice[7],
"credential6"},
357 {alice[8],
"credential7"},
358 {alice[9],
"credential8"},
359 {alice[10],
"credential9"},
360 {alice[0],
"credential10"},
365 credentials10.size() ==
373 auto object = objects[domain2];
417 auto const acctDelFee(
drops(env.
current()->fees().increment));
422 while (deleteDelta + ownerSeq > env.
current()->seq())
435 while (deleteDelta + ownerSeq > env.
current()->seq())
450 auto const setFee(
drops(env.
current()->fees().increment));
457 BEAST_EXPECT(objects.size() == 1);
458 auto const domain = objects.begin()->first;
489 BEAST_EXPECT(tx[jss::TransactionType] ==
"PermissionedDomainDelete");
505 using namespace test::jtx;
512 auto const acctReserve = env.
current()->fees().reserve;
513 auto const incReserve = env.
current()->fees().increment;
514 env.
fund(acctReserve, alice);
516 BEAST_EXPECT(env.
balance(alice) == acctReserve);
526 auto const baseFee = env.
current()->fees().base.drops();
532 acctReserve + incReserve +
drops(baseFee) -
drops(1));
563BEAST_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.
FeatureBitset testable_amendments()
Json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
XRP_t const XRP
Converts to XRP Issue or 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
std::size_t constexpr maxCredentialTypeLength
The maximum length of a CredentialType inside a Credential.
@ tecINSUFFICIENT_RESERVE