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 test {
24namespace jtx {
25
26namespace detail {
27
29owned_count_of(ReadView const& view, AccountID const& id, LedgerEntryType type)
30{
31 std::uint32_t count = 0;
33 view, id, [&count, type](std::shared_ptr<SLE const> const& sle) {
34 if (sle->getType() == type)
35 ++count;
36 });
37 return count;
38}
39
40void
42 Env& env,
43 AccountID const& id,
44 LedgerEntryType type,
45 std::uint32_t value)
46{
47 env.test.expect(owned_count_of(*env.current(), id, type) == value);
48}
49
50} // namespace detail
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:52
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:263
std::uint32_t value_
Definition: owners.h:76
void operator()(Env &env) const
Definition: owners.cpp:53
std::uint32_t owned_count_of(ReadView const &view, AccountID const &id, LedgerEntryType type)
Definition: owners.cpp:29
void owned_count_helper(Env &env, AccountID const &id, LedgerEntryType type, std::uint32_t value)
Definition: owners.cpp:41
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:25
LedgerEntryType
Identifiers for on-ledger objects.
Definition: LedgerFormats.h:54
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:655