18 #include <ripple/basics/random.h>
19 #include <ripple/ledger/BookDirs.h>
20 #include <ripple/ledger/Directory.h>
21 #include <ripple/ledger/Sandbox.h>
22 #include <ripple/protocol/Feature.h>
23 #include <ripple/protocol/Protocol.h>
24 #include <ripple/protocol/jss.h>
38 BEAST_EXPECT(i < 17577);
42 for (
int j = 0; j != 3; ++j)
86 testcase(
"Directory Ordering (with 'SortedDirectories' amendment)");
89 env.
fund(
XRP(10000000), alice, gw);
93 env(offer(alice, USD(i),
XRP(i)));
100 auto const view = env.
closed();
110 auto const& v = p->getFieldV256(
sfIndexes);
119 for (
auto const& e : v)
123 BEAST_EXPECT(c->getFieldU32(
sfSequence) >= minSeq);
124 BEAST_EXPECT(c->getFieldU32(
sfSequence) < maxSeq);
136 for (
auto const& offer : book)
139 BEAST_EXPECT(offer->getFieldAmount(
sfTakerPays) == USD(count));
147 testcase(
"dirIsEmpty");
150 auto const alice =
Account(
"alice");
151 auto const bob =
Account(
"bob");
152 auto const charlie =
Account(
"charlie");
157 env.
fund(
XRP(1000000), alice, charlie, gw);
164 env(signers(alice, 1, {{bob, 1}}));
186 auto cl = currencies;
188 for (
auto const& c : cl)
190 env(
trust(alice, c(50)));
198 for (
auto const& c : cl)
200 env(
trust(alice, c(0)));
210 auto cl = currencies;
214 for (
auto c : currencies)
216 env(
trust(charlie, c(50)));
218 env(
pay(gw, charlie, c(50)));
220 env(offer(alice, c(50),
XRP(50)));
231 for (
auto const& c : cl)
233 env(offer(charlie,
XRP(50), c(50)));
242 for (
auto const& c : cl)
244 env(
pay(alice, charlie, c(50)));
255 testcase(
"RIPD-1353 Empty Offer Directories");
260 auto const gw =
Account{
"gateway"};
261 auto const alice =
Account{
"alice"};
262 auto const USD = gw[
"USD"];
264 env.
fund(
XRP(10000), alice, gw);
266 env.
trust(USD(1000), alice);
267 env(
pay(gw, alice, USD(1000)));
269 auto const firstOfferSeq = env.
seq(alice);
272 for (
int i = 0; i < 3; ++i)
274 env(offer(alice,
XRP(1), USD(1)));
278 for (
auto page : {0, 2, 1})
302 env.
trust(USD(0), alice);
303 env(
pay(alice, gw, alice[
"USD"](1000)));
312 testcase(
"Empty Chain on Delete");
317 auto const gw =
Account{
"gateway"};
318 auto const alice =
Account{
"alice"};
319 auto const USD = gw[
"USD"];
325 "fb71c9aa3310141da4b01d6c744a98286af2d72ab5448d5adc0910ca0c910880");
328 "bad0f021aa3b2f6754a8fe82a5779730aa0bbbab82f17201ef24900efc2c7312");
const SF_UINT64 sfIndexNext
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
std::optional< key_type > succ(key_type const &key, std::optional< key_type > const &last=std::nullopt) const override
Return the key of the next state item.
void makePages(Sandbox &sb, uint256 const &base, std::uint64_t n)
const XRP_t XRP
Converts to XRP Issue or STAmount.
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
const SF_UINT32 sfSequence
uint256 getBookBase(Book const &book)
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
void push_back(uint256 const &v)
Json::Value offer_cancel(Account const &account, std::uint32_t offerSeq)
Cancel an offer.
void testDirectoryOrdering()
void update(std::shared_ptr< SLE > const &sle) override
Indicate changes to a peeked SLE.
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
uint256 getQualityNext(uint256 const &uBase)
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
BEAST_DEFINE_TESTSUITE_PRIO(AccountDelete, app, ripple, 2)
const SF_VECTOR256 sfIndexes
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
const SF_AMOUNT sfTakerPays
const SF_UINT64 sfIndexPrevious
Keylet page(uint256 const &key, std::uint64_t index) noexcept
A page in a directory.
Discardable, editable view to a ledger.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
beast::xor_shift_engine & default_prng()
Return the default random engine.
const SF_AMOUNT sfTakerGets
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
std::string currcode(std::size_t i)
void insert(std::shared_ptr< SLE > const &sle) override
Insert a new state SLE.
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Json::Value pay(Account const &account, Account const &to, AnyAmount amount)
Create a payment.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
Immutable cryptographic account descriptor.
std::shared_ptr< SLE > peek(Keylet const &k) override
Prepare to modify the SLE associated with key.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
A transaction testing environment.
constexpr std::size_t dirNodeMaxEntries
The maximum number of entries per directory page.