3#include <xrpl/protocol/Feature.h>
4#include <xrpl/protocol/jss.h>
21 auto const gw =
Account(
"gateway");
22 auto const alice =
Account(
"alice");
24 env.
fund(
XRP(10000), gw, alice);
26 auto const USD = gw[
"USD"];
29 account_gw[jss::account] = gw.human();
31 account_alice[jss::account] = alice.human();
33 for (
auto SetOrClear : {
true,
false})
41 auto const& gwLine0 =
lines[jss::result][jss::lines][0u];
42 BEAST_EXPECT(gwLine0[jss::no_ripple].asBool() == SetOrClear);
46 auto const& aline0 =
lines[jss::result][jss::lines][0u];
47 BEAST_EXPECT(aline0[jss::no_ripple_peer].asBool() == SetOrClear);
54 testcase(
"Set noripple on a line with negative balance");
57 auto const gw =
Account(
"gateway");
58 auto const alice =
Account(
"alice");
59 auto const bob =
Account(
"bob");
60 auto const carol =
Account(
"carol");
62 Env env(*
this, features);
64 env.
fund(
XRP(10000), gw, alice, bob, carol);
67 env.
trust(alice[
"USD"](100), bob);
68 env.
trust(bob[
"USD"](100), carol);
74 env(
pay(alice, carol, carol[
"USD"](50)),
path(bob));
84 params[jss::source_account] = alice.human();
85 params[jss::destination_account] = carol.human();
86 params[jss::destination_amount] = [] {
88 dest_amt[jss::currency] =
"USD";
89 dest_amt[jss::value] =
"1";
94 auto const resp = env.
rpc(
"json",
"ripple_path_find",
to_string(params));
95 BEAST_EXPECT(resp[jss::result][jss::alternatives].size() == 1);
103 BEAST_EXPECT(aliceLines.size() == 1);
104 BEAST_EXPECT(aliceLines[0u][jss::no_ripple].asBool() ==
false);
107 BEAST_EXPECT(bobLines.size() == 2);
108 BEAST_EXPECT(bobLines[0u][jss::no_ripple].asBool() ==
false);
109 BEAST_EXPECT(bobLines[1u][jss::no_ripple].asBool() ==
false);
114 env(
pay(carol, alice, alice[
"USD"](50)),
path(bob));
122 BEAST_EXPECT(aliceLines.size() == 1);
123 BEAST_EXPECT(aliceLines[0u].isMember(jss::no_ripple));
126 BEAST_EXPECT(bobLines.size() == 2);
127 BEAST_EXPECT(bobLines[0u].isMember(jss::no_ripple_peer));
128 BEAST_EXPECT(bobLines[1u].isMember(jss::no_ripple));
138 Env env(*
this, features);
140 auto const alice =
Account(
"alice");
141 auto const bob =
Account(
"bob");
142 auto const carol =
Account(
"carol");
144 env.
fund(
XRP(10000), alice, bob, carol);
146 env(
trust(bob, alice[
"USD"](100)));
147 env(
trust(carol, bob[
"USD"](100)));
154 params[jss::source_account] = alice.human();
155 params[jss::destination_account] = carol.human();
156 params[jss::destination_amount] = [] {
158 dest_amt[jss::currency] =
"USD";
159 dest_amt[jss::value] =
"1";
165 BEAST_EXPECT(resp[jss::result][jss::alternatives].size() == 0);
174 "Set default ripple on an account and check new trustlines "
179 Env env(*
this, features);
181 auto const gw =
Account(
"gateway");
182 auto const alice =
Account(
"alice");
183 auto const bob =
Account(
"bob");
189 auto const USD = gw[
"USD"];
191 env(
trust(gw, USD(100), alice, 0));
192 env(
trust(gw, USD(100), bob, 0));
194 params[jss::api_version] = apiVersion;
197 params[jss::account] = gw.human();
198 params[jss::peer] = alice.human();
201 auto const& line0 =
lines[jss::result][jss::lines][0u];
202 BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() ==
true);
205 params[jss::account] = alice.human();
206 params[jss::peer] = gw.human();
209 auto const& line0 =
lines[jss::result][jss::lines][0u];
210 BEAST_EXPECT(line0[jss::no_ripple].asBool() ==
true);
213 params[jss::account] = gw.human();
214 params[jss::peer] = bob.human();
217 auto const& line0 =
lines[jss::result][jss::lines][0u];
218 BEAST_EXPECT(line0[jss::no_ripple].asBool() ==
false);
221 params[jss::account] = bob.human();
222 params[jss::peer] = gw.human();
225 auto const& line0 =
lines[jss::result][jss::lines][0u];
226 BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() ==
false);
231 params[jss::account] = bob.human();
232 params[jss::role] =
"gateway";
233 params[jss::transactions] =
"asdf";
237 BEAST_EXPECT(
lines[jss::result][jss::status] ==
"success");
239 BEAST_EXPECT(
lines[jss::result][jss::error] ==
"invalidParams");
256 withFeatsTests(sa - featurePermissionedDEX);
testcase_t testcase
Memberspace for declaring test cases.
void testPairwise(FeatureBitset features)
void run() override
Runs the suite.
void testDefaultRipple(FeatureBitset features, unsigned int apiVersion)
void testNegativeBalance(FeatureBitset features)
Immutable cryptographic account descriptor.
std::string const & human() const
Returns the human readable public key.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
XRP_t const XRP
Converts to XRP Issue or STAmount.
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
FeatureBitset testable_amendments()
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Json::Value getAccountLines(Env &env, AccountID const &acctId)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_string(base_uint< Bits, Tag > const &a)
constexpr std::uint32_t tfSetNoRipple
constexpr std::uint32_t asfDefaultRipple
void forAllApiVersions(Fn const &fn, Args &&... args)
constexpr std::uint32_t tfClearNoRipple