xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
jtx
impl
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
>
13
namespace
xrpl
{
14
namespace
detail
{
15
16
std::uint32_t
17
ownedCountOf
(
ReadView
const
& view,
AccountID
const
&
id
,
LedgerEntryType
type)
18
{
19
std::uint32_t
count = 0;
20
forEachItem
(view,
id
, [&count, type](
SLE::ConstRef
sle) {
21
if
(sle->getType() == type)
22
++count;
23
});
24
return
count;
25
}
26
27
void
28
ownedCountHelper
(
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
39
namespace
test::jtx {
40
41
void
42
Owners::operator()
(
Env
& env)
const
43
{
44
env.
test
.
expect
(env.
le
(
account_
)->getFieldU32(sfOwnerCount) ==
value_
);
45
}
46
47
void
48
SponsoredOwners::operator()
(
Env
& env)
const
49
{
50
env.
test
.
expect
(env.
le
(
account_
)->getFieldU32(sfSponsoredOwnerCount) ==
value_
);
51
}
52
53
void
54
SponsoringOwners::operator()
(
Env
& env)
const
55
{
56
env.
test
.
expect
(env.
le
(
account_
)->getFieldU32(sfSponsoringOwnerCount) ==
value_
);
57
}
58
59
void
60
SponsoringAccountCount::operator()
(
Env
& env)
const
61
{
62
env.
test
.
expect
(env.
le
(
account_
)->getFieldU32(sfSponsoringAccountCount) ==
value_
);
63
}
64
65
}
// namespace test::jtx
66
67
}
// namespace xrpl
beast::unit_test::Suite::expect
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition
suite.h:235
xrpl::ReadView
A view into a ledger.
Definition
ReadView.h:41
xrpl::STLedgerEntry::ConstRef
std::shared_ptr< STLedgerEntry const > const & ConstRef
Definition
STLedgerEntry.h:37
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:161
xrpl::test::jtx::Env::le
SLE::const_pointer le(Account const &account) const
Return an account root.
Definition
Env.cpp:311
xrpl::test::jtx::Env::test
beast::unit_test::Suite & test
Definition
Env.h:163
xrpl::test::jtx::Env::current
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition
Env.h:377
xrpl::test::jtx::Owners::operator()
void operator()(Env &env) const
Definition
owners.cpp:42
xrpl::test::jtx::Owners::value_
std::uint32_t value_
Definition
owners.h:58
xrpl::test::jtx::Owners::account_
Account account_
Definition
owners.h:57
xrpl::test::jtx::SponsoredOwners::operator()
void operator()(Env &env) const
Definition
owners.cpp:48
xrpl::test::jtx::SponsoredOwners::value_
std::uint32_t value_
Definition
owners.h:77
xrpl::test::jtx::SponsoredOwners::account_
Account account_
Definition
owners.h:76
xrpl::test::jtx::SponsoringAccountCount::account_
Account account_
Definition
owners.h:116
xrpl::test::jtx::SponsoringAccountCount::value_
std::uint32_t value_
Definition
owners.h:117
xrpl::test::jtx::SponsoringAccountCount::operator()
void operator()(Env &env) const
Definition
owners.cpp:60
xrpl::test::jtx::SponsoringOwners::account_
Account account_
Definition
owners.h:96
xrpl::test::jtx::SponsoringOwners::value_
std::uint32_t value_
Definition
owners.h:97
xrpl::test::jtx::SponsoringOwners::operator()
void operator()(Env &env) const
Definition
owners.cpp:54
cstdint
std::uint32_t
xrpl::detail
Definition
base_uint.h:37
xrpl::detail::ownedCountOf
std::uint32_t ownedCountOf(ReadView const &view, AccountID const &id, LedgerEntryType type)
Definition
owners.cpp:17
xrpl::detail::ownedCountHelper
void ownedCountHelper(test::jtx::Env &env, AccountID const &id, LedgerEntryType type, std::uint32_t value)
Definition
owners.cpp:28
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::forEachItem
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(SLE::ConstRef)> const &f)
Iterate all items in the given directory.
Definition
DirectoryHelpers.cpp:63
xrpl::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
xrpl::LedgerEntryType
LedgerEntryType
Identifiers for on-ledger objects.
Definition
LedgerFormats.h:40
Generated by
1.17.0