20 #include <ripple/ledger/ApplyViewImpl.h>
21 #include <ripple/ledger/PaymentSandbox.h>
22 #include <ripple/ledger/View.h>
23 #include <ripple/protocol/AmountConversions.h>
24 #include <ripple/protocol/Feature.h>
25 #include <test/jtx/PathSet.h>
60 testcase(
"selfFunding");
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))),
98 testcase(
"subtractCredits");
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);
299 testcase(
"Tiny balance");
307 Env env(*
this, features);
311 auto const USD = gw[
"USD"];
313 auto const issue = USD.issue();
332 BEAST_EXPECT(pv.
balanceHook(alice, gw, hugeAmt) == tinyAmt);
341 auto accountFundsXRP = [](
ReadView const& view,
349 return env.
current()->fees().accountReserve(count);
352 Env env(*
this, features);
376 accountFundsXRP(sb, alice, env.
journal) == beast::zero);
385 testcase(
"balanceHook");
388 Env env(*
this, features);
391 auto const USD = gw[
"USD"];
400 tlIssue.
currency = USD.issue().currency;
408 BEAST_EXPECT(
balance.getIssuer() == USD.issue().account);