1#include <xrpl/tx/ApplyContext.h>
3#include <xrpl/ledger/ApplyView.h>
4#include <xrpl/ledger/Ledger.h>
5#include <xrpl/ledger/OpenView.h>
6#include <xrpl/protocol/Indexes.h>
7#include <xrpl/protocol/SField.h>
8#include <xrpl/protocol/STAmount.h>
9#include <xrpl/protocol/STLedgerEntry.h>
10#include <xrpl/protocol/STTx.h>
11#include <xrpl/protocol/SeqProxy.h>
12#include <xrpl/protocol/TER.h>
13#include <xrpl/protocol/TxMeta.h>
14#include <xrpl/protocol/XRPAmount.h>
15#include <xrpl/protocol_autogen/transactions/AccountSet.h>
17#include <gtest/gtest.h>
18#include <helpers/Account.h>
19#include <helpers/TxTest.h>
57 sle->setAccountID(sfAccount,
alice_.id());
58 sle->setFieldU32(sfTicketSequence, seq);
59 sle->setFieldU64(sfOwnerNode, 0);
66 ASSERT_NE(tx_,
nullptr);
80 auto const stale = makeTicket(1);
83 ASSERT_NE(account,
nullptr);
84 auto const baseSeq = account->getFieldU32(sfSequence);
85 account->setFieldU32(sfSequence, baseSeq + 1);
89 ASSERT_EQ(ctx.
size(), 2);
94 EXPECT_EQ(ctx.
size(), 0);
97 ASSERT_NE(reread,
nullptr);
98 EXPECT_EQ(reread->getFieldU32(sfSequence), baseSeq);
102 auto const fresh = makeTicket(2);
106 ASSERT_TRUE(meta.has_value());
107 EXPECT_FALSE(meta->getDeliveredAmount().has_value());
111 ASSERT_NE(applied,
nullptr);
112 EXPECT_EQ(applied->getFieldU32(sfSequence), baseSeq);
117 Ledger const& prev = env_.getClosedLedger();
118 Ledger next(prev, prev.header().closeTime + prev.header().closeTimeResolution);
120 EXPECT_EQ(next.header().drops, prev.header().drops - keptBurn);
State information when applying a tx.
std::size_t size()
Get the number of unapplied changes.
void destroyXRP(XRPAmount const &fee)
void discard()
Discard changes and start fresh.
void deliver(STAmount const &amount)
Sets the DeliveredAmount field in the metadata.
std::optional< TxMeta > apply(TER)
Apply the transaction result to the base.
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void insert(SLE::Ref sle)=0
Insert a new state SLE.
virtual ApplyFlags flags() const =0
Returns the tx apply flags.
virtual void update(SLE::Ref sle)=0
Indicate changes to a peeked SLE.
Writable ledger view that accumulates state and tx changes.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
std::shared_ptr< STLedgerEntry > pointer
static constexpr SeqProxy rawTicket(std::uint32_t v)
Factory function to return a ticket-based SeqProxy.
A funded alice over an open ledger, plus a signed transaction to build an ApplyContext around.
SLE::pointer makeTicket(std::uint32_t seq) const
Build a ticket entry that is not in the ledger.
std::shared_ptr< STTx const > tx_
A lightweight transaction testing harness.
Immutable cryptographic account descriptor.
Builder for AccountSet transactions.
AccountSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the AccountSet wrapper.
std::shared_ptr< STTx const > getSTTx() const
Get the underlying STTx object.
Derived & setFee(STAmount const &value)
Set the transaction fee.
Derived & setSequence(std::uint32_t const &value)
Set the sequence number.
Keylet unchecked(UInt256 const &key) noexcept
Any ledger entry.
Keylet ticket(AccountID const &id, SeqProxy const &ticketSeq)
A ticket belonging to an account.
Keylet account(AccountID const &id) noexcept
AccountID root.
XrpT const XRP
Converts to XRP Issue or STAmount.
TEST_F(BaseUintDeathTest, from_raw_size_mismatch)
constexpr XRPAmount
Convert XRP to drops (integral types).
void open(soci::session &s, BasicConfig const &config, std::string const &dbName)
Open a soci session.