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})
45 env.
rpc(
"json",
"account_lines",
to_string(account_gw))};
46 auto const& gline0 =
lines[jss::result][jss::lines][0u];
47 BEAST_EXPECT(gline0[jss::no_ripple].asBool() == SetOrClear);
51 auto const& aline0 =
lines[jss::result][jss::lines][0u];
52 BEAST_EXPECT(aline0[jss::no_ripple_peer].asBool() == SetOrClear);
59 testcase(
"Set noripple on a line with negative balance");
62 auto const gw =
Account(
"gateway");
63 auto const alice =
Account(
"alice");
64 auto const bob =
Account(
"bob");
65 auto const carol =
Account(
"carol");
67 Env env(*
this, features);
69 env.
fund(
XRP(10000), gw, alice, bob, carol);
72 env.
trust(alice[
"USD"](100), bob);
73 env.
trust(bob[
"USD"](100), carol);
79 env(
pay(alice, carol, carol[
"USD"](50)),
path(bob));
89 params[jss::source_account] = alice.human();
90 params[jss::destination_account] = carol.human();
91 params[jss::destination_amount] = [] {
93 dest_amt[jss::currency] =
"USD";
94 dest_amt[jss::value] =
"1";
101 BEAST_EXPECT(resp[jss::result][jss::alternatives].size() == 1);
105 return r[jss::lines];
109 BEAST_EXPECT(aliceLines.size() == 1);
110 BEAST_EXPECT(aliceLines[0u][jss::no_ripple].asBool() ==
false);
113 BEAST_EXPECT(bobLines.size() == 2);
114 BEAST_EXPECT(bobLines[0u][jss::no_ripple].asBool() ==
false);
115 BEAST_EXPECT(bobLines[1u][jss::no_ripple].asBool() ==
false);
120 env(
pay(carol, alice, alice[
"USD"](50)),
path(bob));
128 BEAST_EXPECT(aliceLines.size() == 1);
129 BEAST_EXPECT(aliceLines[0u].isMember(jss::no_ripple));
132 BEAST_EXPECT(bobLines.size() == 2);
133 BEAST_EXPECT(bobLines[0u].isMember(jss::no_ripple_peer));
134 BEAST_EXPECT(bobLines[1u].isMember(jss::no_ripple));
144 Env env(*
this, features);
146 auto const alice =
Account(
"alice");
147 auto const bob =
Account(
"bob");
148 auto const carol =
Account(
"carol");
150 env.
fund(
XRP(10000), alice, bob, carol);
152 env(
trust(bob, alice[
"USD"](100)));
153 env(
trust(carol, bob[
"USD"](100)));
160 params[jss::source_account] = alice.human();
161 params[jss::destination_account] = carol.human();
162 params[jss::destination_amount] = [] {
164 dest_amt[jss::currency] =
"USD";
165 dest_amt[jss::value] =
"1";
171 env.
rpc(
"json",
"ripple_path_find",
to_string(params))};
172 BEAST_EXPECT(resp[jss::result][jss::alternatives].size() == 0);
181 "Set default ripple on an account and check new trustlines "
186 Env env(*
this, features);
188 auto const gw =
Account(
"gateway");
189 auto const alice =
Account(
"alice");
190 auto const bob =
Account(
"bob");
196 auto const USD = gw[
"USD"];
198 env(
trust(gw, USD(100), alice, 0));
199 env(
trust(gw, USD(100), bob, 0));
201 params[jss::api_version] = apiVersion;
204 params[jss::account] = gw.human();
205 params[jss::peer] = alice.human();
208 auto const& line0 =
lines[jss::result][jss::lines][0u];
209 BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() ==
true);
212 params[jss::account] = alice.human();
213 params[jss::peer] = gw.human();
216 auto const& line0 =
lines[jss::result][jss::lines][0u];
217 BEAST_EXPECT(line0[jss::no_ripple].asBool() ==
true);
220 params[jss::account] = gw.human();
221 params[jss::peer] = bob.human();
224 auto const& line0 =
lines[jss::result][jss::lines][0u];
225 BEAST_EXPECT(line0[jss::no_ripple].asBool() ==
false);
228 params[jss::account] = bob.human();
229 params[jss::peer] = gw.human();
232 auto const& line0 =
lines[jss::result][jss::lines][0u];
233 BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() ==
false);
238 params[jss::account] = bob.human();
239 params[jss::role] =
"gateway";
240 params[jss::transactions] =
"asdf";
245 BEAST_EXPECT(
lines[jss::result][jss::status] ==
"success");
248 lines[jss::result][jss::error] ==
"invalidParams");
267 withFeatsTests(sa - featurePermissionedDEX);
testcase_t testcase
Memberspace for declaring test cases.
void testDefaultRipple(FeatureBitset features, unsigned int apiVersion)
void testPairwise(FeatureBitset features)
void run() override
Runs the suite.
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 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.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
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.
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)
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
FeatureBitset testable_amendments()
XRP_t const XRP
Converts to XRP Issue or STAmount.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr std::uint32_t tfClearNoRipple
constexpr std::uint32_t asfDefaultRipple
void forAllApiVersions(Fn const &fn, Args &&... args)
std::string to_string(base_uint< Bits, Tag > const &a)
constexpr std::uint32_t tfSetNoRipple