xrpld
Loading...
Searching...
No Matches
View_test.cpp
1
2
3#include <test/jtx/Account.h>
4#include <test/jtx/Env.h>
5#include <test/jtx/amount.h>
6#include <test/jtx/balance.h> // IWYU pragma: keep
7#include <test/jtx/envconfig.h>
8#include <test/jtx/fee.h>
9#include <test/jtx/flags.h>
10#include <test/jtx/noop.h>
11#include <test/jtx/offer.h>
12#include <test/jtx/pay.h>
13#include <test/jtx/rate.h>
14#include <test/jtx/ter.h>
15#include <test/jtx/trust.h>
16
17#include <xrpld/app/ledger/OpenLedger.h>
18#include <xrpld/core/Config.h>
19
20#include <xrpl/basics/base_uint.h>
21#include <xrpl/basics/chrono.h>
22#include <xrpl/beast/unit_test/suite.h>
23#include <xrpl/beast/utility/Journal.h>
24#include <xrpl/core/ServiceRegistry.h>
25#include <xrpl/ledger/ApplyView.h>
26#include <xrpl/ledger/ApplyViewImpl.h>
27#include <xrpl/ledger/Ledger.h>
28#include <xrpl/ledger/OpenView.h>
29#include <xrpl/ledger/PaymentSandbox.h>
30#include <xrpl/ledger/ReadView.h>
31#include <xrpl/ledger/Sandbox.h>
32#include <xrpl/ledger/View.h>
33#include <xrpl/ledger/helpers/AccountRootHelpers.h>
34#include <xrpl/ledger/helpers/TokenHelpers.h>
35#include <xrpl/protocol/AccountID.h>
36#include <xrpl/protocol/Indexes.h>
37#include <xrpl/protocol/Keylet.h>
38#include <xrpl/protocol/LedgerFormats.h>
39#include <xrpl/protocol/Rate.h>
40#include <xrpl/protocol/SField.h>
41#include <xrpl/protocol/TER.h>
42#include <xrpl/protocol/TxFlags.h>
43#include <xrpl/protocol/UintTypes.h>
44
45#include <chrono>
46#include <cstdint>
47#include <memory>
48#include <optional>
49#include <type_traits>
50#include <vector>
51
52namespace xrpl::test {
53
55{
56 // Convert a small integer to a key
57 static Keylet
59 {
60 return Keylet{ltACCOUNT_ROOT, UInt256(id)};
61 }
62
63 // Create SLE with key and payload
64 static SLE::pointer
66 {
67 auto const le = std::make_shared<SLE>(k(id));
68 le->setFieldU32(sfSequence, seq);
69 return le;
70 }
71
72 // Return payload for SLE
73 template <class T>
74 static std::uint32_t
76 {
77 return le->getFieldU32(sfSequence);
78 }
79
80 // Set payload on SLE
81 static void
83 {
84 le->setFieldU32(sfSequence, seq);
85 }
86
87 // Erase all state items
88 static void
89 wipe(OpenLedger& openLedger)
90 {
91 openLedger.modify([](OpenView& view, beast::Journal) {
92 // HACK!
94 next.emplace(0);
95 for (;;)
96 {
97 next = view.succ(*next);
98 if (!next)
99 break;
101 }
102 return true;
103 });
104 }
105
106 static void
107 wipe(Ledger& ledger)
108 {
109 // HACK!
111 next.emplace(0);
112 for (;;)
113 {
114 next = ledger.succ(*next);
115 if (!next)
116 break;
117 ledger.rawErase(std::make_shared<SLE>(*ledger.read(keylet::unchecked(*next))));
118 }
119 }
120
121 // Test succ correctness
122 void
124 {
125 auto const next = v.succ(k(id).key);
126 if (answer)
127 {
128 if (BEAST_EXPECT(next); next.has_value())
129 BEAST_EXPECT(*next == k(*answer).key);
130 }
131 else
132 {
133 BEAST_EXPECT(!next);
134 }
135 }
136
137 template <class T>
140 {
142 }
143
144 // Exercise Ledger implementation of ApplyView
145 void
147 {
148 testcase("Ledger");
149
150 using namespace jtx;
151 Env env(*this);
152 Config const config;
155 Rules{config.features},
156 config.fees.toFees(),
158 env.app().getNodeFamily());
159 auto const ledger =
161 wipe(*ledger);
162 ReadView const& v = *ledger;
163 succ(v, 0, std::nullopt);
164 ledger->rawInsert(sle(1, 1));
165 BEAST_EXPECT(v.exists(k(1)));
166 BEAST_EXPECT(seq(v.read(k(1))) == 1);
167 succ(v, 0, 1);
168 succ(v, 1, std::nullopt);
169 ledger->rawInsert(sle(2, 2));
170 BEAST_EXPECT(seq(v.read(k(2))) == 2);
171 ledger->rawInsert(sle(3, 3));
172 BEAST_EXPECT(seq(v.read(k(3))) == 3);
173 auto const s = copy(v.read(k(2)));
174 seq(s, 4);
175 ledger->rawReplace(s);
176 BEAST_EXPECT(seq(v.read(k(2))) == 4);
177 ledger->rawErase(sle(2));
178 BEAST_EXPECT(!v.exists(k(2)));
179 BEAST_EXPECT(v.exists(k(1)));
180 BEAST_EXPECT(v.exists(k(3)));
181 }
182
183 void
185 {
186 testcase("Meta");
187
188 using namespace jtx;
189 Env env(*this);
190 wipe(env.app().getOpenLedger());
191 auto const open = env.current();
193 succ(v, 0, std::nullopt);
194 v.insert(sle(1));
195 BEAST_EXPECT(v.exists(k(1)));
196 BEAST_EXPECT(seq(v.read(k(1))) == 1);
197 BEAST_EXPECT(seq(v.peek(k(1))) == 1);
198 succ(v, 0, 1);
199 succ(v, 1, std::nullopt);
200 v.insert(sle(2, 2));
201 BEAST_EXPECT(seq(v.read(k(2))) == 2);
202 v.insert(sle(3, 3));
203 auto s = v.peek(k(3));
204 BEAST_EXPECT(seq(s) == 3);
205 s = v.peek(k(2));
206 seq(s, 4);
207 v.update(s);
208 BEAST_EXPECT(seq(v.read(k(2))) == 4);
209 v.erase(s);
210 BEAST_EXPECT(!v.exists(k(2)));
211 BEAST_EXPECT(v.exists(k(1)));
212 BEAST_EXPECT(v.exists(k(3)));
213 }
214
215 // Exercise all succ paths
216 void
218 {
219 testcase("Meta succ");
220
221 using namespace jtx;
222 Env env(*this);
223 wipe(env.app().getOpenLedger());
224 auto const open = env.current();
226 v0.insert(sle(1));
227 v0.insert(sle(2));
228 v0.insert(sle(4));
229 v0.insert(sle(7));
230 {
231 Sandbox v1(&v0);
232 v1.insert(sle(3));
233 v1.insert(sle(5));
234 v1.insert(sle(6));
235
236 // v0: 12-4--7
237 // v1: --3-56-
238
239 succ(v0, 0, 1);
240 succ(v0, 1, 2);
241 succ(v0, 2, 4);
242 succ(v0, 3, 4);
243 succ(v0, 4, 7);
244 succ(v0, 5, 7);
245 succ(v0, 6, 7);
246 succ(v0, 7, std::nullopt);
247
248 succ(v1, 0, 1);
249 succ(v1, 1, 2);
250 succ(v1, 2, 3);
251 succ(v1, 3, 4);
252 succ(v1, 4, 5);
253 succ(v1, 5, 6);
254 succ(v1, 6, 7);
255 succ(v1, 7, std::nullopt);
256
257 v1.erase(v1.peek(k(4)));
258 succ(v1, 3, 5);
259
260 v1.erase(v1.peek(k(6)));
261 succ(v1, 5, 7);
262 succ(v1, 6, 7);
263
264 // v0: 12----7
265 // v1: --3-5--
266
267 v1.apply(v0);
268 }
269
270 // v0: 123-5-7
271
272 succ(v0, 0, 1);
273 succ(v0, 1, 2);
274 succ(v0, 2, 3);
275 succ(v0, 3, 5);
276 succ(v0, 4, 5);
277 succ(v0, 5, 7);
278 succ(v0, 6, 7);
279 succ(v0, 7, std::nullopt);
280 }
281
282 void
284 {
285 testcase("Stacked");
286
287 using namespace jtx;
288 Env env(*this);
289 wipe(env.app().getOpenLedger());
290 auto const open = env.current();
292 v0.rawInsert(sle(1, 1));
293 v0.rawInsert(sle(2, 2));
294 v0.rawInsert(sle(4, 4));
295
296 {
297 Sandbox v1(&v0);
298 v1.erase(v1.peek(k(2)));
299 v1.insert(sle(3, 3));
300 auto const s = v1.peek(k(4));
301 seq(s, 5);
302 v1.update(s);
303 BEAST_EXPECT(seq(v1.read(k(1))) == 1);
304 BEAST_EXPECT(!v1.exists(k(2)));
305 BEAST_EXPECT(seq(v1.read(k(3))) == 3);
306 BEAST_EXPECT(seq(v1.read(k(4))) == 5);
307 {
308 Sandbox v2(&v1);
309 auto const s2 = v2.peek(k(3));
310 seq(s2, 6);
311 v2.update(s2);
312 v2.erase(v2.peek(k(4)));
313 BEAST_EXPECT(seq(v2.read(k(1))) == 1);
314 BEAST_EXPECT(!v2.exists(k(2)));
315 BEAST_EXPECT(seq(v2.read(k(3))) == 6);
316 BEAST_EXPECT(!v2.exists(k(4)));
317 // discard v2
318 }
319 BEAST_EXPECT(seq(v1.read(k(1))) == 1);
320 BEAST_EXPECT(!v1.exists(k(2)));
321 BEAST_EXPECT(seq(v1.read(k(3))) == 3);
322 BEAST_EXPECT(seq(v1.read(k(4))) == 5);
323
324 {
325 Sandbox v2(&v1);
326 auto const s2 = v2.peek(k(3));
327 seq(s2, 6);
328 v2.update(s2);
329 v2.erase(v2.peek(k(4)));
330 BEAST_EXPECT(seq(v2.read(k(1))) == 1);
331 BEAST_EXPECT(!v2.exists(k(2)));
332 BEAST_EXPECT(seq(v2.read(k(3))) == 6);
333 BEAST_EXPECT(!v2.exists(k(4)));
334 v2.apply(v1);
335 }
336 BEAST_EXPECT(seq(v1.read(k(1))) == 1);
337 BEAST_EXPECT(!v1.exists(k(2)));
338 BEAST_EXPECT(seq(v1.read(k(3))) == 6);
339 BEAST_EXPECT(!v1.exists(k(4)));
340 v1.apply(v0);
341 }
342 BEAST_EXPECT(seq(v0.read(k(1))) == 1);
343 BEAST_EXPECT(!v0.exists(k(2)));
344 BEAST_EXPECT(seq(v0.read(k(3))) == 6);
345 BEAST_EXPECT(!v0.exists(k(4)));
346 }
347
348 // Verify contextual information
349 void
351 {
352 testcase("Context");
353
354 using namespace jtx;
355 using namespace std::chrono;
356 {
357 Env env(*this);
358 wipe(env.app().getOpenLedger());
359 auto const open = env.current();
360 OpenView v0(open.get());
361 BEAST_EXPECT(v0.seq() != 98);
362 BEAST_EXPECT(v0.seq() == open->seq());
363 BEAST_EXPECT(v0.parentCloseTime() != NetClock::time_point{99s});
364 BEAST_EXPECT(v0.parentCloseTime() == open->parentCloseTime());
365 {
366 // shallow copy
367 OpenView v1(v0);
368 BEAST_EXPECT(v1.seq() == v0.seq());
369 BEAST_EXPECT(v1.parentCloseTime() == v1.parentCloseTime());
370
371 ApplyViewImpl v2(&v1, TapRetry);
372 BEAST_EXPECT(v2.parentCloseTime() == v1.parentCloseTime());
373 BEAST_EXPECT(v2.seq() == v1.seq());
374 BEAST_EXPECT(v2.flags() == TapRetry);
375
376 Sandbox const v3(&v2);
377 BEAST_EXPECT(v3.seq() == v2.seq());
378 BEAST_EXPECT(v3.parentCloseTime() == v2.parentCloseTime());
379 BEAST_EXPECT(v3.flags() == TapRetry);
380 }
381 {
382 ApplyViewImpl v1(&v0, TapRetry);
383 PaymentSandbox v2(&v1);
384 BEAST_EXPECT(v2.seq() == v0.seq());
385 BEAST_EXPECT(v2.parentCloseTime() == v0.parentCloseTime());
386 BEAST_EXPECT(v2.flags() == TapRetry);
387 PaymentSandbox const v3(&v2);
388 BEAST_EXPECT(v3.seq() == v2.seq());
389 BEAST_EXPECT(v3.parentCloseTime() == v2.parentCloseTime());
390 BEAST_EXPECT(v3.flags() == v2.flags());
391 }
392 }
393 }
394
395 // Return a list of keys found via sles
397 sles(ReadView const& ledger)
398 {
400 v.reserve(32);
401 for (auto const& sle : ledger.sles)
402 v.push_back(sle->key());
403 return v;
404 }
405
406 template <class... Args>
408 list(Args... args)
409 {
410 return std::vector<UInt256>({UInt256(args)...});
411 }
412
413 void
415 {
416 testcase("Upper and lower bound");
417
418 using namespace jtx;
419 Env env(*this);
420 Config const config;
423 Rules{config.features},
424 config.fees.toFees(),
426 env.app().getNodeFamily());
427 auto const ledger =
429
430 auto const setup = [&ledger](std::vector<int> const& vec) {
431 wipe(*ledger);
432 for (auto const x : vec)
433 {
434 ledger->rawInsert(sle(x));
435 }
436 };
437 {
438 setup({1, 2, 3});
439 BEAST_EXPECT(sles(*ledger) == list(1, 2, 3));
440 auto const e = ledger->stateMap().end();
441 auto b1 = ledger->stateMap().begin();
442 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(1)) == e);
443 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(2)) == b1);
444 ++b1;
445 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(3)) == b1);
446 ++b1;
447 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(4)) == b1);
448 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(5)) == b1);
449 b1 = ledger->stateMap().begin();
450 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(0)) == b1);
451 ++b1;
452 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(1)) == b1);
453 ++b1;
454 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(2)) == b1);
455 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(3)) == e);
456 }
457
458 {
459 setup({2, 4, 6});
460 BEAST_EXPECT(sles(*ledger) == list(2, 4, 6));
461 auto const e = ledger->stateMap().end();
462 auto b1 = ledger->stateMap().begin();
463 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(1)) == e);
464 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(2)) == e);
465 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(3)) == b1);
466 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(4)) == b1);
467 ++b1;
468 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(5)) == b1);
469 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(6)) == b1);
470 ++b1;
471 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(7)) == b1);
472 b1 = ledger->stateMap().begin();
473 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(1)) == b1);
474 ++b1;
475 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(2)) == b1);
476 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(3)) == b1);
477 ++b1;
478
479 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(4)) == b1);
480 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(5)) == b1);
481 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(6)) == e);
482 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(7)) == e);
483 }
484 {
485 setup({2, 3, 5, 6, 10, 15});
486 BEAST_EXPECT(sles(*ledger) == list(2, 3, 5, 6, 10, 15));
487 auto const e = ledger->stateMap().end();
488 auto b = ledger->stateMap().begin();
489 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(1)) == e);
490 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(2)) == e);
491 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(3)) == b);
492 ++b;
493 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(4)) == b);
494 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(5)) == b);
495 ++b;
496 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(6)) == b);
497 ++b;
498 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(7)) == b);
499 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(8)) == b);
500 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(9)) == b);
501 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(10)) == b);
502 ++b;
503 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(11)) == b);
504 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(12)) == b);
505 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(13)) == b);
506 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(14)) == b);
507 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(15)) == b);
508 ++b;
509 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(16)) == b);
510 b = ledger->stateMap().begin();
511 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(0)) == b);
512 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(1)) == b);
513 ++b;
514 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(2)) == b);
515 ++b;
516 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(3)) == b);
517 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(4)) == b);
518 ++b;
519 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(5)) == b);
520 ++b;
521 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(6)) == b);
522 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(7)) == b);
523 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(8)) == b);
524 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(9)) == b);
525 ++b;
526 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(10)) == b);
527 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(11)) == b);
528 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(12)) == b);
529 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(13)) == b);
530 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(14)) == b);
531 ++b;
532 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(15)) == e);
533 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(16)) == e);
534 }
535 {
536 // some full trees, some empty trees, etc
537 setup({
538 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 25, 30,
539 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 66, 100,
540 });
541 BEAST_EXPECT(
542 sles(*ledger) ==
543 list(
544 0,
545 1,
546 2,
547 3,
548 4,
549 5,
550 6,
551 7,
552 8,
553 9,
554 10,
555 11,
556 12,
557 13,
558 14,
559 15,
560 16,
561 20,
562 25,
563 30,
564 32,
565 33,
566 34,
567 35,
568 36,
569 37,
570 38,
571 39,
572 40,
573 41,
574 42,
575 43,
576 44,
577 45,
578 46,
579 47,
580 48,
581 66,
582 100));
583 auto const b = ledger->stateMap().begin();
584 auto const e = ledger->stateMap().end();
585 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(0)) == e);
586 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(1)) == b);
587 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(5))->key() == UInt256(4));
588 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(15))->key() == UInt256(14));
589 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(16))->key() == UInt256(15));
590 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(19))->key() == UInt256(16));
591 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(20))->key() == UInt256(16));
592 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(24))->key() == UInt256(20));
593 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(31))->key() == UInt256(30));
594 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(32))->key() == UInt256(30));
595 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(40))->key() == UInt256(39));
596 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(47))->key() == UInt256(46));
597 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(48))->key() == UInt256(47));
598 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(64))->key() == UInt256(48));
599
600 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(90))->key() == UInt256(66));
601 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(96))->key() == UInt256(66));
602 BEAST_EXPECT(ledger->stateMap().lowerBound(UInt256(100))->key() == UInt256(66));
603
604 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(0))->key() == UInt256(1));
605 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(5))->key() == UInt256(6));
606 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(15))->key() == UInt256(16));
607 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(16))->key() == UInt256(20));
608 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(18))->key() == UInt256(20));
609 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(20))->key() == UInt256(25));
610 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(31))->key() == UInt256(32));
611 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(32))->key() == UInt256(33));
612 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(47))->key() == UInt256(48));
613 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(48))->key() == UInt256(66));
614 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(53))->key() == UInt256(66));
615 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(66))->key() == UInt256(100));
616 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(70))->key() == UInt256(100));
617 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(85))->key() == UInt256(100));
618 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(98))->key() == UInt256(100));
619 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(100)) == e);
620 BEAST_EXPECT(ledger->stateMap().upperBound(UInt256(155)) == e);
621 }
622 }
623
624 void
626 {
627 testcase("Sles");
628
629 using namespace jtx;
630 Env env(*this);
631 Config const config;
634 Rules{config.features},
635 config.fees.toFees(),
637 env.app().getNodeFamily());
638 auto const ledger =
640 auto const setup123 = [&ledger, this] {
641 // erase middle element
642 wipe(*ledger);
643 ledger->rawInsert(sle(1));
644 ledger->rawInsert(sle(2));
645 ledger->rawInsert(sle(3));
646 BEAST_EXPECT(sles(*ledger) == list(1, 2, 3));
647 };
648 {
649 setup123();
650 OpenView view(ledger.get());
651 view.rawErase(sle(1));
652 view.rawInsert(sle(4));
653 view.rawInsert(sle(5));
654 BEAST_EXPECT(sles(view) == list(2, 3, 4, 5));
655 auto b = view.sles.begin();
656 BEAST_EXPECT(view.sles.upperBound(UInt256(1)) == b);
657 ++b;
658 BEAST_EXPECT(view.sles.upperBound(UInt256(2)) == b);
659 ++b;
660 BEAST_EXPECT(view.sles.upperBound(UInt256(3)) == b);
661 ++b;
662 BEAST_EXPECT(view.sles.upperBound(UInt256(4)) == b);
663 ++b;
664 BEAST_EXPECT(view.sles.upperBound(UInt256(5)) == b);
665 }
666 {
667 setup123();
668 OpenView view(ledger.get());
669 view.rawErase(sle(1));
670 view.rawErase(sle(2));
671 view.rawInsert(sle(4));
672 view.rawInsert(sle(5));
673 BEAST_EXPECT(sles(view) == list(3, 4, 5));
674 auto b = view.sles.begin();
675 BEAST_EXPECT(view.sles.upperBound(UInt256(1)) == b);
676 BEAST_EXPECT(view.sles.upperBound(UInt256(2)) == b);
677 ++b;
678 BEAST_EXPECT(view.sles.upperBound(UInt256(3)) == b);
679 ++b;
680 BEAST_EXPECT(view.sles.upperBound(UInt256(4)) == b);
681 ++b;
682 BEAST_EXPECT(view.sles.upperBound(UInt256(5)) == b);
683 }
684 {
685 setup123();
686 OpenView view(ledger.get());
687 view.rawErase(sle(1));
688 view.rawErase(sle(2));
689 view.rawErase(sle(3));
690 view.rawInsert(sle(4));
691 view.rawInsert(sle(5));
692 BEAST_EXPECT(sles(view) == list(4, 5));
693 auto b = view.sles.begin();
694 BEAST_EXPECT(view.sles.upperBound(UInt256(1)) == b);
695 BEAST_EXPECT(view.sles.upperBound(UInt256(2)) == b);
696 BEAST_EXPECT(view.sles.upperBound(UInt256(3)) == b);
697 ++b;
698 BEAST_EXPECT(view.sles.upperBound(UInt256(4)) == b);
699 ++b;
700 BEAST_EXPECT(view.sles.upperBound(UInt256(5)) == b);
701 }
702 {
703 setup123();
704 OpenView view(ledger.get());
705 view.rawErase(sle(3));
706 view.rawInsert(sle(4));
707 view.rawInsert(sle(5));
708 BEAST_EXPECT(sles(view) == list(1, 2, 4, 5));
709 auto b = view.sles.begin();
710 ++b;
711 BEAST_EXPECT(view.sles.upperBound(UInt256(1)) == b);
712 ++b;
713 BEAST_EXPECT(view.sles.upperBound(UInt256(2)) == b);
714 BEAST_EXPECT(view.sles.upperBound(UInt256(3)) == b);
715 ++b;
716 BEAST_EXPECT(view.sles.upperBound(UInt256(4)) == b);
717 ++b;
718 BEAST_EXPECT(view.sles.upperBound(UInt256(5)) == b);
719 }
720 {
721 setup123();
722 OpenView view(ledger.get());
723 view.rawReplace(sle(1, 10));
724 view.rawReplace(sle(3, 30));
725 BEAST_EXPECT(sles(view) == list(1, 2, 3));
726 BEAST_EXPECT(seq(view.read(k(1))) == 10);
727 BEAST_EXPECT(seq(view.read(k(2))) == 1);
728 BEAST_EXPECT(seq(view.read(k(3))) == 30);
729
730 view.rawErase(sle(3));
731 BEAST_EXPECT(sles(view) == list(1, 2));
732 auto b = view.sles.begin();
733 ++b;
734 BEAST_EXPECT(view.sles.upperBound(UInt256(1)) == b);
735 ++b;
736 BEAST_EXPECT(view.sles.upperBound(UInt256(2)) == b);
737 BEAST_EXPECT(view.sles.upperBound(UInt256(3)) == b);
738 BEAST_EXPECT(view.sles.upperBound(UInt256(4)) == b);
739 BEAST_EXPECT(view.sles.upperBound(UInt256(5)) == b);
740
741 view.rawInsert(sle(5));
742 view.rawInsert(sle(4));
743 view.rawInsert(sle(3));
744 BEAST_EXPECT(sles(view) == list(1, 2, 3, 4, 5));
745 b = view.sles.begin();
746 ++b;
747 BEAST_EXPECT(view.sles.upperBound(UInt256(1)) == b);
748 ++b;
749 BEAST_EXPECT(view.sles.upperBound(UInt256(2)) == b);
750 ++b;
751 BEAST_EXPECT(view.sles.upperBound(UInt256(3)) == b);
752 ++b;
753 BEAST_EXPECT(view.sles.upperBound(UInt256(4)) == b);
754 ++b;
755 BEAST_EXPECT(view.sles.upperBound(UInt256(5)) == b);
756 }
757 }
758
759 void
761 {
762 testcase("Flags");
763
764 using namespace jtx;
765 Env env(*this);
766
767 auto const alice = Account("alice");
768 auto const bob = Account("bob");
769 auto const carol = Account("carol");
770 auto const gw = Account("gateway");
771 auto const usd = gw["USD"];
772 auto const eur = gw["EUR"];
773
774 env.fund(XRP(10000), alice, bob, carol, gw);
775 env.close();
776 env.trust(usd(100), alice, bob, carol);
777 {
778 // Global freezing.
779 env(pay(gw, alice, usd(50)));
780 env(offer(alice, XRP(5), usd(5)));
781
782 // Now freeze gw.
783 env(fset(gw, asfGlobalFreeze));
784 env.close();
785 env(offer(alice, XRP(4), usd(5)), Ter(tecFROZEN));
786 env.close();
787
788 // Alice's USD balance should be zero if frozen.
789 BEAST_EXPECT(
790 usd(0) ==
792 *env.closed(),
793 alice,
794 usd.currency,
795 gw,
797 env.journal));
798
799 // Thaw gw and try again.
800 env(fclear(gw, asfGlobalFreeze));
801 env.close();
802 env(offer("alice", XRP(4), usd(5)));
803 }
804 {
805 // Local freezing.
806 env(pay(gw, bob, usd(50)));
807 env.close();
808
809 // Now gw freezes bob's USD trust line.
810 env(trust(gw, usd(100), bob, tfSetFreeze));
811 env.close();
812
813 // Bob's balance should be zero if frozen.
814 BEAST_EXPECT(
815 usd(0) ==
817 *env.closed(),
818 bob,
819 usd.currency,
820 gw,
822 env.journal));
823
824 // gw thaws bob's trust line. bob gets his money back.
825 env(trust(gw, usd(100), bob, tfClearFreeze));
826 env.close();
827 BEAST_EXPECT(
828 usd(50) ==
830 *env.closed(),
831 bob,
832 usd.currency,
833 gw,
835 env.journal));
836 }
837 {
838 // accountHolds().
839 env(pay(gw, carol, usd(50)));
840 env.close();
841
842 // carol has no EUR.
843 BEAST_EXPECT(
844 eur(0) ==
846 *env.closed(),
847 carol,
848 eur.currency,
849 gw,
851 env.journal));
852
853 // But carol does have USD.
854 BEAST_EXPECT(
855 usd(50) ==
857 *env.closed(),
858 carol,
859 usd.currency,
860 gw,
862 env.journal));
863
864 // carol's XRP balance should be her holdings minus her reserve.
865 auto const carolsXRP = accountHolds(
866 *env.closed(),
867 carol,
868 xrpCurrency(),
869 xrpAccount(),
871 env.journal);
872 // carol's XRP balance: 10000
873 // base reserve: -200
874 // 1 trust line times its reserve: 1 * -50
875 // -------
876 // carol's available balance: 9750
877 BEAST_EXPECT(carolsXRP == XRP(9750));
878
879 // carol should be able to spend *more* than her XRP balance on
880 // a fee by eating into her reserve.
881 env(noop(carol), Fee(carolsXRP + XRP(10)));
882 env.close();
883
884 // carol's XRP balance should now show as zero.
885 BEAST_EXPECT(
886 XRP(0) ==
888 *env.closed(),
889 carol,
890 xrpCurrency(),
891 gw,
893 env.journal));
894 }
895 {
896 // accountFunds().
897 // Gateways have whatever funds they claim to have.
898 auto const gwUSD = accountFunds(
899 *env.closed(), gw, usd(314159), FreezeHandling::ZeroIfFrozen, env.journal);
900 BEAST_EXPECT(gwUSD == usd(314159));
901
902 // carol has funds from the gateway.
903 auto carolsUSD = accountFunds(
904 *env.closed(), carol, usd(0), FreezeHandling::ZeroIfFrozen, env.journal);
905 BEAST_EXPECT(carolsUSD == usd(50));
906
907 // If carol's funds are frozen she has no funds...
908 env(fset(gw, asfGlobalFreeze));
909 env.close();
910 carolsUSD = accountFunds(
911 *env.closed(), carol, usd(0), FreezeHandling::ZeroIfFrozen, env.journal);
912 BEAST_EXPECT(carolsUSD == usd(0));
913
914 // ... unless the query ignores the FROZEN state.
915 carolsUSD = accountFunds(
916 *env.closed(), carol, usd(0), FreezeHandling::IgnoreFreeze, env.journal);
917 BEAST_EXPECT(carolsUSD == usd(50));
918
919 // Just to be tidy, thaw gw.
920 env(fclear(gw, asfGlobalFreeze));
921 env.close();
922 }
923 }
924
925 void
927 {
928 testcase("Transfer rate");
929
930 using namespace jtx;
931 Env env(*this);
932
933 auto const gw1 = Account("gw1");
934
935 env.fund(XRP(10000), gw1);
936 env.close();
937
938 auto rdView = env.closed();
939 // Test with no rate set on gw1.
940 BEAST_EXPECT(transferRate(*rdView, gw1) == kParityRate);
941
942 env(rate(gw1, 1.02));
943 env.close();
944
945 rdView = env.closed();
946 BEAST_EXPECT(transferRate(*rdView, gw1) == Rate{1020000000});
947 }
948
949 void
951 {
952 // This test requires incompatible ledgers. The good news we can
953 // construct and manage two different Env instances at the same
954 // time. So we can use two Env instances to produce mutually
955 // incompatible ledgers.
956 testcase("Are compatible");
957
958 using namespace jtx;
959 auto const alice = Account("alice");
960 auto const bob = Account("bob");
961
962 // The first Env.
963 Env eA(*this, envconfig(), nullptr, beast::Severity::Disabled);
964
965 eA.fund(XRP(10000), alice);
966 eA.close();
967 auto const rdViewA3 = eA.closed();
968
969 eA.fund(XRP(10000), bob);
970 eA.close();
971 auto const rdViewA4 = eA.closed();
972
973 // The two Env's can't share the same ports, so modify the config
974 // of the second Env to use higher port numbers
975 Env eB{*this, envconfig(), nullptr, beast::Severity::Disabled};
976
977 // Make ledgers that are incompatible with the first ledgers. Note
978 // that bob is funded before alice.
979 eB.fund(XRP(10000), bob);
980 eB.close();
981 auto const rdViewB3 = eB.closed();
982
983 eB.fund(XRP(10000), alice);
984 eB.close();
985 auto const rdViewB4 = eB.closed();
986
987 // Check for compatibility.
988 auto const jStream = eA.journal.error();
989 BEAST_EXPECT(areCompatible(*rdViewA3, *rdViewA4, jStream, ""));
990 BEAST_EXPECT(areCompatible(*rdViewA4, *rdViewA3, jStream, ""));
991 BEAST_EXPECT(areCompatible(*rdViewA4, *rdViewA4, jStream, ""));
992 BEAST_EXPECT(!areCompatible(*rdViewA3, *rdViewB4, jStream, ""));
993 BEAST_EXPECT(!areCompatible(*rdViewA4, *rdViewB3, jStream, ""));
994 BEAST_EXPECT(!areCompatible(*rdViewA4, *rdViewB4, jStream, ""));
995
996 // Try the other interface.
997 // Note that the different interface has different outcomes.
998 auto const& iA3 = rdViewA3->header();
999 auto const& iA4 = rdViewA4->header();
1000
1001 BEAST_EXPECT(areCompatible(iA3.hash, iA3.seq, *rdViewA4, jStream, ""));
1002 BEAST_EXPECT(areCompatible(iA4.hash, iA4.seq, *rdViewA3, jStream, ""));
1003 BEAST_EXPECT(areCompatible(iA4.hash, iA4.seq, *rdViewA4, jStream, ""));
1004 BEAST_EXPECT(!areCompatible(iA3.hash, iA3.seq, *rdViewB4, jStream, ""));
1005 BEAST_EXPECT(areCompatible(iA4.hash, iA4.seq, *rdViewB3, jStream, ""));
1006 BEAST_EXPECT(!areCompatible(iA4.hash, iA4.seq, *rdViewB4, jStream, ""));
1007 }
1008
1009 void
1011 {
1012 testcase("Regressions");
1013
1014 using namespace jtx;
1015
1016 // Create a ledger with 1 item, put a
1017 // ApplyView on that, then another ApplyView,
1018 // erase the item, apply.
1019 {
1020 Env env(*this);
1021 Config const config;
1024 Rules{config.features},
1025 config.fees.toFees(),
1027 env.app().getNodeFamily());
1028 auto const ledger =
1030 wipe(*ledger);
1031 ledger->rawInsert(sle(1));
1032 ReadView const& v0 = *ledger;
1033 ApplyViewImpl v1(&v0, TapNone);
1034 {
1035 Sandbox v2(&v1);
1036 v2.erase(v2.peek(k(1)));
1037 v2.apply(v1);
1038 }
1039 BEAST_EXPECT(!v1.exists(k(1)));
1040 }
1041
1042 // Make sure OpenLedger::empty works
1043 {
1044 Env env(*this);
1045 BEAST_EXPECT(env.app().getOpenLedger().empty());
1046 env.fund(XRP(10000), Account("test"));
1047 BEAST_EXPECT(!env.app().getOpenLedger().empty());
1048 }
1049 }
1050
1051 void
1052 run() override
1053 {
1054 // This had better work, or else
1055 BEAST_EXPECT(k(0).key < k(1).key);
1056
1057 testLedger();
1058 testMeta();
1059 testMetaSucc();
1060 testStacked();
1061 testContext();
1062 testSles();
1064 testFlags();
1068 }
1069};
1070
1072{
1073 void
1075 {
1076 using namespace jtx;
1077 Env env{*this, envconfig(validator, "")};
1078
1079 // Start out with no amendments.
1080 auto majorities = getMajorityAmendments(*env.closed());
1081 BEAST_EXPECT(majorities.empty());
1082
1083 // Now close ledgers until the amendments show up.
1084 int i = 0;
1085 for (i = 0; i <= 256; ++i)
1086 {
1087 env.close();
1088 majorities = getMajorityAmendments(*env.closed());
1089 if (!majorities.empty())
1090 break;
1091 }
1092
1093 // There should be at least 3 amendments. Don't do exact comparison
1094 // to avoid maintenance as more amendments are added in the future.
1095 BEAST_EXPECT(i == 254);
1096 BEAST_EXPECT(majorities.size() >= 2);
1097
1098 // None of the amendments should be enabled yet.
1099 auto enabledAmendments = getEnabledAmendments(*env.closed());
1100 BEAST_EXPECT(enabledAmendments.empty());
1101
1102 // Now wait 2 weeks modulo 256 ledgers for the amendments to be
1103 // enabled. Speed the process by closing ledgers every 80 minutes,
1104 // which should get us to just past 2 weeks after 256 ledgers.
1105 for (i = 0; i <= 256; ++i)
1106 {
1107 using namespace std::chrono_literals;
1108 env.close(80min);
1109 enabledAmendments = getEnabledAmendments(*env.closed());
1110 if (!enabledAmendments.empty())
1111 break;
1112 }
1113 BEAST_EXPECT(i == 255);
1114 BEAST_EXPECT(enabledAmendments.size() >= 2);
1115 }
1116
1117 void
1118 run() override
1119 {
1121 }
1122};
1123
1125BEAST_DEFINE_TESTSUITE(GetAmendments, ledger, xrpl);
1126
1127} // namespace xrpl::test
A generic endpoint for log messages.
Definition Journal.h:44
Stream error() const
Definition Journal.h:362
A testsuite class.
Definition suite.h:52
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
Editable, discardable view that can build metadata for one tx.
std::unordered_set< UInt256, beast::Uhash<> > features
std::optional< UInt256 > succ(UInt256 const &key, std::optional< UInt256 > const &last=std::nullopt) const override
SLE::const_pointer read(Keylet const &k) const override
Return the state item associated with a key.
void rawErase(SLE::Ref sle) override
Delete an existing state item.
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
Represents the open ledger.
Definition OpenLedger.h:43
bool empty() const
Returns true if there are no transactions.
bool modify(ModifyType const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:59
void rawReplace(SLE::Ref sle) override
Unconditionally replace a state item.
Definition OpenView.cpp:246
SLE::const_pointer read(Keylet const &k) const override
Return the state item associated with a key.
Definition OpenView.cpp:170
std::optional< key_type > succ(key_type const &key, std::optional< key_type > const &last=std::nullopt) const override
Return the key of the next state item.
Definition OpenView.cpp:163
void rawInsert(SLE::Ref sle) override
Unconditionally insert a state item.
Definition OpenView.cpp:240
void rawErase(SLE::Ref sle) override
Delete an existing state item.
Definition OpenView.cpp:234
A wrapper which makes credits unavailable to balances.
A view into a ledger.
Definition ReadView.h:41
NetClock::time_point parentCloseTime() const
Returns the close time of the previous ledger.
Definition ReadView.h:106
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
SlesType sles
Iterable range of ledger state items.
Definition ReadView.h:267
LedgerIndex seq() const
Returns the sequence number of the base ledger.
Definition ReadView.h:115
virtual std::optional< key_type > succ(key_type const &key, std::optional< key_type > const &last=std::nullopt) const =0
Return the key of the next state item.
Rules controlling protocol behavior.
Definition Rules.h:40
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry > const & Ref
Discardable, editable view to a ledger.
Definition Sandbox.h:18
void apply(RawView &to)
Definition Sandbox.h:38
virtual OpenLedger & getOpenLedger()=0
virtual TimeKeeper & getTimeKeeper()=0
time_point closeTime() const
Returns the predicted close time, in network time.
Definition TimeKeeper.h:61
void insert(SLE::Ref sle) override
Insert a new state SLE.
ApplyFlags flags() const override
Returns the tx apply flags.
SLE::pointer peek(Keylet const &k) override
Prepare to modify the SLE associated with key.
SLE::const_pointer read(Keylet const &k) const override
Return the state item associated with a key.
void erase(SLE::Ref sle) override
Remove a peeked SLE.
void rawInsert(SLE::Ref sle) override
Unconditionally insert a state item.
void update(SLE::Ref sle) override
Indicate changes to a peeked SLE.
bool exists(Keylet const &k) const override
Determine if a state item exists.
void run() override
Runs the suite.
static std::vector< UInt256 > list(Args... args)
static std::uint32_t seq(std::shared_ptr< T > const &le)
Definition View_test.cpp:75
void succ(ReadView const &v, std::uint32_t id, std::optional< std::uint32_t > answer)
static Keylet k(std::uint64_t id)
Definition View_test.cpp:58
static void wipe(OpenLedger &openLedger)
Definition View_test.cpp:89
static std::vector< UInt256 > sles(ReadView const &ledger)
void run() override
Runs the suite.
static void wipe(Ledger &ledger)
static std::shared_ptr< std::remove_const_t< T > > copy(std::shared_ptr< T > const &sp)
static SLE::pointer sle(std::uint64_t id, std::uint32_t seq=1)
Definition View_test.cpp:65
static void seq(SLE::Ref le, std::uint32_t seq)
Definition View_test.cpp:82
A transaction testing environment.
Definition Env.h:161
Application & app()
Definition Env.h:300
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:133
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
Definition Env.cpp:127
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:323
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:354
beast::Journal const journal
Definition Env.h:204
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
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition ter.h:18
T make_shared(T... args)
T min(T... args)
Keylet unchecked(UInt256 const &key) noexcept
Any ledger entry.
Definition Indexes.cpp:409
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:14
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
json::Value noop(Account const &account)
The null transaction.
Definition noop.h:14
json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
Definition flags.h:110
json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
Definition offer.cpp:14
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:38
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:18
json::Value rate(Account const &account, double multiplier)
Set a transfer rate.
Definition rate.cpp:15
json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition flags.cpp:15
std::unique_ptr< Config > validator(std::unique_ptr< Config >, std::string const &)
adjust configuration with params needed to be a validator
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
CreateGenesisT const kCreateGenesis
std::set< UInt256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:312
bool areCompatible(ReadView const &validLedger, ReadView const &testLedger, beast::Journal::Stream const &s, char const *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
Definition View.cpp:214
Currency const & xrpCurrency()
XRP currency.
Definition UintTypes.cpp:99
void open(soci::session &s, BasicConfig const &config, std::string const &dbName)
Open a soci session.
Definition SociDB.cpp:91
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
BaseUInt< 256 > UInt256
Definition base_uint.h:581
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Rate const kParityRate
A transfer rate signifying a 1:1 exchange.
@ TapNone
Definition ApplyView.h:28
@ TapRetry
Definition ApplyView.h:36
AccountID const & xrpAccount()
Compute AccountID from public key.
@ tecFROZEN
Definition TER.h:314
MajorityAmendmentsT getMajorityAmendments(ReadView const &view)
Definition View.cpp:318
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j, SpendableHandling includeFullBalance=SpendableHandling::SimpleBalance)
T push_back(T... args)
T reserve(T... args)
Fees toFees() const
Convert to a Fees object for use with Ledger construction.
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
UInt256 key
Definition Keylet.h:21
Represents a transfer rate.
Definition Rate.h:21
Iterator begin() const
Definition ReadView.cpp:22
Iterator upperBound(key_type const &key) const
Definition ReadView.cpp:34