20 #include <ripple/protocol/Feature.h>
21 #include <ripple/protocol/jss.h>
34 testcase(
"Set and clear noripple");
39 auto const gw =
Account(
"gateway");
40 auto const alice =
Account(
"alice");
42 env.
fund(
XRP(10000), gw, alice);
44 auto const USD = gw[
"USD"];
47 account_gw[jss::account] = gw.human();
49 account_alice[jss::account] = alice.human();
51 for (
auto SetOrClear : {
true,
false})
63 env.
rpc(
"json",
"account_lines",
to_string(account_gw))};
64 auto const& gline0 =
lines[jss::result][jss::lines][0u];
65 BEAST_EXPECT(gline0[jss::no_ripple].asBool() == SetOrClear);
69 auto const& aline0 =
lines[jss::result][jss::lines][0u];
70 BEAST_EXPECT(aline0[jss::no_ripple_peer].asBool() == SetOrClear);
77 testcase(
"Set noripple on a line with negative balance");
80 auto const gw =
Account(
"gateway");
81 auto const alice =
Account(
"alice");
82 auto const bob =
Account(
"bob");
83 auto const carol =
Account(
"carol");
87 for (
auto const& tweakedFeatures :
90 Env env(*
this, tweakedFeatures);
92 env.
fund(
XRP(10000), gw, alice, bob, carol);
95 env.
trust(alice[
"USD"](100), bob);
96 env.
trust(bob[
"USD"](100), carol);
102 env(
pay(alice, carol, carol[
"USD"](50)),
path(bob));
115 params[jss::source_account] = alice.human();
116 params[jss::destination_account] = carol.human();
117 params[jss::destination_amount] = [] {
119 dest_amt[jss::currency] =
"USD";
120 dest_amt[jss::value] =
"1";
127 BEAST_EXPECT(resp[jss::result][jss::alternatives].size() == 1);
129 auto getAccountLines = [&env](
Account const& acct) {
131 jv[jss::account] = acct.human();
132 auto const r = env.
rpc(
"json",
"account_lines",
to_string(jv));
133 return r[jss::result][jss::lines];
136 auto const aliceLines = getAccountLines(alice);
137 BEAST_EXPECT(aliceLines.size() == 1);
138 BEAST_EXPECT(aliceLines[0u][jss::no_ripple].asBool() ==
false);
140 auto const bobLines = getAccountLines(bob);
141 BEAST_EXPECT(bobLines.size() == 2);
142 BEAST_EXPECT(bobLines[0u][jss::no_ripple].asBool() ==
false);
143 BEAST_EXPECT(bobLines[1u][jss::no_ripple].asBool() ==
false);
148 env(
pay(carol, alice, alice[
"USD"](50)),
path(bob));
155 auto const aliceLines = getAccountLines(alice);
156 BEAST_EXPECT(aliceLines.size() == 1);
157 BEAST_EXPECT(aliceLines[0u].isMember(jss::no_ripple));
159 auto const bobLines = getAccountLines(bob);
160 BEAST_EXPECT(bobLines.size() == 2);
161 BEAST_EXPECT(bobLines[0u].isMember(jss::no_ripple_peer));
162 BEAST_EXPECT(bobLines[1u].isMember(jss::no_ripple));
170 testcase(
"pairwise NoRipple");
173 Env env(*
this, features);
175 auto const alice =
Account(
"alice");
176 auto const bob =
Account(
"bob");
177 auto const carol =
Account(
"carol");
179 env.
fund(
XRP(10000), alice, bob, carol);
181 env(
trust(bob, alice[
"USD"](100)));
182 env(
trust(carol, bob[
"USD"](100)));
189 params[jss::source_account] = alice.human();
190 params[jss::destination_account] = carol.human();
191 params[jss::destination_amount] = [] {
193 dest_amt[jss::currency] =
"USD";
194 dest_amt[jss::value] =
"1";
200 env.
rpc(
"json",
"ripple_path_find",
to_string(params))};
201 BEAST_EXPECT(resp[jss::result][jss::alternatives].size() == 0);
209 testcase(
"Set default ripple on an account and check new trustlines");
212 Env env(*
this, features);
214 auto const gw =
Account(
"gateway");
215 auto const alice =
Account(
"alice");
216 auto const bob =
Account(
"bob");
222 auto const USD = gw[
"USD"];
224 env(
trust(gw, USD(100), alice, 0));
225 env(
trust(gw, USD(100), bob, 0));
229 params[jss::account] = gw.human();
230 params[jss::peer] = alice.human();
233 auto const& line0 =
lines[jss::result][jss::lines][0u];
234 BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() ==
true);
238 params[jss::account] = alice.human();
239 params[jss::peer] = gw.human();
242 auto const& line0 =
lines[jss::result][jss::lines][0u];
243 BEAST_EXPECT(line0[jss::no_ripple].asBool() ==
true);
247 params[jss::account] = gw.human();
248 params[jss::peer] = bob.human();
251 auto const& line0 =
lines[jss::result][jss::lines][0u];
252 BEAST_EXPECT(line0[jss::no_ripple].asBool() ==
false);
256 params[jss::account] = bob.human();
257 params[jss::peer] = gw.human();
260 auto const& line0 =
lines[jss::result][jss::lines][0u];
261 BEAST_EXPECT(line0[jss::no_ripple_peer].asBool() ==
false);