rippled
Loading...
Searching...
No Matches
owners.cpp
1#include <test/jtx/owners.h>
2
3#include <xrpl/ledger/helpers/DirectoryHelpers.h>
4
5namespace xrpl {
6namespace detail {
7
9owned_count_of(ReadView const& view, AccountID const& id, LedgerEntryType type)
10{
11 std::uint32_t count = 0;
12 forEachItem(view, id, [&count, type](std::shared_ptr<SLE const> const& sle) {
13 if (sle->getType() == type)
14 ++count;
15 });
16 return count;
17}
18
19void
21 test::jtx::Env& env,
22 AccountID const& id,
23 LedgerEntryType type,
24 std::uint32_t value)
25{
26 env.test.expect(owned_count_of(*env.current(), id, type) == value);
27}
28
29} // namespace detail
30
31namespace test {
32namespace jtx {
33
34void
36{
37 env.test.expect(env.le(account_)->getFieldU32(sfOwnerCount) == value_);
38}
39
40} // namespace jtx
41} // namespace test
42} // namespace xrpl
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition suite.h:224
A view into a ledger.
Definition ReadView.h:31
A transaction testing environment.
Definition Env.h:122
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition Env.cpp:258
beast::unit_test::suite & test
Definition Env.h:124
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:329
std::uint32_t value_
Definition owners.h:55
void operator()(Env &env) const
Definition owners.cpp:35
std::uint32_t owned_count_of(ReadView const &view, AccountID const &id, LedgerEntryType type)
Definition owners.cpp:9
void owned_count_helper(test::jtx::Env &env, AccountID const &id, LedgerEntryType type, std::uint32_t value)
Definition owners.cpp:20
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items in the given directory.
LedgerEntryType
Identifiers for on-ledger objects.