xrpld
Loading...
Searching...
No Matches
AccountDelete_test.cpp
1
2#include <test/jtx/Account.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/TestHelpers.h>
5#include <test/jtx/acctdelete.h>
6#include <test/jtx/amount.h>
7#include <test/jtx/balance.h>
8#include <test/jtx/check.h>
9#include <test/jtx/credentials.h>
10#include <test/jtx/deposit.h>
11#include <test/jtx/did.h>
12#include <test/jtx/escrow.h>
13#include <test/jtx/fee.h>
14#include <test/jtx/flags.h>
15#include <test/jtx/multisign.h>
16#include <test/jtx/noop.h>
17#include <test/jtx/offer.h>
18#include <test/jtx/owners.h>
19#include <test/jtx/pay.h>
20#include <test/jtx/regkey.h>
21#include <test/jtx/sig.h>
22#include <test/jtx/ter.h>
23#include <test/jtx/ticket.h>
24#include <test/jtx/trust.h>
25#include <test/jtx/txflags.h>
26#include <test/jtx/vault.h>
27
28#include <xrpl/basics/base_uint.h>
29#include <xrpl/basics/chrono.h>
30#include <xrpl/basics/strHex.h>
31#include <xrpl/beast/unit_test/suite.h>
32#include <xrpl/json/json_value.h>
33#include <xrpl/json/to_string.h>
34#include <xrpl/ledger/ReadView.h>
35#include <xrpl/protocol/ErrorCodes.h>
36#include <xrpl/protocol/Feature.h>
37#include <xrpl/protocol/Indexes.h>
38#include <xrpl/protocol/Issue.h>
39#include <xrpl/protocol/Keylet.h>
40#include <xrpl/protocol/PublicKey.h>
41#include <xrpl/protocol/SField.h>
42#include <xrpl/protocol/STAmount.h>
43#include <xrpl/protocol/SeqProxy.h>
44#include <xrpl/protocol/TER.h>
45#include <xrpl/protocol/TxFlags.h>
46#include <xrpl/protocol/jss.h>
47
48#include <chrono>
49#include <cstdint>
50#include <memory>
51#include <string>
52
53namespace xrpl::test {
54
56{
57private:
58 // Helper function that verifies the expected DeliveredAmount is present.
59 //
60 // NOTE: the function _infers_ the transaction to operate on by calling
61 // env.tx(), which returns the result from the most recent transaction.
62 void
64 {
65 // Get the hash for the most recent transaction.
66 std::string const txHash{
67 env.tx()->getJson(JsonOptions::Values::None)[jss::hash].asString(),
68 };
69
70 // Verify DeliveredAmount and delivered_amount metadata are correct.
71 // We can't use env.meta() here, because meta() doesn't include
72 // delivered_amount.
73 env.close();
74 json::Value const txResult = env.rpc("tx", txHash)[jss::result];
75 json::Value const meta = txResult[jss::meta];
76
77 // Expect there to be a DeliveredAmount field.
78 if (!BEAST_EXPECT(meta.isMember(sfDeliveredAmount.jsonName)))
79 return;
80
81 // DeliveredAmount and delivered_amount should both be present and
82 // equal amount.
83 json::Value const jsonExpect{amount.getJson(JsonOptions::Values::None)};
84 BEAST_EXPECT(meta[sfDeliveredAmount.jsonName] == jsonExpect);
85 BEAST_EXPECT(meta[jss::delivered_amount] == jsonExpect);
86
87 // The `ledger` RPC (with expanded transactions) should also report
88 // delivered_amount for this transaction, matching the `tx` RPC.
89 json::Value ledgerParams;
90 ledgerParams[jss::ledger_index] = txResult[jss::ledger_index].asUInt();
91 ledgerParams[jss::transactions] = true;
92 ledgerParams[jss::expand] = true;
93
94 auto const ledgerResult = env.rpc("json", "ledger", to_string(ledgerParams));
95 auto const& ledgerTx = ledgerResult[jss::result][jss::ledger][jss::transactions][0u];
96 BEAST_EXPECT(ledgerTx[jss::hash].asString() == txHash);
97
98 json::Value const& ledgerMeta = ledgerTx[jss::metaData];
99 BEAST_EXPECT(ledgerMeta[sfDeliveredAmount.jsonName] == jsonExpect);
100 BEAST_EXPECT(ledgerMeta[jss::delivered_amount] == jsonExpect);
101 }
102
103 // Helper function to create a payment channel.
104 static json::Value
106 jtx::Account const& account,
107 jtx::Account const& to,
108 STAmount const& amount,
109 NetClock::duration const& settleDelay,
110 NetClock::time_point const& cancelAfter,
111 PublicKey const& pk)
112 {
113 json::Value jv;
114 jv[jss::TransactionType] = jss::PaymentChannelCreate;
115 jv[jss::Account] = account.human();
116 jv[jss::Destination] = to.human();
117 jv[jss::Amount] = amount.getJson(JsonOptions::Values::None);
118 jv[sfSettleDelay.jsonName] = settleDelay.count();
119 jv[sfCancelAfter.jsonName] = cancelAfter.time_since_epoch().count() + 2;
120 jv[sfPublicKey.jsonName] = strHex(pk.slice());
121 return jv;
122 };
123
124public:
125 void
127 {
128 using namespace jtx;
129
130 testcase("Basics");
131
132 Env env{*this};
133 Account const alice("alice");
134 Account const becky("becky");
135 Account const carol("carol");
136 Account const gw("gw");
137
138 env.fund(XRP(10000), alice, becky, carol, gw);
139 env.close();
140
141 // Alice can't delete her account and then give herself the XRP.
142 env(acctdelete(alice, alice), Ter(temDST_IS_SRC));
143
144 // alice can't delete her account with a negative fee.
145 env(acctdelete(alice, becky), Fee(drops(-1)), Ter(temBAD_FEE));
146
147 // Invalid flags.
148 env(acctdelete(alice, becky), Txflags(tfImmediateOrCancel), Ter(temINVALID_FLAG));
149
150 // Account deletion has a high fee. Make sure the fee requirement
151 // behaves as we expect.
152 auto const acctDelFee{drops(env.current()->fees().increment)};
153 env(acctdelete(alice, becky), Ter(telINSUF_FEE_P));
154
155 // Try a fee one drop less than the required amount.
156 env(acctdelete(alice, becky), Fee(acctDelFee - drops(1)), Ter(telINSUF_FEE_P));
157
158 // alice's account is created too recently to be deleted.
159 env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON));
160
161 // Give becky a trustline. She is no longer deletable.
162 env(trust(becky, gw["USD"](1000)));
163 env.close();
164
165 // Give carol a deposit pre-authorization, an offer, a ticket,
166 // a signer list, and a DID. Even with all that she's still deletable.
167 env(deposit::auth(carol, becky));
168 std::uint32_t const carolOfferSeq{env.seq(carol)};
169 env(offer(carol, gw["USD"](51), XRP(51)));
170 std::uint32_t const carolTicketSeq{env.seq(carol) + 1};
171 env(ticket::create(carol, 1));
172 env(signers(carol, 1, {{alice, 1}, {becky, 1}}));
173 env(did::setValid(carol));
174
175 // Deleting should fail with TOO_SOON, which is a relatively
176 // cheap check compared to validating the contents of her directory.
177 env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON));
178
179 // Close enough ledgers to almost be able to delete alice's account.
180 incLgrSeqForAccDel(env, alice, 1);
181
182 // alice's account is still created too recently to be deleted.
183 env(acctdelete(alice, becky), Fee(acctDelFee), Ter(tecTOO_SOON));
184
185 // The most recent delete attempt advanced alice's sequence. So
186 // close two ledgers and her account should be deletable.
187 env.close();
188 env.close();
189
190 {
191 auto const aliceOldBalance{env.balance(alice)};
192 auto const beckyOldBalance{env.balance(becky)};
193
194 // Verify that alice's account exists but she has no directory.
195 BEAST_EXPECT(env.closed()->exists(keylet::account(alice.id())));
196 BEAST_EXPECT(!env.closed()->exists(keylet::ownerDir(alice.id())));
197
198 env(acctdelete(alice, becky), Fee(acctDelFee));
199 verifyDeliveredAmount(env, aliceOldBalance - acctDelFee);
200 env.close();
201
202 // Verify that alice's account and directory are actually gone.
203 BEAST_EXPECT(!env.closed()->exists(keylet::account(alice.id())));
204 BEAST_EXPECT(!env.closed()->exists(keylet::ownerDir(alice.id())));
205
206 // Verify that alice's XRP, minus the fee, was transferred to becky.
207 BEAST_EXPECT(env.balance(becky) == aliceOldBalance + beckyOldBalance - acctDelFee);
208 }
209
210 // Attempt to delete becky's account but get stopped by the trust line.
211 env(acctdelete(becky, carol), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
212 env.close();
213
214 // Verify that becky's account is still there by giving her a regular
215 // key. This has the side effect of setting the lsfPasswordSpent bit
216 // on her account root.
217 Account const beck("beck");
218 env(regkey(becky, beck), Fee(drops(0)));
219 env.close();
220
221 // Show that the lsfPasswordSpent bit is set by attempting to change
222 // becky's regular key for free again. That fails.
223 Account const reb("reb");
224 env(regkey(becky, reb), Sig(becky), Fee(drops(0)), Ter(telINSUF_FEE_P));
225
226 // Close enough ledgers that becky's failing regkey transaction is
227 // no longer retried.
228 for (int i = 0; i < 8; ++i)
229 env.close();
230
231 {
232 auto const beckyOldBalance{env.balance(becky)};
233 auto const carolOldBalance{env.balance(carol)};
234
235 // Verify that Carol's account, directory, deposit
236 // pre-authorization, offer, ticket, and signer list exist.
237 BEAST_EXPECT(env.closed()->exists(keylet::account(carol.id())));
238 BEAST_EXPECT(env.closed()->exists(keylet::ownerDir(carol.id())));
239 BEAST_EXPECT(env.closed()->exists(keylet::depositPreauth(carol.id(), becky.id())));
240 BEAST_EXPECT(env.closed()->exists(
241 keylet::offer(carol.id(), SeqProxy::rawSequence(carolOfferSeq))));
242 BEAST_EXPECT(env.closed()->exists(
243 keylet::ticket(carol.id(), SeqProxy::rawTicket(carolTicketSeq))));
244 BEAST_EXPECT(env.closed()->exists(keylet::signerList(carol.id())));
245
246 // Delete carol's account even with stuff in her directory. Show
247 // that multisigning for the delete does not increase carol's fee.
248 env(acctdelete(carol, becky), Fee(acctDelFee), Msig(alice));
249 verifyDeliveredAmount(env, carolOldBalance - acctDelFee);
250 env.close();
251
252 // Verify that Carol's account, directory, and other stuff are gone.
253 BEAST_EXPECT(!env.closed()->exists(keylet::account(carol.id())));
254 BEAST_EXPECT(!env.closed()->exists(keylet::ownerDir(carol.id())));
255 BEAST_EXPECT(!env.closed()->exists(keylet::depositPreauth(carol.id(), becky.id())));
256 BEAST_EXPECT(!env.closed()->exists(
257 keylet::offer(carol.id(), SeqProxy::rawSequence(carolOfferSeq))));
258 BEAST_EXPECT(!env.closed()->exists(
259 keylet::ticket(carol.id(), SeqProxy::rawTicket(carolTicketSeq))));
260 BEAST_EXPECT(!env.closed()->exists(keylet::signerList(carol.id())));
261
262 // Verify that Carol's XRP, minus the fee, was transferred to becky.
263 BEAST_EXPECT(env.balance(becky) == carolOldBalance + beckyOldBalance - acctDelFee);
264
265 // Since becky received an influx of XRP, her lsfPasswordSpent bit
266 // is cleared and she can change her regular key for free again.
267 env(regkey(becky, reb), Sig(becky), Fee(drops(0)));
268 }
269 }
270
271 void
273 {
274 // The code that deletes consecutive directory entries uses a
275 // peculiarity of the implementation. Make sure that peculiarity
276 // behaves as expected across owner directory pages.
277 using namespace jtx;
278
279 testcase("Directories");
280
281 Env env{*this};
282 Account const alice("alice");
283 Account const gw("gw");
284
285 env.fund(XRP(10000), alice, gw);
286 env.close();
287
288 // Alice creates enough offers to require two owner directories.
289 for (int i{0}; i < 45; ++i)
290 {
291 env(offer(alice, gw["USD"](1), XRP(1)));
292 env.close();
293 }
294 env.require(Offers(alice, 45));
295
296 // Close enough ledgers to be able to delete alice's account.
297 incLgrSeqForAccDel(env, alice);
298
299 // Verify that both directory nodes exist.
300 Keylet const aliceRootKey{keylet::ownerDir(alice.id())};
301 Keylet const alicePageKey{keylet::page(aliceRootKey, 1)};
302 BEAST_EXPECT(env.closed()->exists(aliceRootKey));
303 BEAST_EXPECT(env.closed()->exists(alicePageKey));
304
305 // Delete alice's account.
306 auto const acctDelFee{drops(env.current()->fees().increment)};
307 auto const aliceBalance{env.balance(alice)};
308 env(acctdelete(alice, gw), Fee(acctDelFee));
309 verifyDeliveredAmount(env, aliceBalance - acctDelFee);
310 env.close();
311
312 // Both of alice's directory nodes should be gone.
313 BEAST_EXPECT(!env.closed()->exists(aliceRootKey));
314 BEAST_EXPECT(!env.closed()->exists(alicePageKey));
315 }
316
317 void
319 {
320 using namespace jtx;
321
322 testcase("Owned types");
323
324 // We want to test PayChannels with the backlink.
325 Env env{*this, testableAmendments()};
326 Account const alice("alice");
327 Account const becky("becky");
328 Account const gw("gw");
329
330 env.fund(XRP(100000), alice, becky, gw);
331 env.close();
332
333 // Give alice and becky a bunch of offers that we have to search
334 // through before we figure out that there's a non-deletable
335 // entry in their directory.
336 for (int i{0}; i < 200; ++i)
337 {
338 env(offer(alice, gw["USD"](1), XRP(1)));
339 env(offer(becky, gw["USD"](1), XRP(1)));
340 env.close();
341 }
342 env.require(Offers(alice, 200));
343 env.require(Offers(becky, 200));
344
345 // Close enough ledgers to be able to delete alice's and becky's
346 // accounts.
347 incLgrSeqForAccDel(env, alice);
348 incLgrSeqForAccDel(env, becky);
349
350 // alice writes a check to becky. Until that check is cashed or
351 // canceled it will prevent alice's and becky's accounts from being
352 // deleted.
353 UInt256 const checkId = keylet::check(alice, SeqProxy::rawSequence(env.seq(alice))).key;
354 env(check::create(alice, becky, XRP(1)));
355 env.close();
356
357 auto const acctDelFee{drops(env.current()->fees().increment)};
358 env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
359 env(acctdelete(becky, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
360 env.close();
361
362 // Cancel the check, but add an escrow. Again, with the escrow
363 // on board, alice and becky should not be able to delete their
364 // accounts.
365 env(check::cancel(becky, checkId));
366 env.close();
367
368 using namespace std::chrono_literals;
369 std::uint32_t const escrowSeq{env.seq(alice)};
370 env(escrow::create(alice, becky, XRP(333)),
371 escrow::kFinishTime(env.now() + 3s),
372 escrow::kCancelTime(env.now() + 4s));
373 env.close();
374
375 // alice and becky should be unable to delete their accounts because
376 // of the escrow.
377 env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
378 env(acctdelete(becky, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
379 env.close();
380
381 // Now cancel the escrow, but create a payment channel between
382 // alice and becky.
383
384 bool const withTokenEscrow = env.current()->rules().enabled(featureTokenEscrow);
385 if (withTokenEscrow)
386 {
387 Account const gw1("gw1");
388 Account const carol("carol");
389 auto const usd = gw1["USD"];
390 env.fund(XRP(100000), carol, gw1);
391 env(fset(gw1, asfAllowTrustLineLocking));
392 env.close();
393 env.trust(usd(10000), carol);
394 env.close();
395 env(pay(gw1, carol, usd(100)));
396 env.close();
397
398 std::uint32_t const escrowSeq{env.seq(carol)};
399 env(escrow::create(carol, becky, usd(1)),
400 escrow::kFinishTime(env.now() + 3s),
401 escrow::kCancelTime(env.now() + 4s));
402 env.close();
403
404 incLgrSeqForAccDel(env, gw1);
405
406 env(acctdelete(gw1, becky), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
407 env.close();
408
409 env(escrow::cancel(becky, carol, escrowSeq));
410 env.close();
411 }
412
413 env(escrow::cancel(becky, alice, escrowSeq));
414 env.close();
415
416 Keylet const alicePayChanKey{
417 keylet::payChannel(alice, becky, SeqProxy::rawSequence(env.seq(alice))),
418 };
419
420 env(payChanCreate(alice, becky, XRP(57), 4s, env.now() + 2s, alice.pk()));
421 env.close();
422
423 // With the PayChannel in place becky and alice should not be
424 // able to delete her account
425 auto const beckyBalance{env.balance(becky)};
426 env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
427 env(acctdelete(becky, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
428 env.close();
429
430 // Alice cancels her PayChannel, which will leave her with only offers
431 // in her directory.
432
433 // Lambda to close a PayChannel.
434 auto const payChanClose =
435 [](jtx::Account const& account, Keylet const& payChanKeylet, PublicKey const& pk) {
436 json::Value jv;
437 jv[jss::TransactionType] = jss::PaymentChannelClaim;
438 jv[jss::Flags] = tfClose;
439 jv[jss::Account] = account.human();
440 jv[sfChannel.jsonName] = to_string(payChanKeylet.key);
441 jv[sfPublicKey.jsonName] = strHex(pk.slice());
442 return jv;
443 };
444 env(payChanClose(alice, alicePayChanKey, alice.pk()));
445 env.close();
446
447 // gw creates a PayChannel with alice as the destination, this should
448 // prevent alice from deleting her account.
449 Keylet const gwPayChanKey{
450 keylet::payChannel(gw, alice, SeqProxy::rawSequence(env.seq(gw))),
451 };
452
453 env(payChanCreate(gw, alice, XRP(68), 4s, env.now() + 2s, alice.pk()));
454 env.close();
455
456 // alice can't delete her account because of the PayChannel.
457 env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
458 env.close();
459
460 // alice closes the PayChannel which should (finally) allow her to
461 // delete her account.
462 env(payChanClose(alice, gwPayChanKey, alice.pk()));
463 env.close();
464
465 // Now alice can successfully delete her account.
466 auto const aliceBalance{env.balance(alice)};
467 env(acctdelete(alice, gw), Fee(acctDelFee));
468 verifyDeliveredAmount(env, aliceBalance - acctDelFee);
469 env.close();
470 }
471
472 void
474 {
475 // Put enough offers in an account that we refuse to delete the account.
476 using namespace jtx;
477
478 testcase("Too many offers");
479
480 Env env{*this};
481 Account const alice("alice");
482 Account const gw("gw");
483
484 // Fund alice well so she can afford the reserve on the offers.
485 env.fund(XRP(10000000), alice, gw);
486 env.close();
487
488 // To increase the number of Books affected, change the currency of
489 // each offer.
490 std::string currency{"AAA"};
491
492 // Alice creates 1001 offers. This is one greater than the number of
493 // directory entries an AccountDelete will remove.
494 std::uint32_t const offerSeq0{env.seq(alice)};
495 static constexpr int kOfferCount{1001};
496 for (int i{0}; i < kOfferCount; ++i)
497 {
498 env(offer(alice, gw[currency](1), XRP(1)));
499 env.close();
500
501 // Increment to next currency.
502 ++currency[0];
503 if (currency[0] > 'Z')
504 {
505 currency[0] = 'A';
506 ++currency[1];
507 }
508 if (currency[1] > 'Z')
509 {
510 currency[1] = 'A';
511 ++currency[2];
512 }
513 if (currency[2] > 'Z')
514 {
515 currency[0] = 'A';
516 currency[1] = 'A';
517 currency[2] = 'A';
518 }
519 }
520
521 // Close enough ledgers to be able to delete alice's account.
522 incLgrSeqForAccDel(env, alice);
523
524 // Verify the existence of the expected ledger entries.
525 Keylet const aliceOwnerDirKey{keylet::ownerDir(alice.id())};
526 {
527 std::shared_ptr<ReadView const> const closed{env.closed()};
528 BEAST_EXPECT(closed->exists(keylet::account(alice.id())));
529 BEAST_EXPECT(closed->exists(aliceOwnerDirKey));
530
531 // alice's directory nodes.
532 for (std::uint32_t i{0}; i < ((kOfferCount / 32) + 1); ++i)
533 BEAST_EXPECT(closed->exists(keylet::page(aliceOwnerDirKey, i)));
534
535 // alice's offers.
536 for (std::uint32_t i{0}; i < kOfferCount; ++i)
537 {
538 BEAST_EXPECT(closed->exists(
539 keylet::offer(alice.id(), SeqProxy::rawSequence(offerSeq0 + i))));
540 }
541 }
542
543 // Delete alice's account. Should fail because she has too many
544 // offers in her directory.
545 auto const acctDelFee{drops(env.current()->fees().increment)};
546
547 env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tefTOO_BIG));
548
549 // Cancel one of alice's offers. Then the account delete can succeed.
550 env.require(Offers(alice, kOfferCount));
551 env(offerCancel(alice, offerSeq0));
552 env.close();
553 env.require(Offers(alice, kOfferCount - 1));
554
555 // alice successfully deletes her account.
556 auto const alicePreDelBal{env.balance(alice)};
557 env(acctdelete(alice, gw), Fee(acctDelFee));
558 verifyDeliveredAmount(env, alicePreDelBal - acctDelFee);
559 env.close();
560
561 // Verify that alice's account root is gone as well as her directory
562 // nodes and all of her offers.
563 {
564 std::shared_ptr<ReadView const> const closed{env.closed()};
565 BEAST_EXPECT(!closed->exists(keylet::account(alice.id())));
566 BEAST_EXPECT(!closed->exists(aliceOwnerDirKey));
567
568 // alice's former directory nodes.
569 for (std::uint32_t i{0}; i < ((kOfferCount / 32) + 1); ++i)
570 BEAST_EXPECT(!closed->exists(keylet::page(aliceOwnerDirKey, i)));
571
572 // alice's former offers.
573 for (std::uint32_t i{0}; i < kOfferCount; ++i)
574 {
575 BEAST_EXPECT(!closed->exists(
576 keylet::offer(alice.id(), SeqProxy::rawSequence(offerSeq0 + i))));
577 }
578 }
579 }
580
581 void
583 {
584 // Show that a trust line that is implicitly created by offer crossing
585 // prevents an account from being deleted.
586 using namespace jtx;
587
588 testcase("Implicitly created trust line");
589
590 Env env{*this};
591 Account const alice{"alice"};
592 Account const gw{"gw"};
593 auto const bux{gw["BUX"]};
594
595 env.fund(XRP(10000), alice, gw);
596 env.close();
597
598 // alice creates an offer that, if crossed, will implicitly create
599 // a trust line.
600 env(offer(alice, bux(30), XRP(30)));
601 env.close();
602
603 // gw crosses alice's offer. alice should end up with BUX(30).
604 env(offer(gw, XRP(30), bux(30)));
605 env.close();
606 env.require(Balance(alice, bux(30)));
607
608 // Close enough ledgers to be able to delete alice's account.
609 incLgrSeqForAccDel(env, alice);
610
611 // alice and gw can't delete their accounts because of the implicitly
612 // created trust line.
613 auto const acctDelFee{drops(env.current()->fees().increment)};
614 env(acctdelete(alice, gw), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
615 env.close();
616
617 env(acctdelete(gw, alice), Fee(acctDelFee), Ter(tecHAS_OBLIGATIONS));
618 env.close();
619 {
620 std::shared_ptr<ReadView const> const closed{env.closed()};
621 BEAST_EXPECT(closed->exists(keylet::account(alice.id())));
622 BEAST_EXPECT(closed->exists(keylet::account(gw.id())));
623 }
624 }
625
626 void
628 {
629 // See what happens when an account with a balance less than the
630 // incremental reserve tries to delete itself.
631 using namespace jtx;
632
633 testcase("Balance too small for fee");
634
635 Env env{*this};
636 Account const alice("alice");
637
638 // Note that the fee structure for unit tests does not match the fees
639 // on the production network (October 2019). Unit tests have a base
640 // reserve of 200 XRP.
641 env.fund(env.current()->fees().reserve, noripple(alice));
642 env.close();
643
644 // Burn a chunk of alice's funds so she only has 1 XRP remaining in
645 // her account.
646 env(noop(alice), Fee(env.balance(alice) - XRP(1)));
647 env.close();
648
649 auto const acctDelFee{drops(env.current()->fees().increment)};
650 BEAST_EXPECT(acctDelFee > env.balance(alice));
651
652 // alice attempts to delete her account even though she can't pay
653 // the full fee. She specifies a fee that is larger than her balance.
654 //
655 // The balance of env.master should not change.
656 auto const masterBalance{env.balance(env.master)};
657 env(acctdelete(alice, env.master), Fee(acctDelFee), Ter(terINSUF_FEE_B));
658 env.close();
659 {
660 std::shared_ptr<ReadView const> const closed{env.closed()};
661 BEAST_EXPECT(closed->exists(keylet::account(alice.id())));
662 BEAST_EXPECT(env.balance(env.master) == masterBalance);
663 }
664
665 // alice again attempts to delete her account. This time she specifies
666 // her current balance in XRP. Again the transaction fails.
667 BEAST_EXPECT(env.balance(alice) == XRP(1));
668 env(acctdelete(alice, env.master), Fee(XRP(1)), Ter(telINSUF_FEE_P));
669 env.close();
670 {
671 std::shared_ptr<ReadView const> const closed{env.closed()};
672 BEAST_EXPECT(closed->exists(keylet::account(alice.id())));
673 BEAST_EXPECT(env.balance(env.master) == masterBalance);
674 }
675 }
676
677 void
679 {
680 testcase("With Tickets");
681
682 using namespace test::jtx;
683
684 Account const alice{"alice"};
685 Account const bob{"bob"};
686
687 Env env{*this};
688 env.fund(XRP(100000), alice, bob);
689 env.close();
690
691 // bob grabs as many tickets as he is allowed to have.
692 std::uint32_t const ticketSeq{env.seq(bob) + 1};
693 env(ticket::create(bob, 250));
694 env.close();
695 env.require(Owners(bob, 250));
696
697 {
698 std::shared_ptr<ReadView const> const closed{env.closed()};
699 BEAST_EXPECT(closed->exists(keylet::account(bob.id())));
700 for (std::uint32_t i = 0; i < 250; ++i)
701 {
702 BEAST_EXPECT(
703 closed->exists(keylet::ticket(bob.id(), SeqProxy::rawTicket(ticketSeq + i))));
704 }
705 }
706
707 // Close enough ledgers to be able to delete bob's account.
708 incLgrSeqForAccDel(env, bob);
709
710 // bob deletes his account using a ticket. bob's account and all
711 // of his tickets should be removed from the ledger.
712 auto const acctDelFee{drops(env.current()->fees().increment)};
713 auto const bobOldBalance{env.balance(bob)};
714 env(acctdelete(bob, alice), ticket::Use(ticketSeq), Fee(acctDelFee));
715 verifyDeliveredAmount(env, bobOldBalance - acctDelFee);
716 env.close();
717 {
718 std::shared_ptr<ReadView const> const closed{env.closed()};
719 BEAST_EXPECT(!closed->exists(keylet::account(bob.id())));
720 for (std::uint32_t i = 0; i < 250; ++i)
721 {
722 BEAST_EXPECT(
723 !closed->exists(keylet::ticket(bob.id(), SeqProxy::rawTicket(ticketSeq + i))));
724 }
725 }
726 }
727
728 void
730 {
731 testcase("Destination Constraints");
732
733 using namespace test::jtx;
734
735 Account const alice{"alice"};
736 Account const becky{"becky"};
737 Account const carol{"carol"};
738 Account const daria{"daria"};
739
740 Env env{*this, features};
741 env.fund(XRP(100000), alice, becky, carol);
742 env.close();
743
744 // alice sets the lsfDepositAuth flag on her account. This should
745 // prevent becky from deleting her account while using alice as the
746 // destination.
747 env(fset(alice, asfDepositAuth));
748
749 // carol requires a destination tag.
750 env(fset(carol, asfRequireDest));
751 env.close();
752
753 // Need to create a pseudo-account
754 Vault const vault{env};
755 auto [tx, keylet] = vault.create({.owner = alice, .asset = xrpIssue()});
756 env(tx);
757 env.close();
758 auto const sleVault = env.le(keylet);
759 if (!BEAST_EXPECT(sleVault))
760 return;
761 Account const vaultPseudo{"vaultPseudo", sleVault->at(sfAccount)};
762
763 // Close enough ledgers to be able to delete becky's account.
764 incLgrSeqForAccDel(env, becky);
765
766 // becky attempts to delete her account using daria as the destination.
767 // Since daria is not in the ledger the delete attempt fails.
768 auto const acctDelFee{drops(env.current()->fees().increment)};
769 env(acctdelete(becky, daria), Fee(acctDelFee), Ter(tecNO_DST));
770 env.close();
771
772 // becky attempts to delete her account, but carol requires a
773 // destination tag which becky has omitted.
774 env(acctdelete(becky, carol), Fee(acctDelFee), Ter(tecDST_TAG_NEEDED));
775 env.close();
776
777 // becky attempts to delete her account, but alice won't take her XRP,
778 // so the delete is blocked.
779 env(acctdelete(becky, alice), Fee(acctDelFee), Ter(tecNO_PERMISSION));
780 env.close();
781
782 // becky attempts to delete her account using a pseudo-account as the
783 // destination, which fails since pseudo-accounts have deposit auth enabled.
784 env(acctdelete(becky, vaultPseudo), Fee(acctDelFee), Ter(tecNO_PERMISSION));
785
786 // alice preauthorizes deposits from becky. Now becky can delete her
787 // account and forward the leftovers to alice.
788 env(deposit::auth(alice, becky));
789 env.close();
790
791 auto const beckyOldBalance{env.balance(becky)};
792 env(acctdelete(becky, alice), Fee(acctDelFee));
793 verifyDeliveredAmount(env, beckyOldBalance - acctDelFee);
794 env.close();
795 }
796
797 void
799 {
800 {
801 testcase("Destination Constraints with DepositPreauth and Credentials");
802
803 using namespace test::jtx;
804
805 Account const alice{"alice"};
806 Account const becky{"becky"};
807 Account const carol{"carol"};
808 Account const daria{"daria"};
809
810 char const credType[] = "abcd";
811
812 Env env{*this};
813 env.fund(XRP(100000), alice, becky, carol, daria);
814 env.close();
815
816 // carol issue credentials for becky
817 env(credentials::create(becky, carol, credType));
818 env.close();
819
820 // get credentials index
821 auto const jv = credentials::ledgerEntry(env, becky, carol, credType);
822 std::string const credIdx = jv[jss::result][jss::index].asString();
823
824 // Close enough ledgers to be able to delete becky's account.
825 incLgrSeqForAccDel(env, becky);
826
827 auto const acctDelFee{drops(env.current()->fees().increment)};
828
829 // becky use credentials but they aren't accepted
830 env(acctdelete(becky, alice),
831 credentials::Ids({credIdx}),
832 Fee(acctDelFee),
834 env.close();
835
836 {
837 // alice sets the lsfDepositAuth flag on her account. This
838 // should prevent becky from deleting her account while using
839 // alice as the destination.
840 env(fset(alice, asfDepositAuth));
841 env.close();
842 }
843
844 // Fail, credentials still not accepted
845 env(acctdelete(becky, alice),
846 credentials::Ids({credIdx}),
847 Fee(acctDelFee),
849 env.close();
850
851 // becky accept the credentials
852 env(credentials::accept(becky, carol, credType));
853 env.close();
854
855 // Fail, credentials doesn’t belong to carol
856 env(acctdelete(carol, alice),
857 credentials::Ids({credIdx}),
858 Fee(acctDelFee),
860
861 // Fail, no depositPreauth for provided credentials
862 env(acctdelete(becky, alice),
863 credentials::Ids({credIdx}),
864 Fee(acctDelFee),
866 env.close();
867
868 // alice create DepositPreauth Object
869 env(deposit::authCredentials(alice, {{.issuer = carol, .credType = credType}}));
870 env.close();
871
872 // becky attempts to delete her account, but alice won't take her
873 // XRP, so the delete is blocked.
874 env(acctdelete(becky, alice), Fee(acctDelFee), Ter(tecNO_PERMISSION));
875
876 // becky use empty credentials and can't delete account
877 env(acctdelete(becky, alice), Fee(acctDelFee), credentials::Ids({}), Ter(temMALFORMED));
878
879 // becky use bad credentials and can't delete account
880 env(acctdelete(becky, alice),
882 "48004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6E"
883 "A288BE4",
884 }),
885 Fee(acctDelFee),
887 env.close();
888
889 // becky use credentials and can delete account
890 env(acctdelete(becky, alice), credentials::Ids({credIdx}), Fee(acctDelFee));
891 env.close();
892
893 {
894 // check that credential object deleted too
895 auto const jNoCred = credentials::ledgerEntry(env, becky, carol, credType);
896 BEAST_EXPECT(
897 jNoCred.isObject() && jNoCred.isMember(jss::result) &&
898 jNoCred[jss::result][jss::error] == "entryNotFound" &&
899 jNoCred[jss::result][jss::error_code] == RpcEntryNotFound &&
900 jNoCred[jss::result][jss::error_message] == "Entry not found.");
901 }
902
903 testcase("Credentials that aren't required");
904 { // carol issue credentials for daria
905 env(credentials::create(daria, carol, credType));
906 env.close();
907 env(credentials::accept(daria, carol, credType));
908 env.close();
909 std::string const credDaria =
910 credentials::ledgerEntry(env, daria, carol, credType)[jss::result][jss::index]
911 .asString();
912
913 // daria use valid credentials, which aren't required and can
914 // delete her account
915 env(acctdelete(daria, carol), credentials::Ids({credDaria}), Fee(acctDelFee));
916 env.close();
917
918 // check that credential object deleted too
919 auto const jNoCred = credentials::ledgerEntry(env, daria, carol, credType);
920
921 BEAST_EXPECT(
922 jNoCred.isObject() && jNoCred.isMember(jss::result) &&
923 jNoCred[jss::result][jss::error] == "entryNotFound" &&
924 jNoCred[jss::result][jss::error_code] == RpcEntryNotFound &&
925 jNoCred[jss::result][jss::error_message] == "Entry not found.");
926 }
927
928 {
929 Account const eaton{"eaton"};
930 Account const fred{"fred"};
931
932 env.fund(XRP(5000), eaton, fred);
933
934 // carol issue credentials for eaton
935 env(credentials::create(eaton, carol, credType));
936 env.close();
937 env(credentials::accept(eaton, carol, credType));
938 env.close();
939 std::string const credEaton =
940 credentials::ledgerEntry(env, eaton, carol, credType)[jss::result][jss::index]
941 .asString();
942
943 // fred make pre-authorization through authorized account
944 env(fset(fred, asfDepositAuth));
945 env.close();
946 env(deposit::auth(fred, eaton));
947 env.close();
948
949 // Close enough ledgers to be able to delete becky's account.
950 incLgrSeqForAccDel(env, eaton);
951 auto const acctDelFee{drops(env.current()->fees().increment)};
952
953 // eaton use valid credentials, but he already authorized
954 // through "Authorized" field.
955 env(acctdelete(eaton, fred), credentials::Ids({credEaton}), Fee(acctDelFee));
956 env.close();
957
958 // check that credential object deleted too
959 auto const jNoCred = credentials::ledgerEntry(env, eaton, carol, credType);
960
961 BEAST_EXPECT(
962 jNoCred.isObject() && jNoCred.isMember(jss::result) &&
963 jNoCred[jss::result][jss::error] == "entryNotFound" &&
964 jNoCred[jss::result][jss::error_code] == RpcEntryNotFound &&
965 jNoCred[jss::result][jss::error_message] == "Entry not found.");
966 }
967
968 testcase("Expired credentials");
969 {
970 Account const john{"john"};
971
972 env.fund(XRP(10000), john);
973 env.close();
974
975 auto jv = credentials::create(john, carol, credType);
976 uint32_t const t =
977 env.current()->header().parentCloseTime.time_since_epoch().count() + 20;
978 jv[sfExpiration.jsonName] = t;
979 env(jv);
980 env.close();
981 env(credentials::accept(john, carol, credType));
982 env.close();
983 jv = credentials::ledgerEntry(env, john, carol, credType);
984 std::string const credIdx = jv[jss::result][jss::index].asString();
985
986 incLgrSeqForAccDel(env, john);
987
988 // credentials are expired
989 // john use credentials but can't delete account
990 env(acctdelete(john, alice),
991 credentials::Ids({credIdx}),
992 Fee(acctDelFee),
993 Ter(tecEXPIRED));
994 env.close();
995
996 {
997 // check that expired credential object deleted
998 auto jv = credentials::ledgerEntry(env, john, carol, credType);
999 BEAST_EXPECT(
1000 jv.isObject() && jv.isMember(jss::result) &&
1001 jv[jss::result][jss::error] == "entryNotFound" &&
1002 jv[jss::result][jss::error_code] == RpcEntryNotFound &&
1003 jv[jss::result][jss::error_message] == "Entry not found.");
1004 }
1005 }
1006 }
1007
1008 {
1009 testcase("Credentials feature disabled");
1010 using namespace test::jtx;
1011
1012 Account const alice{"alice"};
1013 Account const becky{"becky"};
1014 Account const carol{"carol"};
1015
1016 Env env{*this, testableAmendments() - featureCredentials};
1017 env.fund(XRP(100000), alice, becky, carol);
1018 env.close();
1019
1020 // alice sets the lsfDepositAuth flag on her account. This should
1021 // prevent becky from deleting her account while using alice as the
1022 // destination.
1023 env(fset(alice, asfDepositAuth));
1024 env.close();
1025
1026 // Close enough ledgers to be able to delete becky's account.
1027 incLgrSeqForAccDel(env, becky);
1028
1029 auto const acctDelFee{drops(env.current()->fees().increment)};
1030
1031 std::string const credIdx =
1032 "098B7F1B146470A1C5084DC7832C04A72939E3EBC58E68AB8B579BA072B0CE"
1033 "CB";
1034
1035 // and can't delete even with old DepositPreauth
1036 env(deposit::auth(alice, becky));
1037 env.close();
1038
1039 env(acctdelete(becky, alice),
1040 credentials::Ids({credIdx}),
1041 Fee(acctDelFee),
1042 Ter(temDISABLED));
1043 env.close();
1044 }
1045 }
1046
1047 void
1049 {
1050 {
1051 testcase("Deleting Issuer deletes issued credentials");
1052
1053 using namespace test::jtx;
1054
1055 Account const alice{"alice"};
1056 Account const becky{"becky"};
1057 Account const carol{"carol"};
1058
1059 char const credType[] = "abcd";
1060
1061 Env env{*this};
1062 env.fund(XRP(100000), alice, becky, carol);
1063 env.close();
1064
1065 // carol issue credentials for becky
1066 env(credentials::create(becky, carol, credType));
1067 env.close();
1068 env(credentials::accept(becky, carol, credType));
1069 env.close();
1070
1071 // get credentials index
1072 auto const jv = credentials::ledgerEntry(env, becky, carol, credType);
1073 std::string const credIdx = jv[jss::result][jss::index].asString();
1074
1075 // Close enough ledgers to be able to delete carol's account.
1076 incLgrSeqForAccDel(env, carol);
1077
1078 auto const acctDelFee{drops(env.current()->fees().increment)};
1079 env(acctdelete(carol, alice), Fee(acctDelFee));
1080 env.close();
1081
1082 { // check that credential object deleted too
1083 BEAST_EXPECT(!env.le(credIdx));
1084 auto const jv = credentials::ledgerEntry(env, becky, carol, credType);
1085 BEAST_EXPECT(
1086 jv.isObject() && jv.isMember(jss::result) &&
1087 jv[jss::result][jss::error] == "entryNotFound" &&
1088 jv[jss::result][jss::error_code] == RpcEntryNotFound &&
1089 jv[jss::result][jss::error_message] == "Entry not found.");
1090 }
1091 }
1092
1093 {
1094 testcase("Deleting Subject deletes issued credentials");
1095
1096 using namespace test::jtx;
1097
1098 Account const alice{"alice"};
1099 Account const becky{"becky"};
1100 Account const carol{"carol"};
1101
1102 char const credType[] = "abcd";
1103
1104 Env env{*this};
1105 env.fund(XRP(100000), alice, becky, carol);
1106 env.close();
1107
1108 // carol issue credentials for becky
1109 env(credentials::create(becky, carol, credType));
1110 env.close();
1111 env(credentials::accept(becky, carol, credType));
1112 env.close();
1113
1114 // get credentials index
1115 auto const jv = credentials::ledgerEntry(env, becky, carol, credType);
1116 std::string const credIdx = jv[jss::result][jss::index].asString();
1117
1118 // Close enough ledgers to be able to delete carol's account.
1119 incLgrSeqForAccDel(env, becky);
1120
1121 auto const acctDelFee{drops(env.current()->fees().increment)};
1122 env(acctdelete(becky, alice), Fee(acctDelFee));
1123 env.close();
1124
1125 { // check that credential object deleted too
1126 BEAST_EXPECT(!env.le(credIdx));
1127 auto const jv = credentials::ledgerEntry(env, becky, carol, credType);
1128 BEAST_EXPECT(
1129 jv.isObject() && jv.isMember(jss::result) &&
1130 jv[jss::result][jss::error] == "entryNotFound" &&
1131 jv[jss::result][jss::error_code] == RpcEntryNotFound &&
1132 jv[jss::result][jss::error_message] == "Entry not found.");
1133 }
1134 }
1135 }
1136
1137 void
1138 run() override
1139 {
1140 auto const all{jtx::testableAmendments()};
1141 testBasics();
1148 testDest(all);
1149 testDest(all - fixCleanup3_3_0);
1152 }
1153};
1154
1156
1157} // namespace xrpl::test
A testsuite class.
Definition suite.h:52
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
Represents a JSON value.
Definition json_value.h:121
UInt asUInt() const
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
std::chrono::duration< rep, period > duration
Definition chrono.h:47
A public key.
Definition PublicKey.h:53
Slice slice() const noexcept
Definition PublicKey.h:115
json::Value getJson(JsonOptions=JsonOptions::Values::None) const override
static constexpr SeqProxy rawSequence(std::uint32_t v)
Factory function to return a sequence-based SeqProxy.
Definition SeqProxy.h:62
static constexpr SeqProxy rawTicket(std::uint32_t v)
Factory function to return a ticket-based SeqProxy.
Definition SeqProxy.h:74
void testDest(FeatureBitset features)
void run() override
Runs the suite.
static json::Value payChanCreate(jtx::Account const &account, jtx::Account const &to, STAmount const &amount, NetClock::duration const &settleDelay, NetClock::time_point const &cancelAfter, PublicKey const &pk)
void verifyDeliveredAmount(jtx::Env &env, STAmount const &amount)
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
std::string const & human() const
Returns the human readable public key.
PublicKey const & pk() const
Return the public key.
Definition jtx/Account.h:84
AccountID id() const
Returns the Account ID.
A balance matches.
Definition balance.h:24
A transaction testing environment.
Definition Env.h:161
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:133
SLE::const_pointer le(Account const &account) const
Return an account root.
Definition Env.cpp:311
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
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:302
Account const & master
Definition Env.h:165
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Definition Env.h:1058
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition Env.cpp:201
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:354
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
Definition Env.cpp:560
void require(Args const &... args)
Check a set of requirements.
Definition Env.h:766
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:377
NetClock::time_point now()
Returns the current network time.
Definition Env.h:326
Set the fee on a JTx.
Definition fee.h:20
Set a multisignature on a JTx.
Definition multisign.h:53
Match the number of items in the account's owner directory.
Definition owners.h:55
Set the regular signature on a JTx.
Definition sig.h:19
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition ter.h:18
Set the flags on a JTx.
Definition txflags.h:14
Set a ticket sequence on a JTx.
Definition ticket.h:36
Keylet computation functions.
Definition Indexes.h:39
Keylet payChannel(AccountID const &src, AccountID const &dst, SeqProxy const &seq) noexcept
A PaymentChannel.
Definition Indexes.cpp:436
Keylet offer(AccountID const &id, SeqProxy const &seq) noexcept
An offer from an account.
Definition Indexes.cpp:310
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition Indexes.cpp:386
Keylet signerList(AccountID const &account) noexcept
A SignerList.
Definition Indexes.cpp:360
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:415
Keylet check(AccountID const &id, SeqProxy const &seq) noexcept
A Check.
Definition Indexes.cpp:372
Keylet ticket(AccountID const &id, SeqProxy const &ticketSeq)
A ticket belonging to an account.
Definition Indexes.cpp:344
Keylet page(UInt256 const &root, std::uint64_t const index=0) noexcept
A page in a directory.
Definition Indexes.cpp:421
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:233
json::Value cancel(jtx::Account const &dest, UInt256 const &checkId)
Cancel a check.
Definition check.cpp:39
json::Value create(A const &account, A const &dest, STAmount const &sendMax)
Create a check.
json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:29
json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:16
json::Value ledgerEntry(jtx::Env &env, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:56
json::Value authCredentials(jtx::Account const &account, std::vector< AuthorizeCredentials > const &auth)
Definition deposit.cpp:38
json::Value auth(Account const &account, Account const &auth)
Preauthorize for deposit.
Definition deposit.cpp:16
json::Value setValid(jtx::Account const &account)
Definition dids.cpp:25
json::Value create(AccountID const &account, AccountID const &to, STAmount const &amount)
Definition escrow.cpp:24
json::Value cancel(AccountID const &account, Account const &from, std::uint32_t seq)
Definition escrow.cpp:48
auto const kCancelTime
Set the "CancelAfter" time tag on a JTx.
Definition escrow.h:98
auto const kFinishTime
Set the "FinishAfter" time tag on a JTx.
Definition escrow.h:93
json::Value create(Account const &account, std::uint32_t count)
Create one of more tickets.
Definition ticket.cpp:16
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:14
json::Value regkey(Account const &account, DisabledT)
Disable the regular key.
Definition regkey.cpp:13
json::Value offerCancel(Account const &account, std::uint32_t offerSeq)
Cancel an offer.
Definition offer.cpp:31
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
json::Value noop(Account const &account)
The null transaction.
Definition noop.h:14
FeatureBitset testableAmendments()
Definition Env.h:92
OwnerCount< ltOFFER > Offers
Match the number of offers in the account's owner directory.
Definition owners.h:137
json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
void incLgrSeqForAccDel(jtx::Env &env, jtx::Account const &acc, std::uint32_t margin=0)
std::array< Account, 1+sizeof...(Args)> noripple(Account const &account, Args const &... args)
Designate accounts as no-ripple in Env::fund.
Definition Env.h:86
json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
Definition offer.cpp:14
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:18
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
json::Value signers(Account const &account, std::uint32_t quorum, std::vector< Signer > const &v)
Definition multisign.cpp:31
json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition flags.cpp:15
BEAST_DEFINE_TESTSUITE_PRIO(AccountDelete, app, xrpl, 2)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ telINSUF_FEE_P
Definition TER.h:43
@ terINSUF_FEE_B
Definition TER.h:218
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
Definition Issue.h:108
@ RpcEntryNotFound
Definition ErrorCodes.h:144
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:13
@ tefTOO_BIG
Definition TER.h:178
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:658
BaseUInt< 256 > UInt256
Definition base_uint.h:581
@ temBAD_FEE
Definition TER.h:80
@ temINVALID_FLAG
Definition TER.h:99
@ temDST_IS_SRC
Definition TER.h:96
@ temMALFORMED
Definition TER.h:75
@ temDISABLED
Definition TER.h:102
@ tecTOO_SOON
Definition TER.h:329
@ tecBAD_CREDENTIALS
Definition TER.h:370
@ tecEXPIRED
Definition TER.h:325
@ tecNO_PERMISSION
Definition TER.h:316
@ tecDST_TAG_NEEDED
Definition TER.h:320
@ tecHAS_OBLIGATIONS
Definition TER.h:328
@ tecNO_DST
Definition TER.h:301
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
UInt256 key
Definition Keylet.h:21
T time_since_epoch(T... args)