21#include <test/jtx/trust.h>
23#include <xrpl/protocol/Feature.h>
33 return boost::lexical_cast<std::string>(t);
41 if (
auto const sleAcct = env.
le(acct))
42 ret = sleAcct->at(~sfTicketCount).value_or(0);
56 auto const useHigh = src.
id() > dst.
id();
59 Throw<std::runtime_error>(
"No line in getLineFreezeFlag");
66 testcase(
"Enable AllowTrustLineClawback flag");
67 using namespace test::jtx;
73 Env env(*
this, features);
98 Env env(*
this, features);
123 Env env(*
this, features);
128 env.
fund(
XRP(1000), alice, bob);
131 auto const USD = alice[
"USD"];
135 env.
trust(USD(1000), bob);
136 env(
pay(alice, bob, USD(10)));
148 env(
trust(bob, USD(0), 0));
149 env(
pay(bob, alice, USD(10)));
166 Env env(*
this, features - featureClawback);
197 using namespace test::jtx;
203 Env env(*
this, features - featureClawback);
208 env.
fund(
XRP(1000), alice, bob);
213 auto const USD = alice[
"USD"];
216 env.
trust(USD(1000), bob);
217 env(
pay(alice, bob, USD(10)));
248 Env env(*
this, features);
253 env.
fund(
XRP(1000), alice, bob);
261 auto const USD = alice[
"USD"];
264 env.
trust(USD(1000), bob);
265 env(
pay(alice, bob, USD(10)));
272 env(
claw(alice, bob[
"USD"](5)),
295 env(
pay(bob, alice, USD(10)));
309 env(
trust(bob, USD(0), 0));
328 using namespace test::jtx;
332 Env env(*
this, features);
354 Env env(*
this, features);
360 env.
fund(
XRP(1000), alice, bob, cindy);
363 auto const USD = alice[
"USD"];
376 env.
trust(USD(1000), bob);
377 env(
pay(alice, bob, USD(1000)));
397 Env env(*
this, features);
402 env.
fund(
XRP(1000), alice, bob);
405 auto const USD = alice[
"USD"];
406 auto const CAD = bob[
"CAD"];
425 env.
trust(USD(1000), bob);
426 env(
pay(alice, bob, USD(10)));
445 env.
trust(CAD(1000), alice);
446 env(
pay(bob, alice, CAD(10)));
464 using namespace test::jtx;
467 Env env(*
this, features);
472 env.
fund(
XRP(1000), alice, bob);
475 auto const USD = alice[
"USD"];
483 env.
trust(USD(1000), bob);
484 env(
pay(alice, bob, USD(1000)));
491 env(
claw(alice, bob[
"USD"](200)));
499 env(
claw(alice, bob[
"USD"](800)));
512 using namespace test::jtx;
518 Env env(*
this, features);
524 env.
fund(
XRP(1000), alice, bob, cindy);
538 env.
trust(alice[
"USD"](1000), cindy);
539 env(
pay(alice, cindy, alice[
"USD"](1000)));
543 env.
trust(bob[
"USD"](1000), cindy);
544 env(
pay(bob, cindy, bob[
"USD"](1000)));
548 env(
claw(alice, cindy[
"USD"](200)));
560 env(
claw(bob, cindy[
"USD"](600)));
576 Env env(*
this, features);
582 env.
fund(
XRP(1000), alice, bob, cindy);
585 auto const USD = alice[
"USD"];
593 env.
trust(USD(1000), bob);
594 env(
pay(alice, bob, USD(600)));
601 env.
trust(USD(1000), cindy);
602 env(
pay(alice, cindy, USD(1000)));
609 env(
claw(alice, bob[
"USD"](500)));
621 env(
claw(alice, cindy[
"USD"](300)));
638 using namespace test::jtx;
646 Env env(*
this, features);
651 env.
fund(
XRP(1000), alice, bob);
665 env.
trust(alice[
"USD"](1000), bob);
666 env(
pay(alice, bob, alice[
"USD"](1000)));
677 env.
trust(bob[
"USD"](1500), alice);
678 env(
pay(bob, alice, bob[
"USD"](1500)));
699 env(
claw(bob, alice[
"USD"](200)));
706 env(
pay(alice, bob, alice[
"USD"](1000)));
719 env(
claw(alice, bob[
"USD"](200)));
729 testcase(
"Delete default trustline");
730 using namespace test::jtx;
734 Env env(*
this, features);
738 env.
fund(
XRP(1000), alice, bob);
741 auto const USD = alice[
"USD"];
749 env.
trust(USD(1000), bob);
750 env(
pay(alice, bob, USD(1000)));
760 env(
trust(bob, USD(0), 0));
768 env(
claw(alice, bob[
"USD"](1000)));
780 using namespace test::jtx;
784 Env env(*
this, features);
788 env.
fund(
XRP(1000), alice, bob);
791 auto const USD = alice[
"USD"];
799 env.
trust(USD(1000), bob);
800 env(
pay(alice, bob, USD(1000)));
811 env(
claw(alice, bob[
"USD"](200)));
825 testcase(
"Amount exceeds available");
826 using namespace test::jtx;
830 Env env(*
this, features);
834 env.
fund(
XRP(1000), alice, bob);
837 auto const USD = alice[
"USD"];
845 env.
trust(USD(1000), bob);
846 env(
pay(alice, bob, USD(1000)));
853 env(
claw(alice, bob[
"USD"](2000)));
867 env(
trust(bob, USD(0), 0));
879 using namespace test::jtx;
882 Env env(*
this, features);
886 env.
fund(
XRP(1000), alice, bob);
889 auto const USD = alice[
"USD"];
897 env.
trust(USD(1000), bob);
898 env(
pay(alice, bob, USD(100)));
910 BEAST_EXPECT(
ticketCount(env, alice) == ticketCnt);
911 BEAST_EXPECT(
ownerCount(env, alice) == ticketCnt);
913 while (ticketCnt > 0)
920 BEAST_EXPECT(
ticketCount(env, alice) == ticketCnt);
921 BEAST_EXPECT(
ownerCount(env, alice) == ticketCnt);
929 BEAST_EXPECT(env.
seq(alice) == aliceSeq);
951 using namespace test::jtx;
testcase_t testcase
Memberspace for declaring test cases.
void testDeleteDefaultLine(FeatureBitset features)
void testPermission(FeatureBitset features)
void testBidirectionalLine(FeatureBitset features)
void testAmountExceedsAvailable(FeatureBitset features)
void run() override
Runs the suite.
static std::uint32_t ticketCount(test::jtx::Env const &env, test::jtx::Account const &acct)
static bool getLineFreezeFlag(test::jtx::Env const &env, test::jtx::Account const &src, test::jtx::Account const &dst, Currency const &cur)
void testTickets(FeatureBitset features)
void testWithFeats(FeatureBitset features)
static std::string to_string(T const &t)
void testMultiLine(FeatureBitset features)
void testFrozenLine(FeatureBitset features)
void testEnabled(FeatureBitset features)
void testAllowTrustLineClawbackFlag(FeatureBitset features)
void testValidation(FeatureBitset features)
Immutable cryptographic account descriptor.
AccountID id() const
Returns the Account ID.
A transaction testing environment.
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
void require(Args const &... args)
Check a set of requirements.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
void enableFeature(uint256 const feature)
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Match clear account flags.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Set a ticket sequence on a JTx.
Keylet line(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
Json::Value create(Account const &account, std::uint32_t count)
Create one of more tickets.
std::uint32_t ownerCount(Env const &env, Account const &account)
Json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
Json::Value claw(Account const &account, STAmount const &amount, std::optional< Account > const &mptHolder)
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
XRP_t const XRP
Converts to XRP Issue or STAmount.
FeatureBitset supported_amendments()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr std::uint32_t asfNoFreeze
constexpr std::uint32_t asfAllowTrustLineClawback
constexpr std::uint32_t tfSetFreeze