rippled
test
jtx
impl
balance.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/balance.h>
21
22
namespace
ripple
{
23
namespace
test {
24
namespace
jtx {
25
26
void
27
balance::operator()
(
Env
& env)
const
28
{
29
if
(
isXRP
(
value_
.
issue
()))
30
{
31
auto
const
sle = env.
le
(
account_
);
32
if
(
none_
)
33
{
34
env.
test
.expect(!sle);
35
}
36
else
if
(env.
test
.expect(sle))
37
{
38
env.
test
.expect(sle->getFieldAmount(
sfBalance
) ==
value_
);
39
}
40
}
41
else
42
{
43
auto
const
sle = env.
le
(
keylet::line
(
account_
.
id
(),
value_
.
issue
()));
44
if
(
none_
)
45
{
46
env.
test
.expect(!sle);
47
}
48
else
if
(env.
test
.expect(sle))
49
{
50
auto
amount = sle->getFieldAmount(
sfBalance
);
51
amount.setIssuer(
value_
.
issue
().
account
);
52
if
(
account_
.
id
() >
value_
.
issue
().
account
)
53
amount.negate();
54
env.
test
.expect(amount ==
value_
);
55
}
56
}
57
}
58
59
}
// namespace jtx
60
}
// namespace test
61
}
// namespace ripple
ripple::STAmount::issue
Issue const & issue() const
Definition:
STAmount.h:347
ripple::test::jtx::balance::none_
bool none_
Definition:
balance.h:41
ripple::test::jtx::Account::id
AccountID id() const
Returns the Account ID.
Definition:
Account.h:106
ripple::isXRP
bool isXRP(AccountID const &c)
Definition:
AccountID.h:89
ripple::keylet::line
Keylet line(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
Definition:
Indexes.cpp:193
ripple::test::jtx::Env::test
beast::unit_test::suite & test
Definition:
Env.h:119
ripple::test::jtx::balance::operator()
void operator()(Env &) const
Definition:
balance.cpp:27
ripple::test::jtx::balance::value_
STAmount value_
Definition:
balance.h:43
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::test::jtx::Env::le
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition:
Env.cpp:216
ripple::sfBalance
const SF_AMOUNT sfBalance
ripple::test::jtx::balance::account_
Account account_
Definition:
balance.h:42
ripple::test::jtx::Env
A transaction testing environment.
Definition:
Env.h:116
ripple::Issue::account
AccountID account
Definition:
Issue.h:38
Generated by
1.8.17