rippled
Loading...
Searching...
No Matches
permissioned_dex.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2025 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.h>
21
22#include <xrpl/beast/unit_test/suite.h>
23#include <xrpl/protocol/jss.h>
24
25#include <exception>
26
27namespace ripple {
28namespace test {
29namespace jtx {
30
33 jtx::Env& env,
34 std::vector<jtx::Account> const& accounts,
35 jtx::Account const& domainOwner,
36 std::string const& credType)
37{
38 using namespace jtx;
39 env.fund(XRP(100000), domainOwner);
40 env.close();
41
42 pdomain::Credentials credentials{{domainOwner, credType}};
43 env(pdomain::setTx(domainOwner, credentials));
44
45 auto const objects = pdomain::getObjects(domainOwner, env);
46 auto const domainID = objects.begin()->first;
47
48 for (auto const& account : accounts)
49 {
50 env(credentials::create(account, domainOwner, credType));
51 env.close();
52 env(credentials::accept(account, domainOwner, credType));
53 env.close();
54 }
55 return domainID;
56}
57
59 : gw("permdex-gateway")
60 , domainOwner("permdex-domainOwner")
61 , alice("permdex-alice")
62 , bob("permdex-bob")
63 , carol("permdex-carol")
64 , USD(gw["USD"])
65 , credType("permdex-abcde")
66{
67 // Fund accounts
68 env.fund(XRP(100000), alice, bob, carol, gw);
69 env.close();
70
72
73 for (auto const& account : {alice, bob, carol, domainOwner})
74 {
75 env.trust(USD(1000), account);
76 env.close();
77
78 env(pay(gw, account, USD(100)));
79 env.close();
80 }
81}
82
83} // namespace jtx
84} // namespace test
85} // namespace ripple
Immutable cryptographic account descriptor.
Definition Account.h:39
A transaction testing environment.
Definition Env.h:121
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:121
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:320
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:289
Json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:32
Json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:48
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:30
XRP_t const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:111
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
base_uint< 256 > uint256
Definition base_uint.h:558