rippled
Loading...
Searching...
No Matches
owners.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <test/jtx/owners.h>
21
22namespace ripple {
23namespace detail {
24
26owned_count_of(ReadView const& view, AccountID const& id, LedgerEntryType type)
27{
28 std::uint32_t count = 0;
30 view, id, [&count, type](std::shared_ptr<SLE const> const& sle) {
31 if (sle->getType() == type)
32 ++count;
33 });
34 return count;
35}
36
37void
39 test::jtx::Env& env,
40 AccountID const& id,
41 LedgerEntryType type,
42 std::uint32_t value)
43{
44 env.test.expect(owned_count_of(*env.current(), id, type) == value);
45}
46
47} // namespace detail
48
49namespace test {
50namespace jtx {
51
52void
54{
55 env.test.expect(env.le(account_)->getFieldU32(sfOwnerCount) == value_);
56}
57
58} // namespace jtx
59} // namespace test
60} // namespace ripple
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition suite.h:229
A view into a ledger.
Definition ReadView.h:51
A transaction testing environment.
Definition Env.h:121
beast::unit_test::suite & test
Definition Env.h:123
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:331
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition Env.cpp:277
std::uint32_t value_
Definition owners.h:76
void operator()(Env &env) const
Definition owners.cpp:53
void owned_count_helper(test::jtx::Env &env, AccountID const &id, LedgerEntryType type, std::uint32_t value)
Definition owners.cpp:38
std::uint32_t owned_count_of(ReadView const &view, AccountID const &id, LedgerEntryType type)
Definition owners.cpp:26
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
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.
Definition View.cpp:653
LedgerEntryType
Identifiers for on-ledger objects.