20#include <test/jtx/PathSet.h>
21#include <xrpld/ledger/ApplyViewImpl.h>
22#include <xrpld/ledger/PaymentSandbox.h>
23#include <xrpld/ledger/View.h>
24#include <xrpl/protocol/AmountConversions.h>
25#include <xrpl/protocol/Feature.h>
63 Env env(*
this, features);
69 env.
fund(
XRP(10000), snd, rcv, gw1, gw2);
71 auto const USD_gw1 = gw1[
"USD"];
72 auto const USD_gw2 = gw2[
"USD"];
74 env.
trust(USD_gw1(10), snd);
75 env.
trust(USD_gw2(10), snd);
76 env.
trust(USD_gw1(100), rcv);
77 env.
trust(USD_gw2(100), rcv);
79 env(
pay(gw1, snd, USD_gw1(2)));
80 env(
pay(gw2, snd, USD_gw2(4)));
87 env(
pay(snd, rcv,
any(USD_gw1(4))),
101 Env env(*
this, features);
106 env.
fund(
XRP(10000), alice, gw1, gw2);
110 auto const USD_gw1 = gw1[
"USD"];
111 auto const USD_gw2 = gw2[
"USD"];
113 env.
trust(USD_gw1(100), alice);
114 env.
trust(USD_gw2(100), alice);
116 env(
pay(gw1, alice, USD_gw1(50)));
117 env(
pay(gw2, alice, USD_gw2(50)));
119 STAmount const toCredit(USD_gw1(30));
120 STAmount const toDebit(USD_gw1(20));
125 auto const iss = USD_gw1.issue();
135 startingAmount + toCredit);
143 startingAmount + toCredit - toDebit);
150 auto const iss = USD_gw1.issue();
158 startingAmount + toCredit);
164 startingAmount + toCredit - toDebit);
172 auto const iss = USD_gw1.issue();
192 startingAmount - toDebit);
200 auto const iss = USD_gw1.issue();
216 auto const iss = USD_gw1.issue();
224 startingAmount - toDebit);
232 auto const iss = USD_gw1.issue();
248 auto const iss = USD_gw1.issue();
270 j) == startingAmount);
272 auto r =
accountSend(pv2, gw1, alice, toCredit, j);
282 j) == startingAmount);
292 startingAmount - toDebit);
307 Env env(*
this, features);
311 auto const USD = gw[
"USD"];
313 auto const issue = USD.issue();
330 BEAST_EXPECT(pv.
balanceHook(alice, gw, hugeAmt) == tinyAmt);
339 auto accountFundsXRP = [](
ReadView const& view,
347 return env.
current()->fees().accountReserve(count);
350 Env env(*
this, features);
374 accountFundsXRP(sb, alice, env.
journal) == beast::zero);
386 Env env(*
this, features);
389 auto const USD = gw[
"USD"];
398 tlIssue.
currency = USD.issue().currency;
406 BEAST_EXPECT(
balance.getIssuer() == USD.issue().account);
422 testAll(sa - featureFlowCross);
A generic endpoint for log messages.
testcase_t testcase
Memberspace for declaring test cases.
virtual beast::Journal journal(std::string const &name)=0
Editable, discardable view that can build metadata for one tx.
A currency issued by an account.
A wrapper which makes credits unavailable to balances.
void creditHook(AccountID const &from, AccountID const &to, STAmount const &amount, STAmount const &preCreditBalance) override
STAmount balanceHook(AccountID const &account, AccountID const &issuer, STAmount const &amount) const override
static const int cMaxOffset
static const std::uint64_t cMinValue
static const int cMinOffset
static const std::uint64_t cMaxValue
void testTinyBalance(FeatureBitset features)
void testSelfFunding(FeatureBitset features)
void testSubtractCredits(FeatureBitset features)
void testBalanceHook(FeatureBitset features)
void testReserve(FeatureBitset features)
void run() override
Runs the suite.
Immutable cryptographic account descriptor.
AccountID id() const
Returns the Account ID.
A transaction testing environment.
void require(Args const &... args)
Check a set of requirements.
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 trust(STAmount const &amount, Account const &account)
Establish trust lines.
beast::Journal const journal
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Set Paths, SendMax on a JTx.
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
any_t const any
Returns an amount representing "any issuer".
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
XRP_t const XRP
Converts to XRP Issue or STAmount.
FeatureBitset supported_amendments()
static XRPAmount reserve(jtx::Env &env, std::uint32_t count)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
AccountID const & xrpAccount()
Compute AccountID from public key.
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
constexpr std::uint32_t tfPassive
constexpr std::uint32_t tfPartialPayment
Currency const & xrpCurrency()
XRP currency.
TER issueIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Issue const & noIssue()
Returns an asset specifier that represents no account and currency.
constexpr std::uint32_t tfNoRippleDirect
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
TER rippleCredit(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, beast::Journal j)
Calls static rippleCreditIOU if saAmount represents Issue.
XRPAmount toAmount< XRPAmount >(STAmount const &amt)
TER accountSend(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee)
Calls static accountSendIOU if saAmount represents Issue.