xrpld
Loading...
Searching...
No Matches
ReducedOffer_test.cpp
1
2#include <test/jtx/Account.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/amount.h>
5#include <test/jtx/balance.h> // IWYU pragma: keep
6#include <test/jtx/fee.h>
7#include <test/jtx/offer.h>
8#include <test/jtx/owners.h>
9#include <test/jtx/pay.h>
10#include <test/jtx/trust.h>
11#include <test/jtx/txflags.h>
12
13#include <xrpl/beast/unit_test/suite.h>
14#include <xrpl/json/json_value.h>
15#include <xrpl/json/to_string.h>
16#include <xrpl/protocol/ErrorCodes.h>
17#include <xrpl/protocol/Feature.h>
18#include <xrpl/protocol/Quality.h>
19#include <xrpl/protocol/SField.h>
20#include <xrpl/protocol/STAmount.h>
21#include <xrpl/protocol/TxFlags.h>
22#include <xrpl/protocol/jss.h>
23
24#include <cstdint>
25#include <initializer_list>
26#include <utility>
27
28namespace xrpl::test {
29
31{
32 static auto
34 {
35 json::Value jvParams;
36 jvParams[jss::offer][jss::account] = acct.human();
37 jvParams[jss::offer][jss::seq] = offerSeq;
38 return env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result];
39 }
40
41 static bool
42 offerInLedger(jtx::Env& env, jtx::Account const& acct, std::uint32_t offerSeq)
43 {
44 json::Value ledgerOffer = ledgerEntryOffer(env, acct, offerSeq);
45 return !(
46 ledgerOffer[jss::error].asString() == "entryNotFound" &&
47 ledgerOffer[jss::error_code] == RpcEntryNotFound &&
48 ledgerOffer[jss::error_message] == "Entry not found.");
49 }
50
51 // Common code to clean up unneeded offers.
52 static void
54 jtx::Env& env,
56 {
57 for (auto [acct, offerSeq] : list)
58 env(offerCancel(acct, offerSeq));
59 env.close();
60 }
61
62public:
63 void
65 {
66 testcase("exercise partial cross new XRP/IOU offer Q change");
67
68 using namespace jtx;
69
70 auto const gw = Account{"gateway"};
71 auto const alice = Account{"alice"};
72 auto const bob = Account{"bob"};
73 auto const usd = gw["USD"];
74
75 {
76 Env env{*this, testableAmendments()};
77
78 // Make sure none of the offers we generate are under funded.
79 env.fund(XRP(10'000'000), gw, alice, bob);
80 env.close();
81
82 env(trust(alice, usd(10'000'000)));
83 env(trust(bob, usd(10'000'000)));
84 env.close();
85
86 env(pay(gw, bob, usd(10'000'000)));
87 env.close();
88
89 // Lambda that:
90 // 1. Exercises one offer pair,
91 // 2. Collects the results, and
92 // 3. Cleans up for the next offer pair.
93 // Returns 1 if the crossed offer has a bad rate for the book.
94 auto const exerciseOfferPair = [this, &env, &alice, &bob](
95 Amounts const& inLedger,
96 Amounts const& newOffer) -> unsigned int {
97 // Put inLedger offer in the ledger so newOffer can cross it.
98 std::uint32_t const aliceOfferSeq = env.seq(alice);
99 env(offer(alice, inLedger.in, inLedger.out));
100 env.close();
101
102 // Now alice's offer will partially cross bob's offer.
103 STAmount const initialRate = Quality(newOffer).rate();
104 std::uint32_t const bobOfferSeq = env.seq(bob);
105 STAmount const bobInitialBalance = env.balance(bob);
106 STAmount const bobFee = env.current()->fees().base;
107 env(offer(bob, newOffer.in, newOffer.out, tfSell), Fee(bobFee));
108 env.close();
109 STAmount const bobFinalBalance = env.balance(bob);
110
111 // alice's offer should be fully crossed and so gone from
112 // the ledger.
113 if (!BEAST_EXPECT(!offerInLedger(env, alice, aliceOfferSeq)))
114 {
115 // If the in-ledger offer was not consumed then further
116 // results are meaningless.
117 return 1;
118 }
119
120 // bob's offer should be in the ledger, but reduced in size.
121 unsigned int badRate = 1;
122 {
123 json::Value bobOffer = ledgerEntryOffer(env, bob, bobOfferSeq);
124
125 STAmount const reducedTakerGets =
126 amountFromJson(sfTakerGets, bobOffer[jss::node][sfTakerGets.jsonName]);
127 STAmount const reducedTakerPays =
128 amountFromJson(sfTakerPays, bobOffer[jss::node][sfTakerPays.jsonName]);
129 STAmount const bobGot = env.balance(bob) + bobFee - bobInitialBalance;
130 BEAST_EXPECT(reducedTakerPays < newOffer.in);
131 BEAST_EXPECT(reducedTakerGets < newOffer.out);
132 STAmount const inLedgerRate =
133 Quality(Amounts{reducedTakerPays, reducedTakerGets}).rate();
134
135 badRate = inLedgerRate > initialRate ? 1 : 0;
136
137 // If the inLedgerRate is less than initial rate, then
138 // incrementing the mantissa of the reduced taker pays
139 // should result in a rate higher than initial. Check
140 // this to verify that the largest allowable TakerPays
141 // was computed.
142 if (badRate == 0)
143 {
144 STAmount const tweakedTakerPays = reducedTakerPays + drops(1);
145 STAmount const tweakedRate =
146 Quality(Amounts{tweakedTakerPays, reducedTakerGets}).rate();
147 BEAST_EXPECT(tweakedRate > initialRate);
148 }
149 }
150
151 // In preparation for the next iteration make sure the two
152 // offers are gone from the ledger.
153 cleanupOldOffers(env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}});
154 return badRate;
155 };
156
157 // bob's offer (the new offer) is the same every time:
158 Amounts const bobOffer{STAmount(XRP(1)), STAmount(usd, 1, 0)};
159
160 // alice's offer has a slightly smaller TakerPays with each
161 // iteration. This should mean that the size of the offer bob
162 // places in the ledger should increase with each iteration.
163 unsigned int blockedCount = 0;
164 for (std::uint64_t mantissaReduce = 1'000'000'000ull;
165 mantissaReduce <= 5'000'000'000ull;
166 mantissaReduce += 20'000'000ull)
167 {
168 STAmount const aliceUSD{
169 bobOffer.out.asset(),
170 bobOffer.out.mantissa() - mantissaReduce,
171 bobOffer.out.exponent()};
172 STAmount const aliceXRP{bobOffer.in.asset(), bobOffer.in.mantissa() - 1};
173 Amounts const aliceOffer{aliceUSD, aliceXRP};
174 blockedCount += exerciseOfferPair(aliceOffer, bobOffer);
175 }
176
177 // None of the test cases should produce a potentially blocking
178 // rate.
179 BEAST_EXPECT(blockedCount == 0);
180 }
181 }
182
183 void
185 {
186 testcase("exercise partial cross old XRP/IOU offer Q change");
187
188 using namespace jtx;
189
190 auto const gw = Account{"gateway"};
191 auto const alice = Account{"alice"};
192 auto const bob = Account{"bob"};
193 auto const usd = gw["USD"];
194
195 {
196 // Make sure none of the offers we generate are under funded.
197 Env env{*this, testableAmendments()};
198 env.fund(XRP(10'000'000), gw, alice, bob);
199 env.close();
200
201 env(trust(alice, usd(10'000'000)));
202 env(trust(bob, usd(10'000'000)));
203 env.close();
204
205 env(pay(gw, alice, usd(10'000'000)));
206 env.close();
207
208 // Lambda that:
209 // 1. Exercises one offer pair,
210 // 2. Collects the results, and
211 // 3. Cleans up for the next offer pair.
212 auto const exerciseOfferPair = [this, &env, &alice, &bob](
213 Amounts const& inLedger,
214 Amounts const& newOffer) -> unsigned int {
215 // Get the inLedger offer into the ledger so newOffer can cross
216 // it.
217 STAmount const initialRate = Quality(inLedger).rate();
218 std::uint32_t const aliceOfferSeq = env.seq(alice);
219 env(offer(alice, inLedger.in, inLedger.out));
220 env.close();
221
222 // Now bob's offer will partially cross alice's offer.
223 std::uint32_t const bobOfferSeq = env.seq(bob);
224 STAmount const aliceInitialBalance = env.balance(alice);
225 env(offer(bob, newOffer.in, newOffer.out));
226 env.close();
227 STAmount const aliceFinalBalance = env.balance(alice);
228
229 // bob's offer should not have made it into the ledger.
230 if (!BEAST_EXPECT(!offerInLedger(env, bob, bobOfferSeq)))
231 {
232 // If the in-ledger offer was not consumed then further
233 // results are meaningless.
234 cleanupOldOffers(env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}});
235 return 1;
236 }
237 // alice's offer should still be in the ledger, but reduced in
238 // size.
239 unsigned int badRate = 1;
240 {
241 json::Value aliceOffer = ledgerEntryOffer(env, alice, aliceOfferSeq);
242
243 STAmount const reducedTakerGets =
244 amountFromJson(sfTakerGets, aliceOffer[jss::node][sfTakerGets.jsonName]);
245 STAmount const reducedTakerPays =
246 amountFromJson(sfTakerPays, aliceOffer[jss::node][sfTakerPays.jsonName]);
247 STAmount const aliceGot = env.balance(alice) - aliceInitialBalance;
248 BEAST_EXPECT(reducedTakerPays < inLedger.in);
249 BEAST_EXPECT(reducedTakerGets < inLedger.out);
250 STAmount const inLedgerRate =
251 Quality(Amounts{reducedTakerPays, reducedTakerGets}).rate();
252 badRate = inLedgerRate > initialRate ? 1 : 0;
253
254 // If the inLedgerRate is less than initial rate, then
255 // incrementing the mantissa of the reduced taker pays
256 // should result in a rate higher than initial. Check
257 // this to verify that the largest allowable TakerPays
258 // was computed.
259 if (badRate == 0)
260 {
261 STAmount const tweakedTakerPays = reducedTakerPays + drops(1);
262 STAmount const tweakedRate =
263 Quality(Amounts{tweakedTakerPays, reducedTakerGets}).rate();
264 BEAST_EXPECT(tweakedRate > initialRate);
265 }
266 }
267
268 // In preparation for the next iteration make sure the two
269 // offers are gone from the ledger.
270 cleanupOldOffers(env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}});
271 return badRate;
272 };
273
274 // alice's offer (the old offer) is the same every time:
275 Amounts const aliceOffer{STAmount(XRP(1)), STAmount(usd, 1, 0)};
276
277 // bob's offer has a slightly smaller TakerPays with each iteration.
278 // This should mean that the size of the offer alice leaves in the
279 // ledger should increase with each iteration.
280 unsigned int blockedCount = 0;
281 for (std::uint64_t mantissaReduce = 1'000'000'000ull;
282 mantissaReduce <= 4'000'000'000ull;
283 mantissaReduce += 20'000'000ull)
284 {
285 STAmount const bobUSD{
286 aliceOffer.out.asset(),
287 aliceOffer.out.mantissa() - mantissaReduce,
288 aliceOffer.out.exponent()};
289 STAmount const bobXRP{aliceOffer.in.asset(), aliceOffer.in.mantissa() - 1};
290 Amounts const bobOffer{bobUSD, bobXRP};
291
292 blockedCount += exerciseOfferPair(aliceOffer, bobOffer);
293 }
294
295 // None of the test cases should produce a potentially blocking
296 // rate.
297 BEAST_EXPECT(blockedCount == 0);
298 }
299 }
300
301 void
303 {
304 testcase("exercise underfunded XRP/IOU offer Q change");
305
306 // Bob places an offer that is not fully funded.
307
308 using namespace jtx;
309 auto const alice = Account{"alice"};
310 auto const bob = Account{"bob"};
311 auto const gw = Account{"gw"};
312 auto const usd = gw["USD"];
313
314 {
315 Env env{*this, testableAmendments()};
316
317 env.fund(XRP(10000), alice, bob, gw);
318 env.close();
319 env.trust(usd(1000), alice, bob);
320
321 int blockedOrderBookCount = 0;
322 for (STAmount initialBobUSD = usd(0.45); initialBobUSD <= usd(1);
323 initialBobUSD += usd(0.025))
324 {
325 // underfund bob's offer
326 env(pay(gw, bob, initialBobUSD));
327 env.close();
328
329 std::uint32_t const bobOfferSeq = env.seq(bob);
330 env(offer(bob, drops(2), usd(1)));
331 env.close();
332
333 // alice places an offer that would cross bob's if bob's were
334 // well funded.
335 std::uint32_t const aliceOfferSeq = env.seq(alice);
336 env(offer(alice, usd(1), drops(2)));
337 env.close();
338
339 // We want to detect order book blocking. If:
340 // 1. bob's offer is still in the ledger and
341 // 2. alice received no USD
342 // then we use that as evidence that bob's offer blocked the
343 // order book.
344 {
345 bool const bobOfferGone = !offerInLedger(env, bob, bobOfferSeq);
346 STAmount const aliceBalanceUSD = env.balance(alice, usd);
347
348 // Sanity check the ledger if alice got USD.
349 if (aliceBalanceUSD.signum() > 0)
350 {
351 BEAST_EXPECT(aliceBalanceUSD == initialBobUSD);
352 BEAST_EXPECT(env.balance(bob, usd) == usd(0));
353 BEAST_EXPECT(bobOfferGone);
354 }
355
356 // Track occurrences of order book blocking.
357 if (!bobOfferGone && aliceBalanceUSD.signum() == 0)
358 {
359 ++blockedOrderBookCount;
360 }
361
362 // In preparation for the next iteration clean up any
363 // leftover offers.
364 cleanupOldOffers(env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}});
365
366 // Zero out alice's and bob's USD balances.
367 if (STAmount const aliceBalance = env.balance(alice, usd);
368 aliceBalance.signum() > 0)
369 env(pay(alice, gw, aliceBalance));
370
371 if (STAmount const bobBalance = env.balance(bob, usd); bobBalance.signum() > 0)
372 env(pay(bob, gw, bobBalance));
373
374 env.close();
375 }
376 }
377
378 // None of the test cases should produce a potentially blocking
379 // rate.
380 BEAST_EXPECT(blockedOrderBookCount == 0);
381 }
382 }
383
384 void
386 {
387 testcase("exercise underfunded IOU/IOU offer Q change");
388
389 // Bob places an IOU/IOU offer that is not fully funded.
390
391 using namespace jtx;
392 using namespace std::chrono_literals;
393 auto const alice = Account{"alice"};
394 auto const bob = Account{"bob"};
395 auto const gw = Account{"gw"};
396
397 auto const usd = gw["USD"];
398 auto const eur = gw["EUR"];
399
400 STAmount const tinyUSD(usd, /*mantissa*/ 1, /*exponent*/ -81);
401
402 {
403 Env env{*this, testableAmendments()};
404
405 env.fund(XRP(10000), alice, bob, gw);
406 env.close();
407 env.trust(usd(1000), alice, bob);
408 env.trust(eur(1000), alice, bob);
409
410 STAmount const eurOffer(eur, /*mantissa*/ 2957, /*exponent*/ -76);
411 STAmount const usdOffer(usd, /*mantissa*/ 7109, /*exponent*/ -76);
412
413 STAmount const endLoop(usd, /*mantissa*/ 50, /*exponent*/ -81);
414
415 int blockedOrderBookCount = 0;
416 for (STAmount initialBobUSD = tinyUSD; initialBobUSD <= endLoop;
417 initialBobUSD += tinyUSD)
418 {
419 // underfund bob's offer
420 env(pay(gw, bob, initialBobUSD));
421 env(pay(gw, alice, eur(100)));
422 env.close();
423
424 // This offer is underfunded
425 std::uint32_t bobOfferSeq = env.seq(bob);
426 env(offer(bob, eurOffer, usdOffer));
427 env.close();
428 env.require(Offers(bob, 1));
429
430 // alice places an offer that crosses bob's.
431 std::uint32_t aliceOfferSeq = env.seq(alice);
432 env(offer(alice, usdOffer, eurOffer));
433 env.close();
434
435 // Examine the aftermath of alice's offer.
436 {
437 bool const bobOfferGone = !offerInLedger(env, bob, bobOfferSeq);
438 STAmount const aliceBalanceUSD = env.balance(alice, usd);
439 // Sanity check the ledger if alice got USD.
440 if (aliceBalanceUSD.signum() > 0)
441 {
442 BEAST_EXPECT(aliceBalanceUSD == initialBobUSD);
443 BEAST_EXPECT(env.balance(bob, usd) == usd(0));
444 BEAST_EXPECT(bobOfferGone);
445 }
446
447 // Track occurrences of order book blocking.
448 if (!bobOfferGone && aliceBalanceUSD.signum() == 0)
449 {
450 ++blockedOrderBookCount;
451 }
452 }
453
454 // In preparation for the next iteration clean up any
455 // leftover offers.
456 cleanupOldOffers(env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}});
457
458 // Zero out alice's and bob's IOU balances.
459 auto const zeroBalance = [&env, &gw](Account const& acct, IOU const& iou) {
460 if (STAmount const balance = env.balance(acct, iou); balance.signum() > 0)
461 env(pay(acct, gw, balance));
462 };
463
464 zeroBalance(alice, eur);
465 zeroBalance(alice, usd);
466 zeroBalance(bob, eur);
467 zeroBalance(bob, usd);
468 env.close();
469 }
470
471 // None of the test cases should produce a potentially blocking
472 // rate.
473 BEAST_EXPECT(blockedOrderBookCount == 0);
474 }
475 }
476
477 static Amounts
479 {
480 STAmount const in = amountFromJson(sfTakerPays, json[sfTakerPays.jsonName]);
481 STAmount const out = amountFromJson(sfTakerGets, json[sfTakerGets.jsonName]);
482 return {in, out};
483 }
484
485 void
487 {
488 // This test case was motivated by Issue #4937. It recreates
489 // the specific failure identified in that issue and samples some other
490 // cases in the same vicinity to make sure that the new behavior makes
491 // sense.
492 testcase("exercise tfSell partial cross old XRP/IOU offer Q change");
493
494 using namespace jtx;
495
496 Account const gw("gateway");
497 Account const alice("alice");
498 Account const bob("bob");
499 Account const carol("carol");
500 auto const usd = gw["USD"];
501
502 // Make one test run without fixReducedOffersV2 and one with.
503 for (FeatureBitset features :
504 {testableAmendments() - fixReducedOffersV2, testableAmendments() | fixReducedOffersV2})
505 {
506 // Make sure none of the offers we generate are under funded.
507 Env env{*this, features};
508 env.fund(XRP(10'000'000), gw, alice, bob, carol);
509 env.close();
510
511 env(trust(alice, usd(10'000'000)));
512 env(trust(bob, usd(10'000'000)));
513 env(trust(carol, usd(10'000'000)));
514 env.close();
515
516 env(pay(gw, alice, usd(10'000'000)));
517 env(pay(gw, bob, usd(10'000'000)));
518 env(pay(gw, carol, usd(10'000'000)));
519 env.close();
520
521 // Lambda that:
522 // 1. Exercises one offer trio,
523 // 2. Collects the results, and
524 // 3. Cleans up for the next offer trio.
525 auto const exerciseOfferTrio = [this, &env, &alice, &bob, &carol, &usd](
526 Amounts const& carolOffer) -> unsigned int {
527 // alice submits an offer that may become a blocker.
528 std::uint32_t const aliceOfferSeq = env.seq(alice);
529 static Amounts const kAliceInitialOffer(usd(2), drops(3382562));
530 env(offer(alice, kAliceInitialOffer.in, kAliceInitialOffer.out));
531 env.close();
533 env, alice, aliceOfferSeq)[jss::node]))
534 .rate();
535
536 // bob submits an offer that is more desirable than alice's
537 std::uint32_t const bobOfferSeq = env.seq(bob);
538 env(offer(bob, usd(0.97086565812384), drops(1642020)));
539 env.close();
540
541 // Now carol's offer consumes bob's and partially crosses
542 // alice's. The tfSell flag is important.
543 std::uint32_t const carolOfferSeq = env.seq(carol);
544 env(offer(carol, carolOffer.in, carolOffer.out), Txflags(tfSell));
545 env.close();
546
547 // carol's offer should not have made it into the ledger and
548 // bob's offer should be fully consumed.
549 if (!BEAST_EXPECT(
550 !offerInLedger(env, carol, carolOfferSeq) &&
551 !offerInLedger(env, bob, bobOfferSeq)))
552 {
553 // If carol's or bob's offers are still in the ledger then
554 // further results are meaningless.
556 env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}, {carol, carolOfferSeq}});
557 return 1;
558 }
559 // alice's offer should still be in the ledger, but reduced in
560 // size.
561 unsigned int badRate = 1;
562 {
563 json::Value aliceOffer = ledgerEntryOffer(env, alice, aliceOfferSeq);
564
565 Amounts const aliceReducedOffer = jsonOfferToAmounts(aliceOffer[jss::node]);
566
567 BEAST_EXPECT(aliceReducedOffer.in < kAliceInitialOffer.in);
568 BEAST_EXPECT(aliceReducedOffer.out < kAliceInitialOffer.out);
569 STAmount const inLedgerRate = Quality(aliceReducedOffer).rate();
570 badRate = inLedgerRate > initialRate ? 1 : 0;
571
572 // If the inLedgerRate is less than initial rate, then
573 // incrementing the mantissa of the reduced TakerGets
574 // should result in a rate higher than initial. Check
575 // this to verify that the largest allowable TakerGets
576 // was computed.
577 if (badRate == 0)
578 {
579 STAmount const tweakedTakerGets(
580 aliceReducedOffer.in.asset(),
581 aliceReducedOffer.in.mantissa() + 1,
582 aliceReducedOffer.in.exponent(),
583 aliceReducedOffer.in.negative());
584 STAmount const tweakedRate =
585 Quality(Amounts{aliceReducedOffer.in, tweakedTakerGets}).rate();
586 BEAST_EXPECT(tweakedRate > initialRate);
587 }
588 }
589
590 // In preparation for the next iteration make sure all three
591 // offers are gone from the ledger.
593 env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}, {carol, carolOfferSeq}});
594 return badRate;
595 };
596
597 static constexpr int kLoopCount = 100;
598 unsigned int blockedCount = 0;
599 {
600 STAmount increaseGets = usd(0);
601 STAmount const step(increaseGets.asset(), 1, -8);
602 for (unsigned int i = 0; i < kLoopCount; ++i)
603 {
604 blockedCount +=
605 exerciseOfferTrio(Amounts(drops(1642020), usd(1) + increaseGets));
606 increaseGets += step;
607 }
608 }
609
610 // If fixReducedOffersV2 is enabled, then none of the test cases
611 // should produce a potentially blocking rate.
612 //
613 // Also verify that if fixReducedOffersV2 is not enabled then
614 // some of the test cases produced a potentially blocking rate.
615 if (features[fixReducedOffersV2])
616 {
617 BEAST_EXPECT(blockedCount == 0);
618 }
619 else
620 {
621 BEAST_EXPECT(blockedCount > 80);
622 }
623 }
624 }
625
626 void
635};
636
637BEAST_DEFINE_TESTSUITE_PRIO(ReducedOffer, app, xrpl, 2);
638
639} // namespace xrpl::test
A testsuite class.
Definition suite.h:52
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
Represents a JSON value.
Definition json_value.h:121
std::string asString() const
Returns the unquoted string value.
Represents the logical ratio of output currency to input currency.
Definition Quality.h:90
STAmount rate() const
Returns the quality as STAmount.
Definition Quality.h:162
std::uint64_t mantissa() const noexcept
Definition STAmount.h:490
int signum() const noexcept
Definition STAmount.h:522
bool negative() const noexcept
Definition STAmount.h:484
Asset const & asset() const
Definition STAmount.h:496
int exponent() const noexcept
Definition STAmount.h:459
static auto ledgerEntryOffer(jtx::Env &env, jtx::Account const &acct, std::uint32_t offerSeq)
void run() override
Runs the suite.
static bool offerInLedger(jtx::Env &env, jtx::Account const &acct, std::uint32_t offerSeq)
static Amounts jsonOfferToAmounts(json::Value const &json)
static void cleanupOldOffers(jtx::Env &env, std::initializer_list< std::pair< jtx::Account const &, std::uint32_t > > list)
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
std::string const & human() const
Returns the human readable public key.
A transaction testing environment.
Definition Env.h:161
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:133
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:323
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:302
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Definition Env.h:1058
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition Env.cpp:201
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:354
void require(Args const &... args)
Check a set of requirements.
Definition Env.h:766
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:377
Set the fee on a JTx.
Definition fee.h:20
Converts to IOU Issue or STAmount.
Set the flags on a JTx.
Definition txflags.h:14
JSON (JavaScript Object Notation).
Definition json_errors.h:5
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:14
json::Value offerCancel(Account const &account, std::uint32_t offerSeq)
Cancel an offer.
Definition offer.cpp:31
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
FeatureBitset testableAmendments()
Definition Env.h:92
OwnerCount< ltOFFER > Offers
Match the number of offers in the account's owner directory.
Definition owners.h:137
json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
Definition offer.cpp:14
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:18
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
json::Value rate(Account const &account, double multiplier)
Set a transfer rate.
Definition rate.cpp:15
BEAST_DEFINE_TESTSUITE_PRIO(AccountDelete, app, xrpl, 2)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ RpcEntryNotFound
Definition ErrorCodes.h:144
TAmounts< STAmount, STAmount > Amounts
Definition Quality.h:69
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:658
STAmount amountFromJson(SField const &name, json::Value const &v)