Implement enhanced Ticket support:

Tickets are a mechanism to allow for the "out-of-order" execution of
transactions on the XRP Ledger.

This commit, if merged, reworks the existing support for tickets and
introduces support for 'ticket batching', completing the feature set
needed for tickets.

The code is gated under the newly-introduced `TicketBatch` amendment
and the `Tickets` amendment, which is not presently active on the
network, is being removed.

The specification for this change can be found at:
https://github.com/xrp-community/standards-drafts/issues/16
This commit is contained in:
Scott Schurr
2018-10-18 18:43:02 -07:00
committed by Nik Bougalis
parent 01bd5a2646
commit 7724cca384
101 changed files with 6337 additions and 2287 deletions

View File

@@ -431,6 +431,38 @@ struct DepositPreauth_test : public beast::unit_test::suite
env.require(owners(alice, 0));
env.require(owners(becky, 0));
}
{
// Verify that an account can be preauthorized and unauthorized
// using tickets.
Env env(*this, supported_amendments() | featureTicketBatch);
env.fund(XRP(10000), alice, becky);
env.close();
env(ticket::create(alice, 2));
std::uint32_t const aliceSeq{env.seq(alice)};
env.close();
env.require(tickets(alice, 2));
// Consume the tickets from biggest seq to smallest 'cuz we can.
std::uint32_t aliceTicketSeq{env.seq(alice)};
// Add a DepositPreauth to alice.
env(deposit::auth(alice, becky), ticket::use(--aliceTicketSeq));
env.close();
// Alice uses a ticket but gains a preauth entry.
env.require(tickets(alice, 1));
env.require(owners(alice, 2));
BEAST_EXPECT(env.seq(alice) == aliceSeq);
env.require(owners(becky, 0));
// Remove a DepositPreauth from alice.
env(deposit::unauth(alice, becky), ticket::use(--aliceTicketSeq));
env.close();
env.require(tickets(alice, 0));
env.require(owners(alice, 0));
BEAST_EXPECT(env.seq(alice) == aliceSeq);
env.require(owners(becky, 0));
}
}
void
@@ -697,8 +729,9 @@ struct DepositPreauth_test : public beast::unit_test::suite
{
testEnable();
testInvalid();
testPayment(jtx::supported_amendments() - featureDepositPreauth);
testPayment(jtx::supported_amendments());
auto const supported{jtx::supported_amendments() | featureTicketBatch};
testPayment(supported - featureDepositPreauth);
testPayment(supported);
}
};