xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
app
SetAuth_test.cpp
1
2
#include <test/jtx/Account.h>
3
#include <test/jtx/Env.h>
4
#include <test/jtx/amount.h>
5
#include <test/jtx/flags.h>
6
#include <test/jtx/pay.h>
7
#include <test/jtx/ter.h>
8
#include <test/jtx/trust.h>
9
10
#include <xrpl/beast/unit_test/suite.h>
11
#include <xrpl/json/json_value.h>
12
#include <xrpl/protocol/Feature.h>
13
#include <xrpl/protocol/Indexes.h>
14
#include <xrpl/protocol/TER.h>
15
#include <xrpl/protocol/TxFlags.h>
16
#include <xrpl/protocol/UintTypes.h>
17
#include <xrpl/protocol/jss.h>
18
19
#include <
string
>
20
21
namespace
xrpl::test
{
22
23
struct
SetAuth_test
:
public
beast::unit_test::Suite
24
{
25
// Set just the tfSetfAuth flag on a trust line
26
// If the trust line does not exist, then it should
27
// be created under the new rules.
28
static
json::Value
29
auth
(
jtx::Account
const
& account,
jtx::Account
const
& dest,
std::string
const
& currency)
30
{
31
using namespace
jtx
;
32
json::Value
jv;
33
jv[jss::Account] = account.human();
34
jv[jss::LimitAmount] =
35
STAmount
(
Issue
{
toCurrency
(currency), dest}).
getJson
(
JsonOptions::Values::None
);
36
jv[jss::TransactionType] = jss::TrustSet;
37
jv[jss::Flags] = tfSetfAuth;
38
return
jv;
39
}
40
41
void
42
testAuth
(
FeatureBitset
features)
43
{
44
using namespace
jtx
;
45
auto
const
gw =
Account
(
"gw"
);
46
auto
const
usd = gw[
"USD"
];
47
48
Env
env(*
this
);
49
50
env.
fund
(
XRP
(100000),
"alice"
,
"bob"
, gw);
51
env(
fset
(gw, asfRequireAuth));
52
env.
close
();
53
env(
auth
(gw,
"alice"
,
"USD"
));
54
BEAST_EXPECT(env.
le
(
keylet::trustLine
(
Account
(
"alice"
).
id
(), gw.
id
(), usd.currency)));
55
env(
trust
(
"alice"
, usd(1000)));
56
env(
trust
(
"bob"
, usd(1000)));
57
env(
pay
(gw,
"alice"
, usd(100)));
58
env(
pay
(gw,
"bob"
, usd(100)),
59
Ter
(
tecPATH_DRY
));
// Should be terNO_AUTH
60
env(
pay
(
"alice"
,
"bob"
, usd(50)),
61
Ter
(
tecPATH_DRY
));
// Should be terNO_AUTH
62
}
63
64
void
65
run
()
override
66
{
67
using namespace
jtx
;
68
auto
const
sa =
testableAmendments
();
69
testAuth
(sa - featurePermissionedDEX);
70
testAuth
(sa);
71
}
72
};
73
74
BEAST_DEFINE_TESTSUITE
(SetAuth, app,
xrpl
);
75
76
}
// namespace xrpl::test
std::string
beast::unit_test::Suite
A testsuite class.
Definition
suite.h:52
json::Value
Represents a JSON value.
Definition
json_value.h:117
xrpl::FeatureBitset
Definition
Feature.h:196
xrpl::Issue
A currency issued by an account.
Definition
Issue.h:18
xrpl::STAmount
Definition
STAmount.h:46
xrpl::test::jtx::Account
Immutable cryptographic account descriptor.
Definition
jtx/Account.h:21
xrpl::test::jtx::Account::id
AccountID id() const
Returns the Account ID.
Definition
jtx/Account.h:104
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:161
xrpl::test::jtx::Env::close
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition
Env.cpp:133
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::fund
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition
Env.cpp:323
xrpl::test::jtx::Ter
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition
ter.h:18
xrpl::keylet::trustLine
Keylet trustLine(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
Definition
Indexes.cpp:275
xrpl::test::jtx
Definition
Oracle_test.cpp:34
xrpl::test::jtx::pay
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition
pay.cpp:14
xrpl::test::jtx::XRP
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition
amount.cpp:92
xrpl::test::jtx::testableAmendments
FeatureBitset testableAmendments()
Definition
Env.h:92
xrpl::test::jtx::trust
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition
trust.cpp:18
xrpl::test::jtx::fset
json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition
flags.cpp:15
xrpl::test
Definition
STLedgerEntry.h:21
xrpl::test::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::toCurrency
bool toCurrency(Currency &, std::string const &)
Tries to convert a string to a Currency, returns true on success.
Definition
UintTypes.cpp:65
xrpl::getJson
json::Value getJson(LedgerFill const &fill)
Return a new json::Value representing the ledger with given options.
Definition
LedgerToJson.cpp:369
xrpl::tecPATH_DRY
@ tecPATH_DRY
Definition
TER.h:302
xrpl::FeePayerType::Account
@ Account
Definition
Transactor.h:145
string
xrpl::JsonOptions::Values::None
@ None
Definition
STBase.h:27
xrpl::test::SetAuth_test
Definition
SetAuth_test.cpp:24
xrpl::test::SetAuth_test::auth
static json::Value auth(jtx::Account const &account, jtx::Account const &dest, std::string const ¤cy)
Definition
SetAuth_test.cpp:29
xrpl::test::SetAuth_test::run
void run() override
Runs the suite.
Definition
SetAuth_test.cpp:65
xrpl::test::SetAuth_test::testAuth
void testAuth(FeatureBitset features)
Definition
SetAuth_test.cpp:42
Generated by
1.17.0