22#include <xrpld/rpc/detail/RPCHelpers.h>
24#include <xrpl/protocol/Feature.h>
25#include <xrpl/protocol/jss.h>
42 auto const gw =
Account(
"gateway");
43 auto const alice =
Account(
"alice");
45 env.
fund(
XRP(10000), gw, alice);
47 auto const USD = gw[
"USD"];
50 account_gw[jss::account] = gw.human();
52 account_alice[jss::account] = alice.human();
54 for (
auto SetOrClear : {
true,
false})
66 env.
rpc(
"json",
"account_lines",
to_string(account_gw))};
67 auto const& gline0 =
lines[jss::result][jss::lines][0u];
68 BEAST_EXPECT(gline0[jss::no_ripple].asBool() == SetOrClear);
72 auto const& aline0 =
lines[jss::result][jss::lines][0u];
73 BEAST_EXPECT(aline0[jss::no_ripple_peer].asBool() == SetOrClear);
80 testcase(
"Set noripple on a line with negative balance");
83 auto const gw =
Account(
"gateway");
84 auto const alice =
Account(
"alice");
85 auto const bob =
Account(
"bob");
86 auto const carol =
Account(
"carol");
90 for (
auto const& tweakedFeatures :
91 {features - fix1578, features | fix1578})
93 Env env(*
this, tweakedFeatures);
95 env.
fund(
XRP(10000), gw, alice, bob, carol);
98 env.
trust(alice[
"USD"](100), bob);
99 env.
trust(bob[
"USD"](100), carol);
105 env(
pay(alice, carol, carol[
"USD"](50)),
path(bob));
118 params[jss::source_account] = alice.human();
119 params[jss::destination_account] = carol.human();
120 params[jss::destination_amount] = [] {
122 dest_amt[jss::currency] =
"USD";
123 dest_amt[jss::value] =
"1";
130 BEAST_EXPECT(resp[jss::result][jss::alternatives].size() == 1);
134 return r[jss::lines];
138 BEAST_EXPECT(aliceLines.size() == 1);
139 BEAST_EXPECT(aliceLines[0u][jss::no_ripple].asBool() ==
false);
142 BEAST_EXPECT(bobLines.size() == 2);
143 BEAST_EXPECT(bobLines[0u][jss::no_ripple].asBool() ==
false);
144 BEAST_EXPECT(bobLines[1u][jss::no_ripple].asBool() ==
false);
149 env(
pay(carol, alice, alice[
"USD"](50)),
path(bob));
157 BEAST_EXPECT(aliceLines.size() == 1);
158 BEAST_EXPECT(aliceLines[0u].isMember(jss::no_ripple));
161 BEAST_EXPECT(bobLines.size() == 2);
162 BEAST_EXPECT(bobLines[0u].isMember(jss::no_ripple_peer));
163 BEAST_EXPECT(bobLines[1u].isMember(jss::no_ripple));
174 Env env(*
this, features);
176 auto const alice =
Account(
"alice");
177 auto const bob =
Account(
"bob");
178 auto const carol =
Account(
"carol");
180 env.
fund(
XRP(10000), alice, bob, carol);
182 env(
trust(bob, alice[
"USD"](100)));
183 env(
trust(carol, bob[
"USD"](100)));
190 params[jss::source_account] = alice.human();
191 params[jss::destination_account] = carol.human();
192 params[jss::destination_amount] = [] {
194 dest_amt[jss::currency] =
"USD";
195 dest_amt[jss::value] =
"1";
201 env.
rpc(
"json",
"ripple_path_find",
to_string(params))};
202 BEAST_EXPECT(resp[jss::result][jss::alternatives].size() == 0);
211 "Set default ripple on an account and check new trustlines "
216 Env env(*
this, features);
218 auto const gw =
Account(
"gateway");
219 auto const alice =
Account(
"alice");
220 auto const bob =
Account(
"bob");
226 auto const USD = gw[
"USD"];
228 env(
trust(gw, USD(100), alice, 0));
229 env(
trust(gw, USD(100), bob, 0));
231 params[jss::api_version] = apiVersion;
234 params[jss::account] = gw.human();
235 params[jss::peer] = alice.human();
238 auto const& line0 =
lines[jss::result][jss::lines][0u];
239 BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() ==
true);
242 params[jss::account] = alice.human();
243 params[jss::peer] = gw.human();
246 auto const& line0 =
lines[jss::result][jss::lines][0u];
247 BEAST_EXPECT(line0[jss::no_ripple].asBool() ==
true);
250 params[jss::account] = gw.human();
251 params[jss::peer] = bob.human();
254 auto const& line0 =
lines[jss::result][jss::lines][0u];
255 BEAST_EXPECT(line0[jss::no_ripple].asBool() ==
false);
258 params[jss::account] = bob.human();
259 params[jss::peer] = gw.human();
262 auto const& line0 =
lines[jss::result][jss::lines][0u];
263 BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() ==
false);
268 params[jss::account] = bob.human();
269 params[jss::role] =
"gateway";
270 params[jss::transactions] =
"asdf";
275 BEAST_EXPECT(
lines[jss::result][jss::status] ==
"success");
278 lines[jss::result][jss::error] ==
"invalidParams");
297 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