rippled
DepositAuth_test.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2017 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/protocol/Feature.h>
21 #include <test/jtx.h>
22 
23 namespace ripple {
24 namespace test {
25 
26 // Helper function that returns the reserve on an account based on
27 // the passed in number of owners.
29 {
30  return env.current()->fees().accountReserve (count);
31 }
32 
33 // Helper function that returns true if acct has the lsfDepostAuth flag set.
34 static bool hasDepositAuth (jtx::Env const& env, jtx::Account const& acct)
35 {
36  return ((*env.le(acct))[sfFlags] & lsfDepositAuth) == lsfDepositAuth;
37 }
38 
39 
40 struct DepositAuth_test : public beast::unit_test::suite
41 {
42  void testEnable()
43  {
44  testcase ("Enable");
45 
46  using namespace jtx;
47  Account const alice {"alice"};
48 
49  {
50  // featureDepositAuth is disabled.
52  env.fund (XRP (10000), alice);
53 
54  // Note that, to support old behavior, invalid flags are ignored.
55  env (fset (alice, asfDepositAuth));
56  env.close();
57  BEAST_EXPECT (! hasDepositAuth (env, alice));
58 
59  env (fclear (alice, asfDepositAuth));
60  env.close();
61  BEAST_EXPECT (! hasDepositAuth (env, alice));
62  }
63  {
64  // featureDepositAuth is enabled.
65  Env env (*this);
66  env.fund (XRP (10000), alice);
67 
68  env (fset (alice, asfDepositAuth));
69  env.close();
70  BEAST_EXPECT (hasDepositAuth (env, alice));
71 
72  env (fclear (alice, asfDepositAuth));
73  env.close();
74  BEAST_EXPECT (! hasDepositAuth (env, alice));
75  }
76  }
77 
78  void testPayIOU()
79  {
80  // Exercise IOU payments and non-direct XRP payments to an account
81  // that has the lsfDepositAuth flag set.
82  testcase ("Pay IOU");
83 
84  using namespace jtx;
85  Account const alice {"alice"};
86  Account const bob {"bob"};
87  Account const carol {"carol"};
88  Account const gw {"gw"};
89  IOU const USD = gw["USD"];
90 
91  Env env (*this);
92 
93  env.fund (XRP (10000), alice, bob, carol, gw);
94  env.trust (USD (1000), alice, bob);
95  env.close();
96 
97  env (pay (gw, alice, USD (150)));
98  env (offer (carol, USD(100), XRP(100)));
99  env.close();
100 
101  // Make sure bob's trust line is all set up so he can receive USD.
102  env (pay (alice, bob, USD (50)));
103  env.close();
104 
105  // bob sets the lsfDepositAuth flag.
106  env (fset (bob, asfDepositAuth), require(flags (bob, asfDepositAuth)));
107  env.close();
108 
109  // None of the following payments should succeed.
110  auto failedIouPayments = [this, &env, &alice, &bob, &USD] ()
111  {
112  env.require (flags (bob, asfDepositAuth));
113 
114  // Capture bob's balances before hand to confirm they don't change.
115  PrettyAmount const bobXrpBalance {env.balance (bob, XRP)};
116  PrettyAmount const bobUsdBalance {env.balance (bob, USD)};
117 
118  env (pay (alice, bob, USD (50)), ter (tecNO_PERMISSION));
119  env.close();
120 
121  // Note that even though alice is paying bob in XRP, the payment
122  // is still not allowed since the payment passes through an offer.
123  env (pay (alice, bob, drops(1)),
124  sendmax (USD (1)), ter (tecNO_PERMISSION));
125  env.close();
126 
127  BEAST_EXPECT (bobXrpBalance == env.balance (bob, XRP));
128  BEAST_EXPECT (bobUsdBalance == env.balance (bob, USD));
129  };
130 
131  // Test when bob has an XRP balance > base reserve.
132  failedIouPayments();
133 
134  // Set bob's XRP balance == base reserve. Also demonstrate that
135  // bob can make payments while his lsfDepositAuth flag is set.
136  env (pay (bob, alice, USD(25)));
137  env.close();
138 
139  {
140  STAmount const bobPaysXRP {
141  env.balance (bob, XRP) - reserve (env, 1)};
142  XRPAmount const bobPaysFee {reserve (env, 1) - reserve (env, 0)};
143  env (pay (bob, alice, bobPaysXRP), fee (bobPaysFee));
144  env.close();
145  }
146 
147  // Test when bob's XRP balance == base reserve.
148  BEAST_EXPECT (env.balance (bob, XRP) == reserve (env, 0));
149  BEAST_EXPECT (env.balance (bob, USD) == USD(25));
150  failedIouPayments();
151 
152  // Test when bob has an XRP balance == 0.
153  env (noop (bob), fee (reserve (env, 0)));
154  env.close ();
155 
156  BEAST_EXPECT (env.balance (bob, XRP) == XRP (0));
157  failedIouPayments();
158 
159  // Give bob enough XRP for the fee to clear the lsfDepositAuth flag.
160  env (pay (alice, bob, drops(env.current()->fees().base)));
161 
162  // bob clears the lsfDepositAuth and the next payment succeeds.
163  env (fclear (bob, asfDepositAuth));
164  env.close();
165 
166  env (pay (alice, bob, USD (50)));
167  env.close();
168 
169  env (pay (alice, bob, drops(1)), sendmax (USD (1)));
170  env.close();
171  }
172 
173  void testPayXRP()
174  {
175  // Exercise direct XRP payments to an account that has the
176  // lsfDepositAuth flag set.
177  testcase ("Pay XRP");
178 
179  using namespace jtx;
180  Account const alice {"alice"};
181  Account const bob {"bob"};
182 
183  Env env (*this);
184 
185  env.fund (XRP (10000), alice, bob);
186 
187  // bob sets the lsfDepositAuth flag.
188  env (fset (bob, asfDepositAuth), fee (drops (10)));
189  env.close();
190  BEAST_EXPECT (env.balance (bob, XRP) == XRP (10000) - drops(10));
191 
192  // bob has more XRP than the base reserve. Any XRP payment should fail.
193  env (pay (alice, bob, drops(1)), ter (tecNO_PERMISSION));
194  env.close();
195  BEAST_EXPECT (env.balance (bob, XRP) == XRP (10000) - drops(10));
196 
197  // Change bob's XRP balance to exactly the base reserve.
198  {
199  STAmount const bobPaysXRP {
200  env.balance (bob, XRP) - reserve (env, 1)};
201  XRPAmount const bobPaysFee {reserve (env, 1) - reserve (env, 0)};
202  env (pay (bob, alice, bobPaysXRP), fee (bobPaysFee));
203  env.close();
204  }
205 
206  // bob has exactly the base reserve. A small enough direct XRP
207  // payment should succeed.
208  BEAST_EXPECT (env.balance (bob, XRP) == reserve (env, 0));
209  env (pay (alice, bob, drops(1)));
210  env.close();
211 
212  // bob has exactly the base reserve + 1. No payment should succeed.
213  BEAST_EXPECT (env.balance (bob, XRP) == reserve (env, 0) + drops(1));
214  env (pay (alice, bob, drops(1)), ter (tecNO_PERMISSION));
215  env.close();
216 
217  // Take bob down to a balance of 0 XRP.
218  env (noop (bob), fee (reserve (env, 0) + drops(1)));
219  env.close ();
220  BEAST_EXPECT (env.balance (bob, XRP) == drops(0));
221 
222  // We should not be able to pay bob more than the base reserve.
223  env (pay (alice, bob, reserve (env, 0) + drops(1)),
225  env.close();
226 
227  // However a payment of exactly the base reserve should succeed.
228  env (pay (alice, bob, reserve (env, 0) + drops(0)));
229  env.close();
230  BEAST_EXPECT (env.balance (bob, XRP) == reserve (env, 0));
231 
232  // We should be able to pay bob the base reserve one more time.
233  env (pay (alice, bob, reserve (env, 0) + drops(0)));
234  env.close();
235  BEAST_EXPECT (env.balance (bob, XRP) ==
236  (reserve (env, 0) + reserve (env, 0)));
237 
238  // bob's above the threshold again. Any payment should fail.
239  env (pay (alice, bob, drops(1)), ter (tecNO_PERMISSION));
240  env.close();
241  BEAST_EXPECT (env.balance (bob, XRP) ==
242  (reserve (env, 0) + reserve (env, 0)));
243 
244  // Take bob back down to a zero XRP balance.
245  env (noop (bob), fee (env.balance (bob, XRP)));
246  env.close();
247  BEAST_EXPECT (env.balance (bob, XRP) == drops(0));
248 
249  // bob should not be able to clear lsfDepositAuth.
250  env (fclear (bob, asfDepositAuth), ter (terINSUF_FEE_B));
251  env.close();
252 
253  // We should be able to pay bob 1 drop now.
254  env (pay (alice, bob, drops(1)));
255  env.close();
256  BEAST_EXPECT (env.balance (bob, XRP) == drops(1));
257 
258  // Pay bob enough so he can afford the fee to clear lsfDepositAuth.
259  env (pay (alice, bob, drops(9)));
260  env.close();
261 
262  // Interestingly, at this point the terINSUF_FEE_B retry grabs the
263  // request to clear lsfDepositAuth. So the balance should be zero
264  // and lsfDepositAuth should be cleared.
265  BEAST_EXPECT (env.balance (bob, XRP) == drops(0));
266  env.require (nflags (bob, asfDepositAuth));
267 
268  // Since bob no longer has lsfDepositAuth set we should be able to
269  // pay him more than the base reserve.
270  env (pay (alice, bob, reserve (env, 0) + drops(1)));
271  env.close();
272  BEAST_EXPECT (env.balance (bob, XRP) == reserve (env, 0) + drops(1));
273  }
274 
276  {
277  // It its current incarnation the DepositAuth flag does not change
278  // any behaviors regarding rippling and the NoRipple flag.
279  // Demonstrate that.
280  testcase ("No Ripple");
281 
282  using namespace jtx;
283  Account const gw1 ("gw1");
284  Account const gw2 ("gw2");
285  Account const alice ("alice");
286  Account const bob ("bob");
287 
288  IOU const USD1 (gw1["USD"]);
289  IOU const USD2 (gw2["USD"]);
290 
291  auto testIssuer = [&] (FeatureBitset const& features,
292  bool noRipplePrev,
293  bool noRippleNext,
294  bool withDepositAuth)
295  {
296  assert(!withDepositAuth || features[featureDepositAuth]);
297 
298  Env env(*this, features);
299 
300  env.fund(XRP(10000), gw1, alice, bob);
301  env (trust (gw1, alice["USD"](10), noRipplePrev ? tfSetNoRipple : 0));
302  env (trust (gw1, bob["USD"](10), noRippleNext ? tfSetNoRipple : 0));
303  env.trust(USD1 (10), alice, bob);
304 
305  env(pay(gw1, alice, USD1(10)));
306 
307  if (withDepositAuth)
308  env(fset(gw1, asfDepositAuth));
309 
310  TER const result = (noRippleNext && noRipplePrev)
311  ? TER {tecPATH_DRY}
312  : TER {tesSUCCESS};
313  env (pay (alice, bob, USD1(10)), path (gw1), ter (result));
314  };
315 
316  auto testNonIssuer = [&] (FeatureBitset const& features,
317  bool noRipplePrev,
318  bool noRippleNext,
319  bool withDepositAuth)
320  {
321  assert(!withDepositAuth || features[featureDepositAuth]);
322 
323  Env env(*this, features);
324 
325  env.fund(XRP(10000), gw1, gw2, alice);
326  env (trust (alice, USD1(10), noRipplePrev ? tfSetNoRipple : 0));
327  env (trust (alice, USD2(10), noRippleNext ? tfSetNoRipple : 0));
328  env(pay(gw2, alice, USD2(10)));
329 
330  if (withDepositAuth)
331  env(fset(alice, asfDepositAuth));
332 
333  TER const result = (noRippleNext && noRipplePrev)
334  ? TER {tecPATH_DRY}
335  : TER {tesSUCCESS};
336  env (pay (gw1, gw2, USD2 (10)),
337  path (alice), sendmax (USD1 (10)), ter (result));
338  };
339 
340  // Test every combo of noRipplePrev, noRippleNext, and withDepositAuth
341  for (int i = 0; i < 8; ++i)
342  {
343  auto const noRipplePrev = i & 0x1;
344  auto const noRippleNext = i & 0x2;
345  auto const withDepositAuth = i & 0x4;
346  testIssuer(
348  noRipplePrev,
349  noRippleNext,
350  withDepositAuth);
351 
352  if (!withDepositAuth)
353  testIssuer(
355  noRipplePrev,
356  noRippleNext,
357  withDepositAuth);
358 
359  testNonIssuer(
361  noRipplePrev,
362  noRippleNext,
363  withDepositAuth);
364 
365  if (!withDepositAuth)
366  testNonIssuer(
368  noRipplePrev,
369  noRippleNext,
370  withDepositAuth);
371  }
372  }
373 
374  void run() override
375  {
376  testEnable();
377  testPayIOU();
378  testPayXRP();
379  testNoRipple();
380  }
381 };
382 
383 struct DepositPreauth_test : public beast::unit_test::suite
384 {
385  void testEnable()
386  {
387  testcase ("Enable");
388 
389  using namespace jtx;
390  Account const alice {"alice"};
391  Account const becky {"becky"};
392  {
393  // featureDepositPreauth is disabled.
395  env.fund (XRP (10000), alice, becky);
396  env.close();
397 
398  // Should not be able to add a DepositPreauth to alice.
399  env (deposit::auth (alice, becky), ter (temDISABLED));
400  env.close();
401  env.require (owners (alice, 0));
402  env.require (owners (becky, 0));
403 
404  // Should not be able to remove a DepositPreauth from alice.
405  env (deposit::unauth (alice, becky), ter (temDISABLED));
406  env.close();
407  env.require (owners (alice, 0));
408  env.require (owners (becky, 0));
409  }
410  {
411  // featureDepositPreauth is enabled. The valid case is really
412  // simple:
413  // o We should be able to add and remove an entry, and
414  // o That entry should cost one reserve.
415  // o The reserve should be returned when the entry is removed.
416  Env env (*this);
417  env.fund (XRP (10000), alice, becky);
418  env.close();
419 
420  // Add a DepositPreauth to alice.
421  env (deposit::auth (alice, becky));
422  env.close();
423  env.require (owners (alice, 1));
424  env.require (owners (becky, 0));
425 
426  // Remove a DepositPreauth from alice.
427  env (deposit::unauth (alice, becky));
428  env.close();
429  env.require (owners (alice, 0));
430  env.require (owners (becky, 0));
431  }
432  }
433 
434  void testInvalid()
435  {
436  testcase ("Invalid");
437 
438  using namespace jtx;
439  Account const alice {"alice"};
440  Account const becky {"becky"};
441  Account const carol {"carol"};
442 
443  Env env (*this);
444 
445  // Tell env about alice, becky and carol since they are not yet funded.
446  env.memoize (alice);
447  env.memoize (becky);
448  env.memoize (carol);
449 
450  // Add DepositPreauth to an unfunded account.
451  env (deposit::auth (alice, becky), seq (1), ter (terNO_ACCOUNT));
452 
453  env.fund (XRP (10000), alice, becky);
454  env.close();
455 
456  // Bad fee.
457  env (deposit::auth (alice, becky), fee (drops(-10)), ter (temBAD_FEE));
458  env.close();
459 
460  // Bad flags.
461  env (deposit::auth (alice, becky),
463  env.close();
464 
465  {
466  // Neither auth not unauth.
467  Json::Value tx {deposit::auth (alice, becky)};
469  env (tx, ter (temMALFORMED));
470  env.close();
471  }
472  {
473  // Both auth and unauth.
474  Json::Value tx {deposit::auth (alice, becky)};
475  tx[sfUnauthorize.jsonName] = becky.human();
476  env (tx, ter (temMALFORMED));
477  env.close();
478  }
479  {
480  // Alice authorizes a zero account.
481  Json::Value tx {deposit::auth (alice, becky)};
483  env (tx, ter (temINVALID_ACCOUNT_ID));
484  env.close();
485  }
486 
487  // alice authorizes herself.
488  env (deposit::auth (alice, alice), ter (temCANNOT_PREAUTH_SELF));
489  env.close();
490 
491  // alice authorizes an unfunded account.
492  env (deposit::auth (alice, carol), ter (tecNO_TARGET));
493  env.close();
494 
495  // alice successfully authorizes becky.
496  env.require (owners (alice, 0));
497  env.require (owners (becky, 0));
498  env (deposit::auth (alice, becky));
499  env.close();
500  env.require (owners (alice, 1));
501  env.require (owners (becky, 0));
502 
503  // alice attempts to create a duplicate authorization.
504  env (deposit::auth (alice, becky), ter (tecDUPLICATE));
505  env.close();
506  env.require (owners (alice, 1));
507  env.require (owners (becky, 0));
508 
509  // carol attempts to preauthorize but doesn't have enough reserve.
510  env.fund (drops (249'999'999), carol);
511  env.close();
512 
513  env (deposit::auth (carol, becky), ter (tecINSUFFICIENT_RESERVE));
514  env.close();
515  env.require (owners (carol, 0));
516  env.require (owners (becky, 0));
517 
518  // carol gets enough XRP to (barely) meet the reserve.
519  env (pay (alice, carol, drops (11)));
520  env.close();
521  env (deposit::auth (carol, becky));
522  env.close();
523  env.require (owners (carol, 1));
524  env.require (owners (becky, 0));
525 
526  // But carol can't meet the reserve for another preauthorization.
527  env (deposit::auth (carol, alice), ter (tecINSUFFICIENT_RESERVE));
528  env.close();
529  env.require (owners (carol, 1));
530  env.require (owners (becky, 0));
531  env.require (owners (alice, 1));
532 
533  // alice attempts to remove an authorization she doesn't have.
534  env (deposit::unauth (alice, carol), ter (tecNO_ENTRY));
535  env.close();
536  env.require (owners (alice, 1));
537  env.require (owners (becky, 0));
538 
539  // alice successfully removes her authorization of becky.
540  env (deposit::unauth (alice, becky));
541  env.close();
542  env.require (owners (alice, 0));
543  env.require (owners (becky, 0));
544 
545  // alice removes becky again and gets an error.
546  env (deposit::unauth (alice, becky), ter (tecNO_ENTRY));
547  env.close();
548  env.require (owners (alice, 0));
549  env.require (owners (becky, 0));
550  }
551 
552  void testPayment (FeatureBitset features)
553  {
554  testcase ("Payment");
555 
556  using namespace jtx;
557  Account const alice {"alice"};
558  Account const becky {"becky"};
559  Account const gw {"gw"};
560  IOU const USD (gw["USD"]);
561 
562  bool const supportsPreauth = {features[featureDepositPreauth]};
563 
564  {
565  // The initial implementation of DepositAuth had a bug where an
566  // account with the DepositAuth flag set could not make a payment
567  // to itself. That bug was fixed in the DepositPreauth amendment.
568  Env env (*this, features);
569  env.fund (XRP (5000), alice, becky, gw);
570  env.close();
571 
572  env.trust (USD (1000), alice);
573  env.trust (USD (1000), becky);
574  env.close();
575 
576  env (pay (gw, alice, USD (500)));
577  env.close();
578 
579  env (offer (alice, XRP (100), USD (100), tfPassive),
580  require (offers (alice, 1)));
581  env.close();
582 
583  // becky pays herself USD (10) by consuming part of alice's offer.
584  // Make sure the payment works if PaymentAuth is not involved.
585  env (pay (becky, becky, USD (10)),
586  path (~USD), sendmax (XRP (10)));
587  env.close();
588 
589  // becky decides to require authorization for deposits.
590  env(fset (becky, asfDepositAuth));
591  env.close();
592 
593  // becky pays herself again. Whether it succeeds depends on
594  // whether featureDepositPreauth is enabled.
595  TER const expect {
596  supportsPreauth ? TER {tesSUCCESS} : TER {tecNO_PERMISSION}};
597 
598  env (pay (becky, becky, USD (10)),
599  path (~USD), sendmax (XRP (10)), ter (expect));
600  env.close();
601  }
602 
603  if (supportsPreauth)
604  {
605  // Make sure DepositPreauthorization works for payments.
606 
607  Account const carol {"carol"};
608 
609  Env env (*this, features);
610  env.fund (XRP (5000), alice, becky, carol, gw);
611  env.close();
612 
613  env.trust (USD (1000), alice);
614  env.trust (USD (1000), becky);
615  env.trust (USD (1000), carol);
616  env.close();
617 
618  env (pay (gw, alice, USD (1000)));
619  env.close();
620 
621  // Make XRP and IOU payments from alice to becky. Should be fine.
622  env (pay (alice, becky, XRP (100)));
623  env (pay (alice, becky, USD (100)));
624  env.close();
625 
626  // becky decides to require authorization for deposits.
627  env(fset (becky, asfDepositAuth));
628  env.close();
629 
630  // alice can no longer pay becky.
631  env (pay (alice, becky, XRP (100)), ter (tecNO_PERMISSION));
632  env (pay (alice, becky, USD (100)), ter (tecNO_PERMISSION));
633  env.close();
634 
635  // becky preauthorizes carol for deposit, which doesn't provide
636  // authorization for alice.
637  env (deposit::auth (becky, carol));
638  env.close();
639 
640  // alice still can't pay becky.
641  env (pay (alice, becky, XRP (100)), ter (tecNO_PERMISSION));
642  env (pay (alice, becky, USD (100)), ter (tecNO_PERMISSION));
643  env.close();
644 
645  // becky preauthorizes alice for deposit.
646  env (deposit::auth (becky, alice));
647  env.close();
648 
649  // alice can now pay becky.
650  env (pay (alice, becky, XRP (100)));
651  env (pay (alice, becky, USD (100)));
652  env.close();
653 
654  // alice decides to require authorization for deposits.
655  env(fset (alice, asfDepositAuth));
656  env.close();
657 
658  // Even though alice is authorized to pay becky, becky is not
659  // authorized to pay alice.
660  env (pay (becky, alice, XRP (100)), ter (tecNO_PERMISSION));
661  env (pay (becky, alice, USD (100)), ter (tecNO_PERMISSION));
662  env.close();
663 
664  // becky unauthorizes carol. Should have no impact on alice.
665  env (deposit::unauth (becky, carol));
666  env.close();
667 
668  env (pay (alice, becky, XRP (100)));
669  env (pay (alice, becky, USD (100)));
670  env.close();
671 
672  // becky unauthorizes alice. alice now can't pay becky.
673  env (deposit::unauth (becky, alice));
674  env.close();
675 
676  env (pay (alice, becky, XRP (100)), ter (tecNO_PERMISSION));
677  env (pay (alice, becky, USD (100)), ter (tecNO_PERMISSION));
678  env.close();
679 
680  // becky decides to remove authorization for deposits. Now
681  // alice can pay becky again.
682  env(fclear (becky, asfDepositAuth));
683  env.close();
684 
685  env (pay (alice, becky, XRP (100)));
686  env (pay (alice, becky, USD (100)));
687  env.close();
688  }
689  }
690 
691  void run() override
692  {
693  testEnable();
694  testInvalid();
696  testPayment (jtx::supported_amendments());
697  }
698 };
699 
700 BEAST_DEFINE_TESTSUITE(DepositAuth,app,ripple);
702 
703 } // test
704 } // ripple
ripple::test::jtx::noop
Json::Value noop(Account const &account)
The null transaction.
Definition: noop.h:32
ripple::test::jtx::XRP
const XRP_t XRP
Converts to XRP Issue or STAmount.
Definition: amount.cpp:109
ripple::test::DepositAuth_test::testNoRipple
void testNoRipple()
Definition: DepositAuth_test.cpp:275
ripple::tecNO_TARGET
@ tecNO_TARGET
Definition: TER.h:269
ripple::test::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(AccountDelete, app, ripple)
ripple::test::DepositPreauth_test::run
void run() override
Definition: DepositAuth_test.cpp:691
ripple::test::jtx::drops
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
Definition: amount.h:261
ripple::terINSUF_FEE_B
@ terINSUF_FEE_B
Definition: TER.h:194
ripple::test::jtx::ter
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition: ter.h:33
ripple::test::jtx::owners
Match the number of items in the account's owner directory.
Definition: owners.h:73
ripple::test::jtx::Env::require
void require(Args const &... args)
Check a set of requirements.
Definition: Env.h:461
ripple::test::DepositAuth_test
Definition: DepositAuth_test.cpp:40
ripple::featureDepositPreauth
const uint256 featureDepositPreauth
Definition: Feature.cpp:169
ripple::test::jtx::trust
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition: trust.cpp:30
ripple::tfPassive
const std::uint32_t tfPassive
Definition: TxFlags.h:76
ripple::sfFlags
const SF_U32 sfFlags(access, STI_UINT32, 2, "Flags")
Definition: SField.h:338
ripple::featureDepositAuth
const uint256 featureDepositAuth
Definition: Feature.cpp:164
ripple::test::jtx::require
Check a set of conditions.
Definition: require.h:66
ripple::DepositPreauth
Definition: DepositPreauth.h:27
ripple::temCANNOT_PREAUTH_SELF
@ temCANNOT_PREAUTH_SELF
Definition: TER.h:118
ripple::test::DepositPreauth_test::testPayment
void testPayment(FeatureBitset features)
Definition: DepositAuth_test.cpp:552
ripple::asfDepositAuth
const std::uint32_t asfDepositAuth
Definition: TxFlags.h:73
ripple::sfUnauthorize
const SF_Account sfUnauthorize(access, STI_ACCOUNT, 6, "Unauthorize")
Definition: SField.h:465
ripple::test::jtx::Env::balance
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition: Env.cpp:162
ripple::to_string
std::string to_string(ListDisposition disposition)
Definition: ValidatorList.cpp:41
ripple::test::jtx::offer
Json::Value offer(Account const &account, STAmount const &in, STAmount const &out, std::uint32_t flags)
Create an offer.
Definition: offer.cpp:28
ripple::test::DepositAuth_test::testEnable
void testEnable()
Definition: DepositAuth_test.cpp:42
ripple::SField::jsonName
const Json::StaticString jsonName
Definition: SField.h:140
ripple::test::jtx::Env::trust
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition: Env.cpp:245
ripple::lsfDepositAuth
@ lsfDepositAuth
Definition: LedgerFormats.h:140
ripple::test::DepositAuth_test::run
void run() override
Definition: DepositAuth_test.cpp:374
ripple::temINVALID_FLAG
@ temINVALID_FLAG
Definition: TER.h:109
ripple::test::hasDepositAuth
static bool hasDepositAuth(jtx::Env const &env, jtx::Account const &acct)
Definition: DepositAuth_test.cpp:34
ripple::tecDUPLICATE
@ tecDUPLICATE
Definition: TER.h:280
ripple::TERSubset< CanCvtToTER >
ripple::test::jtx::sendmax
Sets the SendMax on a JTx.
Definition: sendmax.h:31
ripple::test::jtx::fset
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition: flags.cpp:28
ripple::test::reserve
static XRPAmount reserve(jtx::Env &env, std::uint32_t count)
Definition: DepositAuth_test.cpp:28
ripple::test::jtx::txflags
Set the flags on a JTx.
Definition: txflags.h:30
ripple::STAmount
Definition: STAmount.h:42
ripple::xrpAccount
AccountID const & xrpAccount()
Compute AccountID from public key.
Definition: AccountID.cpp:149
ripple::test::DepositAuth_test::testPayIOU
void testPayIOU()
Definition: DepositAuth_test.cpp:78
ripple::test::jtx::path
Add a path.
Definition: paths.h:58
ripple::test::jtx::supported_amendments
FeatureBitset supported_amendments()
Definition: Env.h:71
std::uint32_t
ripple::temBAD_FEE
@ temBAD_FEE
Definition: TER.h:90
ripple::test::jtx::fclear
Json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
Definition: flags.h:42
ripple::test::jtx::fee
Set the fee on a JTx.
Definition: fee.h:34
ripple::terNO_ACCOUNT
@ terNO_ACCOUNT
Definition: TER.h:195
ripple::test::DepositPreauth_test::testInvalid
void testInvalid()
Definition: DepositAuth_test.cpp:434
ripple::test::jtx::seq
Set the sequence number on a JTx.
Definition: seq.h:32
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::tfSetNoRipple
const std::uint32_t tfSetNoRipple
Definition: TxFlags.h:90
ripple::tfSell
const std::uint32_t tfSell
Definition: TxFlags.h:79
ripple::test::jtx::flags
Match set account flags.
Definition: flags.h:99
ripple::temINVALID_ACCOUNT_ID
@ temINVALID_ACCOUNT_ID
Definition: TER.h:117
Json::Value::removeMember
Value removeMember(const char *key)
Remove and return the named member.
Definition: json_value.cpp:936
ripple::test::jtx::IOU
Converts to IOU Issue or STAmount.
Definition: amount.h:312
ripple::test::jtx::pay
Json::Value pay(Account const &account, Account const &to, AnyAmount amount)
Create a payment.
Definition: pay.cpp:29
ripple::temDISABLED
@ temDISABLED
Definition: TER.h:112
ripple::test::jtx::Env::close
void close(NetClock::time_point closeTime, boost::optional< std::chrono::milliseconds > consensusDelay=boost::none)
Close and advance the ledger.
Definition: Env.cpp:114
ripple::test::jtx::Env::fund
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition: Env.cpp:214
ripple::test::jtx::Env::le
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition: Env.cpp:202
ripple::tecNO_PERMISSION
@ tecNO_PERMISSION
Definition: TER.h:270
ripple::FeatureBitset
Definition: Feature.h:153
ripple::tecPATH_DRY
@ tecPATH_DRY
Definition: TER.h:259
ripple::tecINSUFFICIENT_RESERVE
@ tecINSUFFICIENT_RESERVE
Definition: TER.h:272
ripple::test::jtx::nflags
Match clear account flags.
Definition: flags.h:118
ripple::test::DepositPreauth_test::testEnable
void testEnable()
Definition: DepositAuth_test.cpp:385
ripple::test::jtx::Account
Immutable cryptographic account descriptor.
Definition: Account.h:37
ripple::test::DepositAuth_test::testPayXRP
void testPayXRP()
Definition: DepositAuth_test.cpp:173
ripple::test::DepositPreauth_test
Definition: DepositAuth_test.cpp:383
ripple::tecNO_ENTRY
@ tecNO_ENTRY
Definition: TER.h:271
ripple::temMALFORMED
@ temMALFORMED
Definition: TER.h:85
ripple::sfAuthorize
const SF_Account sfAuthorize(access, STI_ACCOUNT, 5, "Authorize")
Definition: SField.h:464
ripple::test::jtx::Env::memoize
void memoize(Account const &account)
Associate AccountID with account.
Definition: Env.cpp:135
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:219
ripple::test::jtx::Env::current
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition: Env.h:296
ripple::test::jtx::Env
A transaction testing environment.
Definition: Env.h:117
Json::Value
Represents a JSON value.
Definition: json_value.h:141
ripple::test::jtx::PrettyAmount
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
Definition: amount.h:73
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::test::jtx::owner_count
Definition: owners.h:50