rippled
Loading...
Searching...
No Matches
permissioned_dex.cpp
1#include <test/jtx.h>
2
3#include <xrpl/beast/unit_test/suite.h>
4#include <xrpl/protocol/jss.h>
5
6#include <exception>
7
8namespace ripple {
9namespace test {
10namespace jtx {
11
14 jtx::Env& env,
15 std::vector<jtx::Account> const& accounts,
16 jtx::Account const& domainOwner,
17 std::string const& credType)
18{
19 using namespace jtx;
20 env.fund(XRP(100000), domainOwner);
21 env.close();
22
23 pdomain::Credentials credentials{{domainOwner, credType}};
24 env(pdomain::setTx(domainOwner, credentials));
25
26 auto const objects = pdomain::getObjects(domainOwner, env);
27 auto const domainID = objects.begin()->first;
28
29 for (auto const& account : accounts)
30 {
31 env(credentials::create(account, domainOwner, credType));
32 env.close();
33 env(credentials::accept(account, domainOwner, credType));
34 env.close();
35 }
36 return domainID;
37}
38
40 : gw("permdex-gateway")
41 , domainOwner("permdex-domainOwner")
42 , alice("permdex-alice")
43 , bob("permdex-bob")
44 , carol("permdex-carol")
45 , USD(gw["USD"])
46 , credType("permdex-abcde")
47{
48 // Fund accounts
49 env.fund(XRP(100000), alice, bob, carol, gw);
50 env.close();
51
53
54 for (auto const& account : {alice, bob, carol, domainOwner})
55 {
56 env.trust(USD(1000), account);
57 env.close();
58
59 env(pay(gw, account, USD(100)));
60 env.close();
61 }
62}
63
64} // namespace jtx
65} // namespace test
66} // namespace ripple
Immutable cryptographic account descriptor.
Definition Account.h:20
A transaction testing environment.
Definition Env.h:102
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:103
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:302
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:271
Json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:13
Json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:29
Json::Value setTx(AccountID const &account, Credentials const &credentials, std::optional< uint256 > domain)
std::map< uint256, Json::Value > getObjects(Account const &account, Env &env, bool withType)
uint256 setupDomain(jtx::Env &env, std::vector< jtx::Account > const &accounts, jtx::Account const &domainOwner, std::string const &credType)
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:11
XRP_t const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
base_uint< 256 > uint256
Definition base_uint.h:539