xrpld
Loading...
Searching...
No Matches
owners.cpp
1#include <test/jtx/owners.h>
2
3#include <test/jtx/Env.h>
4
5#include <xrpl/core/ServiceRegistry.h>
6#include <xrpl/ledger/ReadView.h>
7#include <xrpl/ledger/helpers/DirectoryHelpers.h>
8#include <xrpl/protocol/AccountID.h>
9#include <xrpl/protocol/LedgerFormats.h>
10#include <xrpl/protocol/SField.h>
11
12#include <cstdint>
13namespace xrpl {
14namespace detail {
15
16std::uint32_t
17ownedCountOf(ReadView const& view, AccountID const& id, LedgerEntryType type)
18{
19 std::uint32_t count = 0;
20 forEachItem(view, id, [&count, type](SLE::const_ref sle) {
21 if (sle->getType() == type)
22 ++count;
23 });
24 return count;
25}
26
27void
29 test::jtx::Env& env,
30 AccountID const& id,
31 LedgerEntryType type,
32 std::uint32_t value)
33{
34 env.test.expect(ownedCountOf(*env.current(), id, type) == value);
35}
36
37} // namespace detail
38
39namespace test::jtx {
40
41void
43{
44 env.test.expect(env.le(account_)->getFieldU32(sfOwnerCount) == value_);
45}
46
47} // namespace test::jtx
48
49} // namespace xrpl
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition suite.h:223
A view into a ledger.
Definition ReadView.h:31
std::shared_ptr< STLedgerEntry const > const & const_ref
A transaction testing environment.
Definition Env.h:143
SLE::const_pointer le(Account const &account) const
Return an account root.
Definition Env.cpp:284
beast::unit_test::Suite & test
Definition Env.h:145
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:353
void operator()(Env &env) const
Definition owners.cpp:42
std::uint32_t value_
Definition owners.h:55
std::uint32_t ownedCountOf(ReadView const &view, AccountID const &id, LedgerEntryType type)
Definition owners.cpp:17
void ownedCountHelper(test::jtx::Env &env, AccountID const &id, LedgerEntryType type, std::uint32_t value)
Definition owners.cpp:28
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(SLE::const_ref)> const &f)
Iterate all items in the given directory.
LedgerEntryType
Identifiers for on-ledger objects.