rippled
Loading...
Searching...
No Matches
Freeze_test.cpp
1#include <test/jtx.h>
2#include <test/jtx/AMM.h>
3
4#include <xrpl/protocol/AccountID.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/SField.h>
7#include <xrpl/protocol/TxFlags.h>
8#include <xrpl/protocol/jss.h>
9
10namespace xrpl {
11
13{
14 void
16 {
17 testcase("RippleState Freeze");
18
19 using namespace test::jtx;
20 Env env(*this, features);
21
22 Account G1{"G1"};
23 Account alice{"alice"};
24 Account bob{"bob"};
25
26 env.fund(XRP(1000), G1, alice, bob);
27 env.close();
28
29 env.trust(G1["USD"](100), bob);
30 env.trust(G1["USD"](100), alice);
31 env.close();
32
33 env(pay(G1, bob, G1["USD"](10)));
34 env(pay(G1, alice, G1["USD"](100)));
35 env.close();
36
37 env(offer(alice, XRP(500), G1["USD"](100)));
38 env.close();
39
40 {
41 auto lines = getAccountLines(env, bob);
42 if (!BEAST_EXPECT(checkArraySize(lines[jss::lines], 1u)))
43 return;
44 BEAST_EXPECT(lines[jss::lines][0u][jss::account] == G1.human());
45 BEAST_EXPECT(lines[jss::lines][0u][jss::limit] == "100");
46 BEAST_EXPECT(lines[jss::lines][0u][jss::balance] == "10");
47 }
48
49 {
50 auto lines = getAccountLines(env, alice);
51 if (!BEAST_EXPECT(checkArraySize(lines[jss::lines], 1u)))
52 return;
53 BEAST_EXPECT(lines[jss::lines][0u][jss::account] == G1.human());
54 BEAST_EXPECT(lines[jss::lines][0u][jss::limit] == "100");
55 BEAST_EXPECT(lines[jss::lines][0u][jss::balance] == "100");
56 }
57
58 {
59 // Account with line unfrozen (proving operations normally work)
60 // test: can make Payment on that line
61 env(pay(alice, bob, G1["USD"](1)));
62
63 // test: can receive Payment on that line
64 env(pay(bob, alice, G1["USD"](1)));
65 env.close();
66 }
67
68 {
69 // Is created via a TrustSet with SetFreeze flag
70 // test: sets LowFreeze | HighFreeze flags
71 env(trust(G1, bob["USD"](0), tfSetFreeze));
72 auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
73 if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
74 return;
75 auto ff = affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
76 BEAST_EXPECT(ff[sfLowLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none));
77 BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfLowFreeze);
78 BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze));
79 env.close();
80 }
81
82 {
83 // Account with line frozen by issuer
84 // test: can buy more assets on that line
85 env(offer(bob, G1["USD"](5), XRP(25)));
86 auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
87 if (!BEAST_EXPECT(checkArraySize(affected, 5u)))
88 return;
89 auto ff = affected[3u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
90 BEAST_EXPECT(ff[sfHighLimit.fieldName] == bob["USD"](100).value().getJson(JsonOptions::none));
91 auto amt = STAmount{Issue{to_currency("USD"), noAccount()}, -15}.value().getJson(JsonOptions::none);
92 BEAST_EXPECT(ff[sfBalance.fieldName] == amt);
93 env.close();
94 }
95
96 {
97 // test: can not sell assets from that line
98 env(offer(bob, XRP(1), G1["USD"](5)), ter(tecUNFUNDED_OFFER));
99
100 // test: can receive Payment on that line
101 env(pay(alice, bob, G1["USD"](1)));
102
103 // test: can not make Payment from that line
104 env(pay(bob, alice, G1["USD"](1)), ter(tecPATH_DRY));
105 }
106
107 {
108 // check G1 account lines
109 // test: shows freeze
110 auto lines = getAccountLines(env, G1);
111 Json::Value bobLine;
112 for (auto const& it : lines[jss::lines])
113 {
114 if (it[jss::account] == bob.human())
115 {
116 bobLine = it;
117 break;
118 }
119 }
120 if (!BEAST_EXPECT(bobLine))
121 return;
122 BEAST_EXPECT(bobLine[jss::freeze] == true);
123 BEAST_EXPECT(bobLine[jss::balance] == "-16");
124 }
125
126 {
127 // test: shows freeze peer
128 auto lines = getAccountLines(env, bob);
129 Json::Value g1Line;
130 for (auto const& it : lines[jss::lines])
131 {
132 if (it[jss::account] == G1.human())
133 {
134 g1Line = it;
135 break;
136 }
137 }
138 if (!BEAST_EXPECT(g1Line))
139 return;
140 BEAST_EXPECT(g1Line[jss::freeze_peer] == true);
141 BEAST_EXPECT(g1Line[jss::balance] == "16");
142 }
143
144 {
145 // Is cleared via a TrustSet with ClearFreeze flag
146 // test: sets LowFreeze | HighFreeze flags
147 env(trust(G1, bob["USD"](0), tfClearFreeze));
148 auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
149 if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
150 return;
151 auto ff = affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
152 BEAST_EXPECT(ff[sfLowLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none));
153 BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfLowFreeze));
154 BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze));
155 env.close();
156 }
157 }
158
159 void
161 {
162 testcase("Deep Freeze");
163
164 using namespace test::jtx;
165 Env env(*this, features);
166
167 Account G1{"G1"};
168 Account A1{"A1"};
169
170 env.fund(XRP(10000), G1, A1);
171 env.close();
172
173 env.trust(G1["USD"](1000), A1);
174 env.close();
175
176 if (features[featureDeepFreeze])
177 {
178 // test: Issuer deep freezing the trust line in a single
179 // transaction
180 env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze));
181 {
182 auto const flags = getTrustlineFlags(env, 2u, 1u);
183 BEAST_EXPECT(flags & lsfLowFreeze);
184 BEAST_EXPECT(flags & lsfLowDeepFreeze);
185 BEAST_EXPECT(!(flags & (lsfHighFreeze | lsfHighDeepFreeze)));
186 env.close();
187 }
188
189 // test: Issuer clearing deep freeze and normal freeze in a single
190 // transaction
191 env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze));
192 {
193 auto const flags = getTrustlineFlags(env, 2u, 1u);
194 BEAST_EXPECT(!(flags & (lsfLowFreeze | lsfLowDeepFreeze)));
195 BEAST_EXPECT(!(flags & (lsfHighFreeze | lsfHighDeepFreeze)));
196 env.close();
197 }
198
199 // test: Issuer deep freezing not already frozen line must fail
200 env(trust(G1, A1["USD"](0), tfSetDeepFreeze), ter(tecNO_PERMISSION));
201
202 env(trust(G1, A1["USD"](0), tfSetFreeze));
203 env.close();
204
205 // test: Issuer deep freezing already frozen trust line
206 env(trust(G1, A1["USD"](0), tfSetDeepFreeze));
207 {
208 auto const flags = getTrustlineFlags(env, 2u, 1u);
209 BEAST_EXPECT(flags & lsfLowFreeze);
210 BEAST_EXPECT(flags & lsfLowDeepFreeze);
211 BEAST_EXPECT(!(flags & (lsfHighFreeze | lsfHighDeepFreeze)));
212 env.close();
213 }
214
215 // test: Holder clearing freeze flags has no effect. Each sides'
216 // flags are independent
217 env(trust(A1, G1["USD"](0), tfClearFreeze | tfClearDeepFreeze));
218 {
219 auto const flags = getTrustlineFlags(env, 2u, 1u);
220 BEAST_EXPECT(flags & lsfLowFreeze);
221 BEAST_EXPECT(flags & lsfLowDeepFreeze);
222 BEAST_EXPECT(!(flags & (lsfHighFreeze | lsfHighDeepFreeze)));
223 env.close();
224 }
225
226 // test: Issuer can't clear normal freeze when line is deep frozen
227 env(trust(G1, A1["USD"](0), tfClearFreeze), ter(tecNO_PERMISSION));
228
229 // test: Issuer clearing deep freeze but normal freeze is still in
230 // effect
231 env(trust(G1, A1["USD"](0), tfClearDeepFreeze));
232 {
233 auto const flags = getTrustlineFlags(env, 2u, 1u);
234 BEAST_EXPECT(flags & lsfLowFreeze);
235 BEAST_EXPECT(!(flags & lsfLowDeepFreeze));
236 BEAST_EXPECT(!(flags & (lsfHighFreeze | lsfHighDeepFreeze)));
237 env.close();
238 }
239 }
240 else
241 {
242 // test: applying deep freeze before amendment fails
243 env(trust(G1, A1["USD"](0), tfSetDeepFreeze), ter(temINVALID_FLAG));
244
245 // test: clearing deep freeze before amendment fails
246 env(trust(G1, A1["USD"](0), tfClearDeepFreeze), ter(temINVALID_FLAG));
247 }
248 }
249
250 void
252 {
253 testcase("Create Frozen Trustline");
254
255 using namespace test::jtx;
256 Env env(*this, features);
257
258 Account G1{"G1"};
259 Account A1{"A1"};
260
261 env.fund(XRP(10000), G1, A1);
262 env.close();
263
264 // test: can create frozen trustline
265 {
266 env(trust(G1, A1["USD"](1000), tfSetFreeze));
267 auto const flags = getTrustlineFlags(env, 5u, 3u, false);
268 BEAST_EXPECT(flags & lsfLowFreeze);
269 env.close();
270 env.require(lines(A1, 1));
271 }
272
273 // Cleanup
274 env(trust(G1, A1["USD"](0), tfClearFreeze));
275 env.close();
276 env.require(lines(G1, 0));
277 env.require(lines(A1, 0));
278
279 // test: cannot create deep frozen trustline without normal freeze
280 if (features[featureDeepFreeze])
281 {
282 env(trust(G1, A1["USD"](1000), tfSetDeepFreeze), ter(tecNO_PERMISSION));
283 env.close();
284 env.require(lines(A1, 0));
285 }
286
287 // test: can create deep frozen trustline together with normal freeze
288 if (features[featureDeepFreeze])
289 {
290 env(trust(G1, A1["USD"](1000), tfSetFreeze | tfSetDeepFreeze));
291 auto const flags = getTrustlineFlags(env, 5u, 3u, false);
292 BEAST_EXPECT(flags & lsfLowFreeze);
293 BEAST_EXPECT(flags & lsfLowDeepFreeze);
294 env.close();
295 env.require(lines(A1, 1));
296 }
297 }
298
299 void
301 {
302 testcase("Freeze Set and Clear");
303
304 using namespace test::jtx;
305 Env env(*this, features);
306
307 Account G1{"G1"};
308 Account A1{"A1"};
309
310 env.fund(XRP(10000), G1, A1);
311 env.close();
312
313 env.trust(G1["USD"](1000), A1);
314 env.close();
315
316 if (features[featureDeepFreeze])
317 {
318 // test: can't have both set and clear flag families in the same
319 // transaction
320 env(trust(G1, A1["USD"](0), tfSetFreeze | tfClearFreeze), ter(tecNO_PERMISSION));
321 env(trust(G1, A1["USD"](0), tfSetFreeze | tfClearDeepFreeze), ter(tecNO_PERMISSION));
322 env(trust(G1, A1["USD"](0), tfSetDeepFreeze | tfClearFreeze), ter(tecNO_PERMISSION));
323 env(trust(G1, A1["USD"](0), tfSetDeepFreeze | tfClearDeepFreeze), ter(tecNO_PERMISSION));
324 }
325 else
326 {
327 // test: old behavior, transaction succeed with no effect on a
328 // trust line
329 env(trust(G1, A1["USD"](0), tfSetFreeze | tfClearFreeze));
330 {
331 auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
332 BEAST_EXPECT(checkArraySize(affected, 1u)); // means no trustline changes
333 }
334 }
335 }
336
337 void
339 {
340 testcase("Global Freeze");
341
342 using namespace test::jtx;
343 Env env(*this, features);
344
345 Account G1{"G1"};
346 Account A1{"A1"};
347 Account A2{"A2"};
348 Account A3{"A3"};
349 Account A4{"A4"};
350
351 env.fund(XRP(12000), G1);
352 env.fund(XRP(1000), A1);
353 env.fund(XRP(20000), A2, A3, A4);
354 env.close();
355
356 env.trust(G1["USD"](1200), A1);
357 env.trust(G1["USD"](200), A2);
358 env.trust(G1["BTC"](100), A3);
359 env.trust(G1["BTC"](100), A4);
360 env.close();
361
362 env(pay(G1, A1, G1["USD"](1000)));
363 env(pay(G1, A2, G1["USD"](100)));
364 env(pay(G1, A3, G1["BTC"](100)));
365 env(pay(G1, A4, G1["BTC"](100)));
366 env.close();
367
368 env(offer(G1, XRP(10000), G1["USD"](100)), txflags(tfPassive));
369 env(offer(G1, G1["USD"](100), XRP(10000)), txflags(tfPassive));
370 env(offer(A1, XRP(10000), G1["USD"](100)), txflags(tfPassive));
371 env(offer(A2, G1["USD"](100), XRP(10000)), txflags(tfPassive));
372 env.close();
373
374 {
375 // Is toggled via AccountSet using SetFlag and ClearFlag
376 // test: SetFlag GlobalFreeze
377 env.require(nflags(G1, asfGlobalFreeze));
378 env(fset(G1, asfGlobalFreeze));
379 env.require(flags(G1, asfGlobalFreeze));
380 env.require(nflags(G1, asfNoFreeze));
381
382 // test: ClearFlag GlobalFreeze
383 env(fclear(G1, asfGlobalFreeze));
384 env.require(nflags(G1, asfGlobalFreeze));
385 env.require(nflags(G1, asfNoFreeze));
386 }
387
388 {
389 // Account without GlobalFreeze (proving operations normally work)
390 // test: visible offers where taker_pays is unfrozen issuer
391 auto offers = env.rpc("book_offers", std::string("USD/") + G1.human(), "XRP")[jss::result][jss::offers];
392 if (!BEAST_EXPECT(checkArraySize(offers, 2u)))
393 return;
394 std::set<std::string> accounts;
395 for (auto const& offer : offers)
396 {
397 accounts.insert(offer[jss::Account].asString());
398 }
399 BEAST_EXPECT(accounts.find(A2.human()) != std::end(accounts));
400 BEAST_EXPECT(accounts.find(G1.human()) != std::end(accounts));
401
402 // test: visible offers where taker_gets is unfrozen issuer
403 offers = env.rpc("book_offers", "XRP", std::string("USD/") + G1.human())[jss::result][jss::offers];
404 if (!BEAST_EXPECT(checkArraySize(offers, 2u)))
405 return;
406 accounts.clear();
407 for (auto const& offer : offers)
408 {
409 accounts.insert(offer[jss::Account].asString());
410 }
411 BEAST_EXPECT(accounts.find(A1.human()) != std::end(accounts));
412 BEAST_EXPECT(accounts.find(G1.human()) != std::end(accounts));
413 }
414
415 {
416 // Offers/Payments
417 // test: assets can be bought on the market
418 env(offer(A3, G1["BTC"](1), XRP(1)));
419
420 // test: assets can be sold on the market
421 env(offer(A4, XRP(1), G1["BTC"](1)));
422
423 // test: direct issues can be sent
424 env(pay(G1, A2, G1["USD"](1)));
425
426 // test: direct redemptions can be sent
427 env(pay(A2, G1, G1["USD"](1)));
428
429 // test: via rippling can be sent
430 env(pay(A2, A1, G1["USD"](1)));
431
432 // test: via rippling can be sent back
433 env(pay(A1, A2, G1["USD"](1)));
434 }
435
436 {
437 // Account with GlobalFreeze
438 // set GlobalFreeze first
439 // test: SetFlag GlobalFreeze will toggle back to freeze
440 env.require(nflags(G1, asfGlobalFreeze));
441 env(fset(G1, asfGlobalFreeze));
442 env.require(flags(G1, asfGlobalFreeze));
443 env.require(nflags(G1, asfNoFreeze));
444
445 // test: assets can't be bought on the market
446 env(offer(A3, G1["BTC"](1), XRP(1)), ter(tecFROZEN));
447
448 // test: assets can't be sold on the market
449 env(offer(A4, XRP(1), G1["BTC"](1)), ter(tecFROZEN));
450 }
451
452 {
453 // offers are filtered (seems to be broken?)
454 // test: account_offers always shows own offers
455 auto offers = getAccountOffers(env, G1)[jss::offers];
456 if (!BEAST_EXPECT(checkArraySize(offers, 2u)))
457 return;
458
459 // test: book_offers shows offers
460 // (should these actually be filtered?)
461 offers = env.rpc("book_offers", "XRP", std::string("USD/") + G1.human())[jss::result][jss::offers];
462 if (!BEAST_EXPECT(checkArraySize(offers, 2u)))
463 return;
464
465 offers = env.rpc("book_offers", std::string("USD/") + G1.human(), "XRP")[jss::result][jss::offers];
466 if (!BEAST_EXPECT(checkArraySize(offers, 2u)))
467 return;
468 }
469
470 {
471 // Payments
472 // test: direct issues can be sent
473 env(pay(G1, A2, G1["USD"](1)));
474
475 // test: direct redemptions can be sent
476 env(pay(A2, G1, G1["USD"](1)));
477
478 // test: via rippling cant be sent
479 env(pay(A2, A1, G1["USD"](1)), ter(tecPATH_DRY));
480 }
481 }
482
483 void
485 {
486 testcase("No Freeze");
487
488 using namespace test::jtx;
489 Env env(*this, features);
490
491 Account G1{"G1"};
492 Account A1{"A1"};
493 Account frozenAcc{"A2"};
494 Account deepFrozenAcc{"A3"};
495
496 env.fund(XRP(12000), G1);
497 env.fund(XRP(1000), A1);
498 env.fund(XRP(1000), frozenAcc);
499 env.fund(XRP(1000), deepFrozenAcc);
500 env.close();
501
502 env.trust(G1["USD"](1000), A1);
503 env.trust(G1["USD"](1000), frozenAcc);
504 env.trust(G1["USD"](1000), deepFrozenAcc);
505 env.close();
506
507 env(pay(G1, A1, G1["USD"](1000)));
508 env(pay(G1, frozenAcc, G1["USD"](1000)));
509 env(pay(G1, deepFrozenAcc, G1["USD"](1000)));
510
511 // Freezing and deep freezing some of the trust lines to check deep
512 // freeze and clearing of freeze separately
513 env(trust(G1, frozenAcc["USD"](0), tfSetFreeze));
514 {
515 auto const flags = getTrustlineFlags(env, 2u, 1u);
516 BEAST_EXPECT(flags & lsfLowFreeze);
517 BEAST_EXPECT(!(flags & lsfHighFreeze));
518 }
519 if (features[featureDeepFreeze])
520 {
521 env(trust(G1, deepFrozenAcc["USD"](0), tfSetFreeze | tfSetDeepFreeze));
522 {
523 auto const flags = getTrustlineFlags(env, 2u, 1u);
524 BEAST_EXPECT(!(flags & (lsfLowFreeze | lsfLowDeepFreeze)));
525 BEAST_EXPECT(flags & lsfHighFreeze);
526 BEAST_EXPECT(flags & lsfHighDeepFreeze);
527 }
528 }
529 env.close();
530
531 // TrustSet NoFreeze
532 // test: should set NoFreeze in Flags
533 env.require(nflags(G1, asfNoFreeze));
534 env(fset(G1, asfNoFreeze));
535 env.require(flags(G1, asfNoFreeze));
536 env.require(nflags(G1, asfGlobalFreeze));
537
538 // test: cannot be cleared
539 env(fclear(G1, asfNoFreeze));
540 env.require(flags(G1, asfNoFreeze));
541 env.require(nflags(G1, asfGlobalFreeze));
542
543 // test: can set GlobalFreeze
544 env(fset(G1, asfGlobalFreeze));
545 env.require(flags(G1, asfNoFreeze));
546 env.require(flags(G1, asfGlobalFreeze));
547
548 // test: cannot unset GlobalFreeze
549 env(fclear(G1, asfGlobalFreeze));
550 env.require(flags(G1, asfNoFreeze));
551 env.require(flags(G1, asfGlobalFreeze));
552
553 // test: trustlines can't be frozen when no freeze enacted
554 if (features[featureDeepFreeze])
555 {
556 env(trust(G1, A1["USD"](0), tfSetFreeze), ter(tecNO_PERMISSION));
557
558 // test: cannot deep freeze already frozen line when no freeze
559 // enacted
560 env(trust(G1, frozenAcc["USD"](0), tfSetDeepFreeze), ter(tecNO_PERMISSION));
561 }
562 else
563 {
564 // test: previous functionality, checking there's no changes to a
565 // trust line
566 env(trust(G1, A1["USD"](0), tfSetFreeze));
567 auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
568 if (!BEAST_EXPECT(checkArraySize(affected, 1u)))
569 return;
570
571 auto let = affected[0u][sfModifiedNode.fieldName][sfLedgerEntryType.fieldName];
572 BEAST_EXPECT(let == jss::AccountRoot);
573 }
574
575 // test: can clear freeze on account
576 env(trust(G1, frozenAcc["USD"](0), tfClearFreeze));
577 {
578 auto const flags = getTrustlineFlags(env, 2u, 1u);
579 BEAST_EXPECT(!(flags & lsfLowFreeze));
580 }
581
582 if (features[featureDeepFreeze])
583 {
584 // test: can clear deep freeze on account
585 env(trust(G1, deepFrozenAcc["USD"](0), tfClearDeepFreeze));
586 {
587 auto const flags = getTrustlineFlags(env, 2u, 1u);
588 BEAST_EXPECT(flags & lsfHighFreeze);
589 BEAST_EXPECT(!(flags & lsfHighDeepFreeze));
590 }
591 }
592 }
593
594 void
596 {
597 testcase("Offers for Frozen Trust Lines");
598
599 using namespace test::jtx;
600 Env env(*this, features);
601
602 Account G1{"G1"};
603 Account A2{"A2"};
604 Account A3{"A3"};
605 Account A4{"A4"};
606
607 env.fund(XRP(1000), G1, A3, A4);
608 env.fund(XRP(2000), A2);
609 env.close();
610
611 env.trust(G1["USD"](1000), A2);
612 env.trust(G1["USD"](2000), A3);
613 env.trust(G1["USD"](2000), A4);
614 env.close();
615
616 env(pay(G1, A3, G1["USD"](2000)));
617 env(pay(G1, A4, G1["USD"](2000)));
618 env.close();
619
620 env(offer(A3, XRP(1000), G1["USD"](1000)), txflags(tfPassive));
621 env.close();
622
623 // removal after successful payment
624 // test: make a payment with partially consuming offer
625 env(pay(A2, G1, G1["USD"](1)), paths(G1["USD"]), sendmax(XRP(1)));
626 env.close();
627
628 // test: offer was only partially consumed
629 auto offers = getAccountOffers(env, A3)[jss::offers];
630 if (!BEAST_EXPECT(checkArraySize(offers, 1u)))
631 return;
632 BEAST_EXPECT(offers[0u][jss::taker_gets] == G1["USD"](999).value().getJson(JsonOptions::none));
633
634 // test: someone else creates an offer providing liquidity
635 env(offer(A4, XRP(999), G1["USD"](999)));
636 env.close();
637
638 // test: owner of partially consumed offers line is frozen
639 env(trust(G1, A3["USD"](0), tfSetFreeze));
640 auto affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
641 if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
642 return;
643 auto ff = affected[1u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
644 BEAST_EXPECT(ff[sfHighLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none));
645 BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfLowFreeze));
646 BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfHighFreeze);
647 env.close();
648
649 // verify offer on the books
650 offers = getAccountOffers(env, A3)[jss::offers];
651 if (!BEAST_EXPECT(checkArraySize(offers, 1u)))
652 return;
653
654 // test: Can make a payment via the new offer
655 env(pay(A2, G1, G1["USD"](1)), paths(G1["USD"]), sendmax(XRP(1)));
656 env.close();
657
658 // test: Partially consumed offer was removed by tes* payment
659 offers = getAccountOffers(env, A3)[jss::offers];
660 if (!BEAST_EXPECT(checkArraySize(offers, 0u)))
661 return;
662
663 // removal buy successful OfferCreate
664 // test: freeze the new offer
665 env(trust(G1, A4["USD"](0), tfSetFreeze));
666 affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
667 if (!BEAST_EXPECT(checkArraySize(affected, 2u)))
668 return;
669 ff = affected[0u][sfModifiedNode.fieldName][sfFinalFields.fieldName];
670 BEAST_EXPECT(ff[sfLowLimit.fieldName] == G1["USD"](0).value().getJson(JsonOptions::none));
671 BEAST_EXPECT(ff[jss::Flags].asUInt() & lsfLowFreeze);
672 BEAST_EXPECT(!(ff[jss::Flags].asUInt() & lsfHighFreeze));
673 env.close();
674
675 // test: can no longer create a crossing offer
676 env(offer(A2, G1["USD"](999), XRP(999)));
677 affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
678 if (!BEAST_EXPECT(checkArraySize(affected, 8u)))
679 return;
680 auto created = affected[0u][sfCreatedNode.fieldName];
681 BEAST_EXPECT(created[sfNewFields.fieldName][jss::Account] == A2.human());
682 env.close();
683
684 // test: offer was removed by offer_create
685 offers = getAccountOffers(env, A4)[jss::offers];
686 if (!BEAST_EXPECT(checkArraySize(offers, 0u)))
687 return;
688 }
689
690 void
692 {
693 testcase("Offers on frozen trust lines");
694
695 using namespace test::jtx;
696 Env env(*this, features);
697
698 Account G1{"G1"};
699 Account A1{"A1"};
700 Account A2{"A2"};
701 Account A3{"A3"};
702 auto const USD{G1["USD"]};
703
704 env.fund(XRP(10000), G1, A1, A2, A3);
705 env.close();
706
707 auto const limit = USD(10000);
708 env.trust(limit, A1, A2, A3);
709 env.close();
710
711 env(pay(G1, A1, USD(1000)));
712 env(pay(G1, A2, USD(1000)));
713 env.close();
714
715 // Making large passive sell offer
716 // Wants to sell 50 USD for 100 XRP
717 env(offer(A2, XRP(100), USD(50)), txflags(tfPassive));
718 env.close();
719 // Making large passive buy offer
720 // Wants to buy 100 USD for 100 XRP
721 env(offer(A3, USD(100), XRP(100)), txflags(tfPassive));
722 env.close();
723 env.require(offers(A2, 1), offers(A3, 1));
724
725 // Checking A1 can buy from A2 by crossing it's offer
726 env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill));
727 env.close();
728 env.require(balance(A1, USD(1001)), balance(A2, USD(999)));
729
730 // Checking A1 can sell to A3 by crossing it's offer
731 env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill));
732 env.close();
733 env.require(balance(A1, USD(1000)), balance(A3, USD(1)));
734
735 // Testing aggressive and passive offer placing, trustline frozen by
736 // the issuer
737 {
738 env(trust(G1, A1["USD"](0), tfSetFreeze));
739 env.close();
740
741 // test: can still make passive buy offer
742 env(offer(A1, USD(1), XRP(0.5)), txflags(tfPassive));
743 env.close();
744 env.require(balance(A1, USD(1000)), offers(A1, 1));
745 // Cleanup
746 env(offer_cancel(A1, env.seq(A1) - 1));
747 env.require(offers(A1, 0));
748 env.close();
749
750 // test: can still buy from A2
751 env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill));
752 env.close();
753 env.require(balance(A1, USD(1001)), balance(A2, USD(998)), offers(A1, 0));
754
755 // test: cannot create passive sell offer
756 env(offer(A1, XRP(2), USD(1)), txflags(tfPassive), ter(tecUNFUNDED_OFFER));
757 env.close();
758 env.require(balance(A1, USD(1001)), offers(A1, 0));
759
760 // test: cannot sell to A3
761 env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill), ter(tecUNFUNDED_OFFER));
762 env.close();
763 env.require(balance(A1, USD(1001)), offers(A1, 0));
764
765 env(trust(G1, A1["USD"](0), tfClearFreeze));
766 env.close();
767 }
768
769 // Testing aggressive and passive offer placing, trustline deep frozen
770 // by the issuer
771 if (features[featureDeepFreeze])
772 {
773 env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze));
774 env.close();
775
776 // test: cannot create passive buy offer
777 env(offer(A1, USD(1), XRP(0.5)), txflags(tfPassive), ter(tecFROZEN));
778 env.close();
779
780 // test: cannot buy from A2
781 env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill), ter(tecFROZEN));
782 env.close();
783
784 // test: cannot create passive sell offer
785 env(offer(A1, XRP(2), USD(1)), txflags(tfPassive), ter(tecUNFUNDED_OFFER));
786 env.close();
787
788 // test: cannot sell to A3
789 env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill), ter(tecUNFUNDED_OFFER));
790 env.close();
791
792 env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze));
793 env.close();
794 env.require(balance(A1, USD(1001)), offers(A1, 0));
795 }
796
797 // Testing already existing offers behavior after trustline is frozen by
798 // the issuer
799 {
800 env.require(balance(A1, USD(1001)));
801 env(offer(A1, XRP(1.9), USD(1)));
802 env(offer(A1, USD(1), XRP(1.1)));
803 env.close();
804 env.require(balance(A1, USD(1001)), offers(A1, 2));
805
806 env(trust(G1, A1["USD"](0), tfSetFreeze));
807 env.close();
808
809 // test: A2 wants to sell to A1, must succeed
810 env.require(balance(A1, USD(1001)), balance(A2, USD(998)));
811 env(offer(A2, XRP(1.1), USD(1)), txflags(tfFillOrKill));
812 env.close();
813 env.require(balance(A1, USD(1002)), balance(A2, USD(997)), offers(A1, 1));
814
815 // test: A3 wants to buy from A1, must fail
816 env.require(balance(A1, USD(1002)), balance(A3, USD(1)), offers(A1, 1));
817 env(offer(A3, USD(1), XRP(1.9)), txflags(tfFillOrKill), ter(tecKILLED));
818 env.close();
819 env.require(balance(A1, USD(1002)), balance(A3, USD(1)), offers(A1, 0));
820
821 env(trust(G1, A1["USD"](0), tfClearFreeze));
822 env.close();
823 }
824
825 // Testing existing offers behavior after trustline is deep frozen by
826 // the issuer
827 if (features[featureDeepFreeze])
828 {
829 env.require(balance(A1, USD(1002)));
830 env(offer(A1, XRP(1.9), USD(1)));
831 env(offer(A1, USD(1), XRP(1.1)));
832 env.close();
833 env.require(balance(A1, USD(1002)), offers(A1, 2));
834
835 env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze));
836 env.close();
837
838 // test: A2 wants to sell to A1, must fail
839 env.require(balance(A1, USD(1002)), balance(A2, USD(997)));
840 env(offer(A2, XRP(1.1), USD(1)), txflags(tfFillOrKill), ter(tecKILLED));
841 env.close();
842 env.require(balance(A1, USD(1002)), balance(A2, USD(997)), offers(A1, 1));
843
844 // test: A3 wants to buy from A1, must fail
845 env.require(balance(A1, USD(1002)), balance(A3, USD(1)), offers(A1, 1));
846 env(offer(A3, USD(1), XRP(1.9)), txflags(tfFillOrKill), ter(tecKILLED));
847 env.close();
848 env.require(balance(A1, USD(1002)), balance(A3, USD(1)), offers(A1, 0));
849
850 env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze));
851 env.close();
852 }
853
854 // Testing aggressive and passive offer placing, trustline frozen by
855 // the holder
856 {
857 env(trust(A1, limit, tfSetFreeze));
858 env.close();
859
860 // test: A1 can make passive buy offer
861 env(offer(A1, USD(1), XRP(0.5)), txflags(tfPassive));
862 env.close();
863 env.require(balance(A1, USD(1002)), offers(A1, 1));
864 // Cleanup
865 env(offer_cancel(A1, env.seq(A1) - 1));
866 env.require(offers(A1, 0));
867 env.close();
868
869 // test: A1 wants to buy, must fail
870 env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill), ter(tecKILLED));
871 env.close();
872 env.require(balance(A1, USD(1002)), balance(A2, USD(997)), offers(A1, 0));
873
874 // test: A1 can create passive sell offer
875 env(offer(A1, XRP(2), USD(1)), txflags(tfPassive));
876 env.close();
877 env.require(balance(A1, USD(1002)), offers(A1, 1));
878 // Cleanup
879 env(offer_cancel(A1, env.seq(A1) - 1));
880 env.require(offers(A1, 0));
881 env.close();
882
883 // test: A1 can sell to A3
884 env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill));
885 env.close();
886 env.require(balance(A1, USD(1001)), offers(A1, 0));
887
888 env(trust(A1, limit, tfClearFreeze));
889 env.close();
890 }
891
892 // Testing aggressive and passive offer placing, trustline deep frozen
893 // by the holder
894 if (features[featureDeepFreeze])
895 {
896 env(trust(A1, limit, tfSetFreeze | tfSetDeepFreeze));
897 env.close();
898
899 // test: A1 cannot create passive buy offer
900 env(offer(A1, USD(1), XRP(0.5)), txflags(tfPassive), ter(tecFROZEN));
901 env.close();
902
903 // test: A1 cannot buy, must fail
904 env(offer(A1, USD(1), XRP(2)), txflags(tfFillOrKill), ter(tecFROZEN));
905 env.close();
906
907 // test: A1 cannot create passive sell offer
908 env(offer(A1, XRP(2), USD(1)), txflags(tfPassive), ter(tecUNFUNDED_OFFER));
909 env.close();
910
911 // test: A1 cannot sell to A3
912 env(offer(A1, XRP(1), USD(1)), txflags(tfFillOrKill), ter(tecUNFUNDED_OFFER));
913 env.close();
914
915 env(trust(A1, limit, tfClearFreeze | tfClearDeepFreeze));
916 env.close();
917 }
918 }
919
920 void
922 {
923 testcase("Longer paths payment on frozen trust lines");
924 using namespace test::jtx;
925 using path = test::jtx::path;
926
927 Env env(*this, features);
928 Account G1{"G1"};
929 Account A1{"A1"};
930 Account A2{"A2"};
931 auto const USD{G1["USD"]};
932
933 env.fund(XRP(10000), G1, A1, A2);
934 env.close();
935
936 auto const limit = USD(10000);
937 env.trust(limit, A1, A2);
938 env.close();
939
940 env(pay(G1, A1, USD(1000)));
941 env(pay(G1, A2, USD(1000)));
942 env.close();
943
944 env(offer(A2, XRP(100), USD(100)), txflags(tfPassive));
945 env.close();
946
947 // Testing payments A1 <-> G1 using offer from A2 frozen by issuer.
948 {
949 env(trust(G1, A2["USD"](0), tfSetFreeze));
950 env.close();
951
952 // test: A1 cannot send USD using XRP through A2 offer
953 env(pay(A1, G1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
954 env.close();
955
956 // test: G1 cannot send USD using XRP through A2 offer
957 env(pay(G1, A1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
958 env.close();
959
960 env(trust(G1, A2["USD"](0), tfClearFreeze));
961 env.close();
962 }
963
964 // Testing payments A1 <-> G1 using offer from A2 deep frozen by issuer.
965 if (features[featureDeepFreeze])
966 {
967 env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze));
968 env.close();
969
970 // test: A1 cannot send USD using XRP through A2 offer
971 env(pay(A1, G1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
972 env.close();
973
974 // test: G1 cannot send USD using XRP through A2 offer
975 env(pay(G1, A1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
976 env.close();
977
978 env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze));
979 env.close();
980 }
981
982 // Testing payments A1 <-> G1 using offer from A2 frozen by currency
983 // holder.
984 {
985 env(trust(A2, limit, tfSetFreeze));
986 env.close();
987
988 // test: A1 can send USD using XRP through A2 offer
989 env(pay(A1, G1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect));
990 env.close();
991
992 // test: G1 can send USD using XRP through A2 offer
993 env(pay(G1, A1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect));
994 env.close();
995
996 env(trust(A2, limit, tfClearFreeze));
997 env.close();
998 }
999
1000 // Testing payments A1 <-> G1 using offer from A2 deep frozen by
1001 // currency holder.
1002 if (features[featureDeepFreeze])
1003 {
1004 env(trust(A2, limit, tfSetFreeze | tfSetDeepFreeze));
1005 env.close();
1006
1007 // test: A1 cannot send USD using XRP through A2 offer
1008 env(pay(A1, G1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
1009 env.close();
1010
1011 // test: G1 cannot send USD using XRP through A2 offer
1012 env(pay(G1, A1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
1013 env.close();
1014
1015 env(trust(A2, limit, tfClearFreeze | tfClearDeepFreeze));
1016 env.close();
1017 }
1018
1019 // Cleanup
1020 env(offer_cancel(A1, env.seq(A1) - 1));
1021 env.require(offers(A1, 0));
1022 env.close();
1023
1024 env(offer(A2, USD(100), XRP(100)), txflags(tfPassive));
1025 env.close();
1026
1027 // Testing payments A1 <-> G1 using offer from A2 frozen by issuer.
1028 {
1029 env(trust(G1, A2["USD"](0), tfSetFreeze));
1030 env.close();
1031
1032 // test: A1 can send XRP using USD through A2 offer
1033 env(pay(A1, G1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect));
1034 env.close();
1035
1036 // test: G1 can send XRP using USD through A2 offer
1037 env(pay(G1, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect));
1038 env.close();
1039
1040 env(trust(G1, A2["USD"](0), tfClearFreeze));
1041 env.close();
1042 }
1043
1044 // Testing payments A1 <-> G1 using offer from A2 deep frozen by
1045 // issuer.
1046 if (features[featureDeepFreeze])
1047 {
1048 env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze));
1049 env.close();
1050
1051 // test: A1 cannot send XRP using USD through A2 offer
1052 env(pay(A1, G1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
1053 env.close();
1054
1055 // test: G1 cannot send XRP using USD through A2 offer
1056 env(pay(G1, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
1057 env.close();
1058
1059 env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze));
1060 env.close();
1061 }
1062
1063 // Testing payments A1 <-> G1 using offer from A2 frozen by currency
1064 // holder.
1065 {
1066 env(trust(A2, limit, tfSetFreeze));
1067 env.close();
1068
1069 // test: A1 can send XRP using USD through A2 offer
1070 env(pay(A1, G1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect));
1071 env.close();
1072
1073 // test: G1 can send XRP using USD through A2 offer
1074 env(pay(G1, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect));
1075 env.close();
1076
1077 env(trust(A2, limit, tfClearFreeze));
1078 env.close();
1079 }
1080
1081 // Testing payments A1 <-> G1 using offer from A2 deep frozen by
1082 // currency holder.
1083 if (features[featureDeepFreeze])
1084 {
1085 env(trust(A2, limit, tfSetFreeze | tfSetDeepFreeze));
1086 env.close();
1087
1088 // test: A1 cannot send XRP using USD through A2 offer
1089 env(pay(A1, G1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
1090 env.close();
1091
1092 // test: G1 cannot send XRP using USD through A2 offer
1093 env(pay(G1, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL));
1094 env.close();
1095
1096 env(trust(A2, limit, tfClearFreeze | tfClearDeepFreeze));
1097 env.close();
1098 }
1099
1100 // Cleanup
1101 env(offer_cancel(A1, env.seq(A1) - 1));
1102 env.require(offers(A1, 0));
1103 env.close();
1104 }
1105
1106 void
1108 {
1109 testcase("Direct payments on frozen trust lines");
1110
1111 using namespace test::jtx;
1112 Env env(*this, features);
1113
1114 Account G1{"G1"};
1115 Account A1{"A1"};
1116 Account A2{"A2"};
1117 auto const USD{G1["USD"]};
1118
1119 env.fund(XRP(10000), G1, A1, A2);
1120 env.close();
1121
1122 auto const limit = USD(10000);
1123 env.trust(limit, A1, A2);
1124 env.close();
1125
1126 env(pay(G1, A1, USD(1000)));
1127 env(pay(G1, A2, USD(1000)));
1128 env.close();
1129
1130 // Checking payments before freeze
1131 // To issuer:
1132 env(pay(A1, G1, USD(1)));
1133 env(pay(A2, G1, USD(1)));
1134 env.close();
1135
1136 // To each other:
1137 env(pay(A1, A2, USD(1)));
1138 env(pay(A2, A1, USD(1)));
1139 env.close();
1140
1141 // Freeze A1
1142 env(trust(G1, A1["USD"](0), tfSetFreeze));
1143 env.close();
1144
1145 // Issuer and A1 can send payments to each other
1146 env(pay(A1, G1, USD(1)));
1147 env(pay(G1, A1, USD(1)));
1148 env.close();
1149
1150 // A1 cannot send tokens to A2
1151 env(pay(A1, A2, USD(1)), ter(tecPATH_DRY));
1152
1153 // A2 can still send to A1
1154 env(pay(A2, A1, USD(1)));
1155 env.close();
1156
1157 if (features[featureDeepFreeze])
1158 {
1159 // Deep freeze A1
1160 env(trust(G1, A1["USD"](0), tfSetDeepFreeze));
1161 env.close();
1162
1163 // Issuer and A1 can send payments to each other
1164 env(pay(A1, G1, USD(1)));
1165 env(pay(G1, A1, USD(1)));
1166 env.close();
1167
1168 // A1 cannot send tokens to A2
1169 env(pay(A1, A2, USD(1)), ter(tecPATH_DRY));
1170
1171 // A2 cannot send tokens to A1
1172 env(pay(A2, A1, USD(1)), ter(tecPATH_DRY));
1173
1174 // Clear deep freeze on A1
1175 env(trust(G1, A1["USD"](0), tfClearDeepFreeze));
1176 env.close();
1177 }
1178
1179 // Clear freeze on A1
1180 env(trust(G1, A1["USD"](0), tfClearFreeze));
1181 env.close();
1182
1183 // A1 freezes trust line
1184 env(trust(A1, limit, tfSetFreeze));
1185 env.close();
1186
1187 // Issuer and A2 must not be affected
1188 env(pay(A2, G1, USD(1)));
1189 env(pay(G1, A2, USD(1)));
1190 env.close();
1191
1192 // A1 can send tokens to the issuer
1193 env(pay(A1, G1, USD(1)));
1194 env.close();
1195 // A1 can send tokens to A2
1196 env(pay(A1, A2, USD(1)));
1197 env.close();
1198
1199 // Issuer can sent tokens to A1
1200 env(pay(G1, A1, USD(1)));
1201 // A2 cannot send tokens to A1
1202 env(pay(A2, A1, USD(1)), ter(tecPATH_DRY));
1203
1204 if (features[featureDeepFreeze])
1205 {
1206 // A1 deep freezes trust line
1207 env(trust(A1, limit, tfSetDeepFreeze));
1208 env.close();
1209
1210 // Issuer and A2 must not be affected
1211 env(pay(A2, G1, USD(1)));
1212 env(pay(G1, A2, USD(1)));
1213 env.close();
1214
1215 // A1 can still send token to issuer
1216 env(pay(A1, G1, USD(1)));
1217 env.close();
1218
1219 // Issuer can send tokens to A1
1220 env(pay(G1, A1, USD(1)));
1221 // A2 cannot send tokens to A1
1222 env(pay(A2, A1, USD(1)), ter(tecPATH_DRY));
1223 // A1 cannot send tokens to A2
1224 env(pay(A1, A2, USD(1)), ter(tecPATH_DRY));
1225 }
1226 }
1227
1228 void
1230 {
1231 testcase("Checks on frozen trust lines");
1232
1233 using namespace test::jtx;
1234 Env env(*this, features);
1235
1236 Account G1{"G1"};
1237 Account A1{"A1"};
1238 Account A2{"A2"};
1239 auto const USD{G1["USD"]};
1240
1241 env.fund(XRP(10000), G1, A1, A2);
1242 env.close();
1243
1244 auto const limit = USD(10000);
1245 env.trust(limit, A1, A2);
1246 env.close();
1247
1248 env(pay(G1, A1, USD(1000)));
1249 env(pay(G1, A2, USD(1000)));
1250 env.close();
1251
1252 // Confirming we can write and cash checks
1253 {
1254 uint256 const checkId{getCheckIndex(G1, env.seq(G1))};
1255 env(check::create(G1, A1, USD(10)));
1256 env.close();
1257 env(check::cash(A1, checkId, USD(10)));
1258 env.close();
1259 }
1260
1261 {
1262 uint256 const checkId{getCheckIndex(G1, env.seq(G1))};
1263 env(check::create(G1, A2, USD(10)));
1264 env.close();
1265 env(check::cash(A2, checkId, USD(10)));
1266 env.close();
1267 }
1268
1269 {
1270 uint256 const checkId{getCheckIndex(A1, env.seq(A1))};
1271 env(check::create(A1, G1, USD(10)));
1272 env.close();
1273 env(check::cash(G1, checkId, USD(10)));
1274 env.close();
1275 }
1276
1277 {
1278 uint256 const checkId{getCheckIndex(A1, env.seq(A1))};
1279 env(check::create(A1, A2, USD(10)));
1280 env.close();
1281 env(check::cash(A2, checkId, USD(10)));
1282 env.close();
1283 }
1284
1285 {
1286 uint256 const checkId{getCheckIndex(A2, env.seq(A2))};
1287 env(check::create(A2, G1, USD(10)));
1288 env.close();
1289 env(check::cash(G1, checkId, USD(10)));
1290 env.close();
1291 }
1292
1293 {
1294 uint256 const checkId{getCheckIndex(A2, env.seq(A2))};
1295 env(check::create(A2, A1, USD(10)));
1296 env.close();
1297 env(check::cash(A1, checkId, USD(10)));
1298 env.close();
1299 }
1300
1301 // Testing creation and cashing of checks on a trustline frozen by
1302 // issuer
1303 {
1304 env(trust(G1, A1["USD"](0), tfSetFreeze));
1305 env.close();
1306
1307 // test: issuer writes check to A1.
1308 {
1309 uint256 const checkId{getCheckIndex(G1, env.seq(G1))};
1310 env(check::create(G1, A1, USD(10)));
1311 env.close();
1312 env(check::cash(A1, checkId, USD(10)), ter(tecFROZEN));
1313 env.close();
1314 }
1315
1316 // test: A2 writes check to A1.
1317 {
1318 uint256 const checkId{getCheckIndex(A2, env.seq(A2))};
1319 env(check::create(A2, A1, USD(10)));
1320 env.close();
1321 // Same as previous test
1322 env(check::cash(A1, checkId, USD(10)), ter(tecFROZEN));
1323 env.close();
1324 }
1325
1326 // test: A1 writes check to issuer
1327 {
1328 env(check::create(A1, G1, USD(10)), ter(tecFROZEN));
1329 env.close();
1330 }
1331
1332 // test: A1 writes check to A2
1333 {
1334 // Same as previous test
1335 env(check::create(A1, A2, USD(10)), ter(tecFROZEN));
1336 env.close();
1337 }
1338
1339 // Unfreeze the trustline to create a couple of checks so that we
1340 // could try to cash them later when the trustline is frozen again.
1341 env(trust(G1, A1["USD"](0), tfClearFreeze));
1342 env.close();
1343
1344 uint256 const checkId1{getCheckIndex(A1, env.seq(A1))};
1345 env(check::create(A1, G1, USD(10)));
1346 env.close();
1347 uint256 const checkId2{getCheckIndex(A1, env.seq(A1))};
1348 env(check::create(A1, A2, USD(10)));
1349 env.close();
1350
1351 env(trust(G1, A1["USD"](0), tfSetFreeze));
1352 env.close();
1353
1354 // test: issuer tries to cash the check from A1
1355 {
1356 env(check::cash(G1, checkId1, USD(10)), ter(tecPATH_PARTIAL));
1357 env.close();
1358 }
1359
1360 // test: A2 tries to cash the check from A1
1361 {
1362 env(check::cash(A2, checkId2, USD(10)), ter(tecPATH_PARTIAL));
1363 env.close();
1364 }
1365
1366 env(trust(G1, A1["USD"](0), tfClearFreeze));
1367 env.close();
1368 }
1369
1370 // Testing creation and cashing of checks on a trustline deep frozen by
1371 // issuer
1372 if (features[featureDeepFreeze])
1373 {
1374 env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze));
1375 env.close();
1376
1377 // test: issuer writes check to A1.
1378 {
1379 uint256 const checkId{getCheckIndex(G1, env.seq(G1))};
1380 env(check::create(G1, A1, USD(10)));
1381 env.close();
1382
1383 env(check::cash(A1, checkId, USD(10)), ter(tecFROZEN));
1384 env.close();
1385 }
1386
1387 // test: A2 writes check to A1.
1388 {
1389 uint256 const checkId{getCheckIndex(A2, env.seq(A2))};
1390 env(check::create(A2, A1, USD(10)));
1391 env.close();
1392 // Same as previous test
1393 env(check::cash(A1, checkId, USD(10)), ter(tecFROZEN));
1394 env.close();
1395 }
1396
1397 // test: A1 writes check to issuer
1398 {
1399 env(check::create(A1, G1, USD(10)), ter(tecFROZEN));
1400 env.close();
1401 }
1402
1403 // test: A1 writes check to A2
1404 {
1405 // Same as previous test
1406 env(check::create(A1, A2, USD(10)), ter(tecFROZEN));
1407 env.close();
1408 }
1409
1410 // Unfreeze the trustline to create a couple of checks so that we
1411 // could try to cash them later when the trustline is frozen again.
1412 env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze));
1413 env.close();
1414
1415 uint256 const checkId1{getCheckIndex(A1, env.seq(A1))};
1416 env(check::create(A1, G1, USD(10)));
1417 env.close();
1418 uint256 const checkId2{getCheckIndex(A1, env.seq(A1))};
1419 env(check::create(A1, A2, USD(10)));
1420 env.close();
1421
1422 env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze));
1423 env.close();
1424
1425 // test: issuer tries to cash the check from A1
1426 {
1427 env(check::cash(G1, checkId1, USD(10)), ter(tecPATH_PARTIAL));
1428 env.close();
1429 }
1430
1431 // test: A2 tries to cash the check from A1
1432 {
1433 env(check::cash(A2, checkId2, USD(10)), ter(tecPATH_PARTIAL));
1434 env.close();
1435 }
1436
1437 env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze));
1438 env.close();
1439 }
1440
1441 // Testing creation and cashing of checks on a trustline frozen by
1442 // a currency holder
1443 {
1444 env(trust(A1, limit, tfSetFreeze));
1445 env.close();
1446
1447 // test: issuer writes check to A1.
1448 {
1449 env(check::create(G1, A1, USD(10)), ter(tecFROZEN));
1450 env.close();
1451 }
1452
1453 // test: A2 writes check to A1.
1454 {
1455 env(check::create(A2, A1, USD(10)), ter(tecFROZEN));
1456 env.close();
1457 }
1458
1459 // test: A1 writes check to issuer
1460 {
1461 uint256 const checkId{getCheckIndex(A1, env.seq(A1))};
1462 env(check::create(A1, G1, USD(10)));
1463 env.close();
1464 env(check::cash(G1, checkId, USD(10)));
1465 env.close();
1466 }
1467
1468 // test: A1 writes check to A2
1469 {
1470 uint256 const checkId{getCheckIndex(A1, env.seq(A1))};
1471 env(check::create(A1, A2, USD(10)));
1472 env.close();
1473 env(check::cash(A2, checkId, USD(10)));
1474 env.close();
1475 }
1476
1477 env(trust(A1, limit, tfClearFreeze));
1478 env.close();
1479 }
1480
1481 // Testing creation and cashing of checks on a trustline deep frozen by
1482 // a currency holder
1483 if (features[featureDeepFreeze])
1484 {
1485 env(trust(A1, limit, tfSetFreeze | tfSetDeepFreeze));
1486 env.close();
1487
1488 // test: issuer writes check to A1.
1489 {
1490 env(check::create(G1, A1, USD(10)), ter(tecFROZEN));
1491 env.close();
1492 }
1493
1494 // test: A2 writes check to A1.
1495 {
1496 env(check::create(A2, A1, USD(10)), ter(tecFROZEN));
1497 env.close();
1498 }
1499
1500 // test: A1 writes check to issuer
1501 {
1502 uint256 const checkId{getCheckIndex(A1, env.seq(A1))};
1503 env(check::create(A1, G1, USD(10)));
1504 env.close();
1505 env(check::cash(G1, checkId, USD(10)), ter(tecPATH_PARTIAL));
1506 env.close();
1507 }
1508
1509 // test: A1 writes check to A2
1510 {
1511 uint256 const checkId{getCheckIndex(A1, env.seq(A1))};
1512 env(check::create(A1, A2, USD(10)));
1513 env.close();
1514 env(check::cash(A2, checkId, USD(10)), ter(tecPATH_PARTIAL));
1515 env.close();
1516 }
1517
1518 env(trust(A1, limit, tfClearFreeze | tfClearDeepFreeze));
1519 env.close();
1520 }
1521 }
1522
1523 void
1525 {
1526 testcase("AMM payments on frozen trust lines");
1527 using namespace test::jtx;
1528 using path = test::jtx::path;
1529
1530 Env env(*this, features);
1531 Account G1{"G1"};
1532 Account A1{"A1"};
1533 Account A2{"A2"};
1534 auto const USD{G1["USD"]};
1535
1536 env.fund(XRP(10000), G1, A1, A2);
1537 env.close();
1538
1539 env.trust(G1["USD"](10000), A1, A2);
1540 env.close();
1541
1542 env(pay(G1, A1, USD(1000)));
1543 env(pay(G1, A2, USD(1000)));
1544 env.close();
1545
1546 AMM ammG1(env, G1, XRP(1'000), USD(1'000));
1547 env.close();
1548
1549 // Testing basic payment using AMM when freezing one of the trust lines.
1550 {
1551 env(trust(G1, A1["USD"](0), tfSetFreeze));
1552 env.close();
1553
1554 // test: can still use XRP to make payment
1555 env(pay(A1, A2, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect));
1556 env.close();
1557
1558 // test: cannot use USD to make payment
1559 env(pay(A1, A2, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect), ter(tecPATH_DRY));
1560 env.close();
1561
1562 // test: can still receive USD payments.
1563 env(pay(A2, A1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect));
1564 env.close();
1565
1566 // test: can still receive XRP payments.
1567 env(pay(A2, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect));
1568 env.close();
1569
1570 env(trust(G1, A1["USD"](0), tfClearFreeze));
1571 env.close();
1572 }
1573
1574 // Testing basic payment using AMM when deep freezing one of the trust
1575 // lines.
1576 if (features[featureDeepFreeze])
1577 {
1578 env(trust(G1, A1["USD"](0), tfSetFreeze | tfSetDeepFreeze));
1579 env.close();
1580
1581 // test: can still use XRP to make payment
1582 env(pay(A1, A2, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect));
1583 env.close();
1584
1585 // test: cannot use USD to make payment
1586 env(pay(A1, A2, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect), ter(tecPATH_DRY));
1587 env.close();
1588
1589 // test: cannot receive USD payments.
1590 env(pay(A2, A1, USD(10)), path(~USD), sendmax(XRP(11)), txflags(tfNoRippleDirect), ter(tecPATH_DRY));
1591 env.close();
1592
1593 // test: can still receive XRP payments.
1594 env(pay(A2, A1, XRP(10)), path(~XRP), sendmax(USD(11)), txflags(tfNoRippleDirect));
1595 env.close();
1596
1597 env(trust(G1, A1["USD"](0), tfClearFreeze | tfClearDeepFreeze));
1598 env.close();
1599 }
1600 }
1601
1602 void
1604 {
1605 testcase("NFT offers on frozen trust lines");
1606 using namespace test::jtx;
1607
1608 Env env(*this, features);
1609 Account G1{"G1"};
1610 Account A1{"A1"};
1611 Account A2{"A2"};
1612 auto const USD{G1["USD"]};
1613
1614 env.fund(XRP(10000), G1, A1, A2);
1615 env.close();
1616
1617 auto const limit = USD(10000);
1618 env.trust(limit, A1, A2);
1619 env.close();
1620
1621 env(pay(G1, A1, USD(1000)));
1622 env(pay(G1, A2, USD(1000)));
1623 env.close();
1624
1625 // Testing A2 nft offer sell when A2 frozen by issuer
1626 {
1627 auto const sellOfferIndex = createNFTSellOffer(env, A2, USD(10));
1628 env(trust(G1, A2["USD"](0), tfSetFreeze));
1629 env.close();
1630
1631 // test: A2 can still receive USD for his NFT
1632 env(token::acceptSellOffer(A1, sellOfferIndex));
1633 env.close();
1634
1635 env(trust(G1, A2["USD"](0), tfClearFreeze));
1636 env.close();
1637 }
1638
1639 // Testing A2 nft offer sell when A2 deep frozen by issuer
1640 if (features[featureDeepFreeze])
1641 {
1642 auto const sellOfferIndex = createNFTSellOffer(env, A2, USD(10));
1643
1644 env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze));
1645 env.close();
1646
1647 // test: A2 cannot receive USD for his NFT
1648 env(token::acceptSellOffer(A1, sellOfferIndex), ter(tecFROZEN));
1649 env.close();
1650
1651 env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze));
1652 env.close();
1653 }
1654
1655 // Testing A1 nft offer sell when A2 frozen by issuer
1656 {
1657 auto const sellOfferIndex = createNFTSellOffer(env, A1, USD(10));
1658 env(trust(G1, A2["USD"](0), tfSetFreeze));
1659 env.close();
1660
1661 // test: A2 cannot send USD for NFT
1662 env(token::acceptSellOffer(A2, sellOfferIndex), ter(tecINSUFFICIENT_FUNDS));
1663 env.close();
1664
1665 env(trust(G1, A2["USD"](0), tfClearFreeze));
1666 env.close();
1667 }
1668
1669 // Testing A1 nft offer sell when A2 deep frozen by issuer
1670 if (features[featureDeepFreeze])
1671 {
1672 auto const sellOfferIndex = createNFTSellOffer(env, A1, USD(10));
1673 env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze));
1674 env.close();
1675
1676 // test: A2 cannot send USD for NFT
1677 env(token::acceptSellOffer(A2, sellOfferIndex), ter(tecINSUFFICIENT_FUNDS));
1678 env.close();
1679
1680 env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze));
1681 env.close();
1682 }
1683
1684 // Testing A1 nft buy offer when A2 deep frozen by issuer
1685 if (features[featureDeepFreeze] && features[fixEnforceNFTokenTrustlineV2])
1686 {
1687 env(trust(G1, A2["USD"](0), tfSetFreeze | tfSetDeepFreeze));
1688 env.close();
1689
1690 uint256 const nftID{token::getNextID(env, A2, 0u, tfTransferable)};
1691 env(token::mint(A2, 0), txflags(tfTransferable));
1692 env.close();
1693
1694 auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key;
1695 env(token::createOffer(A1, nftID, USD(10)), token::owner(A2));
1696 env.close();
1697
1698 env(token::acceptBuyOffer(A2, buyIdx), ter(tecFROZEN));
1699 env.close();
1700
1701 env(trust(G1, A2["USD"](0), tfClearFreeze | tfClearDeepFreeze));
1702 env.close();
1703
1704 env(token::acceptBuyOffer(A2, buyIdx));
1705 env.close();
1706 }
1707
1708 // Testing A2 nft offer sell when A2 frozen by currency holder
1709 {
1710 auto const sellOfferIndex = createNFTSellOffer(env, A2, USD(10));
1711 env(trust(A2, limit, tfSetFreeze));
1712 env.close();
1713
1714 // test: offer can still be accepted.
1715 env(token::acceptSellOffer(A1, sellOfferIndex));
1716 env.close();
1717
1718 env(trust(A2, limit, tfClearFreeze));
1719 env.close();
1720 }
1721
1722 // Testing A2 nft offer sell when A2 deep frozen by currency holder
1723 if (features[featureDeepFreeze])
1724 {
1725 auto const sellOfferIndex = createNFTSellOffer(env, A2, USD(10));
1726
1727 env(trust(A2, limit, tfSetFreeze | tfSetDeepFreeze));
1728 env.close();
1729
1730 // test: A2 cannot receive USD for his NFT
1731 env(token::acceptSellOffer(A1, sellOfferIndex), ter(tecFROZEN));
1732 env.close();
1733
1734 env(trust(A2, limit, tfClearFreeze | tfClearDeepFreeze));
1735 env.close();
1736 }
1737
1738 // Testing A1 nft offer sell when A2 frozen by currency holder
1739 {
1740 auto const sellOfferIndex = createNFTSellOffer(env, A1, USD(10));
1741 env(trust(A2, limit, tfSetFreeze));
1742 env.close();
1743
1744 // test: A2 cannot send USD for NFT
1745 env(token::acceptSellOffer(A2, sellOfferIndex));
1746 env.close();
1747
1748 env(trust(A2, limit, tfClearFreeze));
1749 env.close();
1750 }
1751
1752 // Testing A1 nft offer sell when A2 deep frozen by currency holder
1753 if (features[featureDeepFreeze])
1754 {
1755 auto const sellOfferIndex = createNFTSellOffer(env, A1, USD(10));
1756 env(trust(A2, limit, tfSetFreeze | tfSetDeepFreeze));
1757 env.close();
1758
1759 // test: A2 cannot send USD for NFT
1760 env(token::acceptSellOffer(A2, sellOfferIndex), ter(tecINSUFFICIENT_FUNDS));
1761 env.close();
1762
1763 env(trust(A2, limit, tfClearFreeze | tfClearDeepFreeze));
1764 env.close();
1765 }
1766
1767 // Testing brokered offer acceptance
1768 if (features[featureDeepFreeze] && features[fixEnforceNFTokenTrustlineV2])
1769 {
1770 Account broker{"broker"};
1771 env.fund(XRP(10000), broker);
1772 env.close();
1773 env(trust(G1, broker["USD"](1000), tfSetFreeze | tfSetDeepFreeze));
1774 env.close();
1775
1776 uint256 const nftID{token::getNextID(env, A2, 0u, tfTransferable)};
1777 env(token::mint(A2, 0), txflags(tfTransferable));
1778 env.close();
1779
1780 uint256 const sellIdx = keylet::nftoffer(A2, env.seq(A2)).key;
1781 env(token::createOffer(A2, nftID, USD(10)), txflags(tfSellNFToken));
1782 env.close();
1783 auto const buyIdx = keylet::nftoffer(A1, env.seq(A1)).key;
1784 env(token::createOffer(A1, nftID, USD(11)), token::owner(A2));
1785 env.close();
1786
1787 env(token::brokerOffers(broker, buyIdx, sellIdx), token::brokerFee(USD(1)), ter(tecFROZEN));
1788 env.close();
1789 }
1790
1791 // Testing transfer fee
1792 if (features[featureDeepFreeze] && features[fixEnforceNFTokenTrustlineV2])
1793 {
1794 Account minter{"minter"};
1795 env.fund(XRP(10000), minter);
1796 env.close();
1797 env(trust(G1, minter["USD"](1000)));
1798 env.close();
1799
1800 uint256 const nftID{token::getNextID(env, minter, 0u, tfTransferable, 1u)};
1801 env(token::mint(minter, 0), token::xferFee(1u), txflags(tfTransferable));
1802 env.close();
1803
1804 uint256 const minterSellIdx = keylet::nftoffer(minter, env.seq(minter)).key;
1805 env(token::createOffer(minter, nftID, drops(1)), txflags(tfSellNFToken));
1806 env.close();
1807 env(token::acceptSellOffer(A2, minterSellIdx));
1808 env.close();
1809
1810 uint256 const sellIdx = keylet::nftoffer(A2, env.seq(A2)).key;
1811 env(token::createOffer(A2, nftID, USD(100)), txflags(tfSellNFToken));
1812 env.close();
1813 env(trust(G1, minter["USD"](1000), tfSetFreeze | tfSetDeepFreeze));
1814 env.close();
1815 env(token::acceptSellOffer(A1, sellIdx), ter(tecFROZEN));
1816 env.close();
1817 }
1818 }
1819
1820 // Helper function to extract trustline flags from open ledger
1821 uint32_t
1822 getTrustlineFlags(test::jtx::Env& env, size_t expectedArraySize, size_t expectedArrayIndex, bool modified = true)
1823 {
1824 using namespace test::jtx;
1825 auto const affected = env.meta()->getJson(JsonOptions::none)[sfAffectedNodes.fieldName];
1826 if (!BEAST_EXPECT(checkArraySize(affected, expectedArraySize)))
1827 return 0;
1828
1829 if (modified)
1830 {
1831 return affected[expectedArrayIndex][sfModifiedNode.fieldName][sfFinalFields.fieldName][jss::Flags].asUInt();
1832 }
1833
1834 return affected[expectedArrayIndex][sfCreatedNode.fieldName][sfNewFields.fieldName][jss::Flags].asUInt();
1835 }
1836
1837 // Helper function that returns the index of the next check on account
1838 uint256
1839 getCheckIndex(AccountID const& account, std::uint32_t uSequence)
1840 {
1841 return keylet::check(account, uSequence).key;
1842 }
1843
1844 uint256
1846 {
1847 using namespace test::jtx;
1848 uint256 const nftID{token::getNextID(env, account, 0u, tfTransferable)};
1849 env(token::mint(account, 0), txflags(tfTransferable));
1850 env.close();
1851
1852 uint256 const sellOfferIndex = keylet::nftoffer(account, env.seq(account)).key;
1853 env(token::createOffer(account, nftID, currency), txflags(tfSellNFToken));
1854 env.close();
1855
1856 return sellOfferIndex;
1857 }
1858
1859public:
1860 void
1861 run() override
1862 {
1863 auto testAll = [this](FeatureBitset features) {
1864 testRippleState(features);
1865 testDeepFreeze(features);
1866 testCreateFrozenTrustline(features);
1867 testSetAndClear(features);
1868 testGlobalFreeze(features);
1869 testNoFreeze(features);
1870 testOffersWhenFrozen(features);
1871 testOffersWhenDeepFrozen(features);
1873 testChecksWhenFrozen(features);
1874 testAMMWhenFreeze(features);
1875 testPathsWhenFrozen(features);
1876 testNFTOffersWhenFreeze(features);
1877 };
1878 using namespace test::jtx;
1879 auto const sa = testable_amendments();
1880 testAll(sa - featureDeepFreeze - featurePermissionedDEX - fixEnforceNFTokenTrustlineV2);
1881 testAll(sa - featurePermissionedDEX - fixEnforceNFTokenTrustlineV2);
1882 testAll(sa - featureDeepFreeze - featurePermissionedDEX);
1883 testAll(sa - featurePermissionedDEX);
1884 testAll(sa - fixEnforceNFTokenTrustlineV2);
1885 testAll(sa - featureDeepFreeze);
1886 testAll(sa);
1887 }
1888};
1889
1890BEAST_DEFINE_TESTSUITE(Freeze, app, xrpl);
1891} // namespace xrpl
Represents a JSON value.
Definition json_value.h:131
A testsuite class.
Definition suite.h:52
testcase_t testcase
Memberspace for declaring test cases.
Definition suite.h:148
void testOffersWhenDeepFrozen(FeatureBitset features)
void testSetAndClear(FeatureBitset features)
void testChecksWhenFrozen(FeatureBitset features)
void testPathsWhenFrozen(FeatureBitset features)
uint256 createNFTSellOffer(test::jtx::Env &env, test::jtx::Account const &account, test::jtx::PrettyAmount const &currency)
uint32_t getTrustlineFlags(test::jtx::Env &env, size_t expectedArraySize, size_t expectedArrayIndex, bool modified=true)
void testOffersWhenFrozen(FeatureBitset features)
void run() override
Runs the suite.
void testNoFreeze(FeatureBitset features)
void testAMMWhenFreeze(FeatureBitset features)
void testNFTOffersWhenFreeze(FeatureBitset features)
void testGlobalFreeze(FeatureBitset features)
void testRippleState(FeatureBitset features)
uint256 getCheckIndex(AccountID const &account, std::uint32_t uSequence)
void testCreateFrozenTrustline(FeatureBitset features)
void testPaymentsWhenDeepFrozen(FeatureBitset features)
void testDeepFreeze(FeatureBitset features)
A currency issued by an account.
Definition Issue.h:14
Immutable cryptographic account descriptor.
Definition Account.h:20
A transaction testing environment.
Definition Env.h:98
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:97
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:239
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
Definition Env.cpp:450
Add a path.
Definition paths.h:38
T clear(T... args)
T end(T... args)
T find(T... args)
T insert(T... args)
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition Indexes.cpp:375
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Definition Indexes.cpp:293
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
constexpr std::uint32_t const tfTransferable
Definition TxFlags.h:123
constexpr std::uint32_t asfGlobalFreeze
Definition TxFlags.h:64
constexpr std::uint32_t tfPassive
Definition TxFlags.h:79
constexpr std::uint32_t tfFillOrKill
Definition TxFlags.h:81
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
constexpr std::uint32_t tfClearFreeze
Definition TxFlags.h:100
constexpr std::uint32_t tfClearDeepFreeze
Definition TxFlags.h:102
constexpr std::uint32_t tfSetDeepFreeze
Definition TxFlags.h:101
constexpr std::uint32_t tfNoRippleDirect
Definition TxFlags.h:88
constexpr std::uint32_t asfNoFreeze
Definition TxFlags.h:63
AccountID const & noAccount()
A placeholder for empty accounts.
@ temINVALID_FLAG
Definition TER.h:92
@ tecPATH_PARTIAL
Definition TER.h:264
@ tecPATH_DRY
Definition TER.h:276
@ tecFROZEN
Definition TER.h:285
@ tecINSUFFICIENT_FUNDS
Definition TER.h:307
@ tecUNFUNDED_OFFER
Definition TER.h:266
@ tecKILLED
Definition TER.h:298
@ tecNO_PERMISSION
Definition TER.h:287
@ lsfLowDeepFreeze
@ lsfLowFreeze
@ lsfHighFreeze
@ lsfHighDeepFreeze
bool to_currency(Currency &, std::string const &)
Tries to convert a string to a Currency, returns true on success.
Definition UintTypes.cpp:62
constexpr std::uint32_t const tfSellNFToken
Definition TxFlags.h:211
constexpr std::uint32_t tfSetFreeze
Definition TxFlags.h:99
uint256 key
Definition Keylet.h:21
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...