20 #include <ripple/basics/StringUtilities.h>
21 #include <ripple/protocol/AmountConversions.h>
22 #include <ripple/protocol/Feature.h>
23 #include <ripple/protocol/jss.h>
24 #include <ripple/protocol/Quality.h>
25 #include <ripple/protocol/Rate.h>
36 testcase (
"No AccountSet");
38 using namespace test::jtx;
40 Account
const alice (
"alice");
41 env.fund(XRP(10000), noripple(alice));
43 auto const jrr = env.le(alice);
44 BEAST_EXPECT((*env.le(alice))[
sfFlags ] == 0u);
49 testcase (
"Most Flags");
51 using namespace test::jtx;
52 Account
const alice (
"alice");
56 env.fund(XRP(10000), noripple(alice));
61 env(regkey (alice, alie));
64 auto testFlags = [
this, &alice, &alie, &env]
69 flag < std::numeric_limits<std::uint32_t>::digits; ++flag)
77 else if (
std::find (goodFlags.begin(), goodFlags.end(), flag) !=
81 env.require(nflags(alice, flag));
82 env(fset(alice, flag), sig(alice));
84 env.require(flags(alice, flag));
85 env(fclear(alice, flag), sig(alie));
87 env.require(nflags(alice, flag));
89 BEAST_EXPECT(now_flags == orig_flags);
94 BEAST_EXPECT((*env.le(alice))[
sfFlags ] == orig_flags);
95 env(fset(alice, flag), sig(alice));
97 BEAST_EXPECT((*env.le(alice))[
sfFlags ] == orig_flags);
98 env(fclear(alice, flag), sig(alie));
100 BEAST_EXPECT((*env.le(alice))[
sfFlags ] == orig_flags);
119 testcase (
"Set and reset AccountTxnID");
121 using namespace test::jtx;
123 Account
const alice (
"alice");
124 env.fund(XRP(10000), noripple(alice));
136 BEAST_EXPECT(now_flags == orig_flags);
141 testcase (
"Set NoFreeze");
143 using namespace test::jtx;
145 Account
const alice (
"alice");
146 env.fund(XRP(10000), noripple(alice));
148 env(regkey(alice,
"eric"));
163 using namespace test::jtx;
165 Account
const alice (
"alice");
166 env.fund(XRP(10000), alice);
167 auto jt = noop(alice);
181 BEAST_EXPECT(! env.le(alice)->isFieldPresent(
sfDomain));
187 for (
std::size_t len = maxLength - 1; len <= maxLength + 1; ++len)
192 BEAST_EXPECT (domain2.
length() == len);
196 if (len <= maxLength)
210 testcase (
"MessageKey");
212 using namespace test::jtx;
214 Account
const alice (
"alice");
215 env.fund(XRP(10000), alice);
216 auto jt = noop(alice);
225 BEAST_EXPECT(! env.le(alice)->isFieldPresent(
sfMessageKey));
227 using namespace std::string_literals;
234 testcase (
"WalletID");
236 using namespace test::jtx;
238 Account
const alice (
"alice");
239 env.fund(XRP(10000), alice);
240 auto jt = noop(alice);
242 uint256 somehash = from_hex_text<uint256>(
"9633ec8af54f16b5286db1d7b519ef49eefc050c0c8ac4384f1d88acd1bfdf05");
254 testcase (
"EmailHash");
256 using namespace test::jtx;
258 Account
const alice (
"alice");
259 env.fund(XRP(10000), alice);
260 auto jt = noop(alice);
262 uint128 somehash = from_hex_text<uint128>(
"fff680681c2f5e6095324e2e08838f221a72ab4f");
265 BEAST_EXPECT((*env.le(alice))[
sfEmailHash ] == somehash);
269 BEAST_EXPECT(! env.le(alice)->isFieldPresent(
sfEmailHash));
281 testcase (
"TransferRate");
283 using namespace test::jtx;
287 Env env (*
this, features);
289 Account
const alice (
"alice");
290 env.fund(XRP(10000), alice);
292 for (
auto const& r : testData)
294 env(rate(alice, r.set), ter(r.code));
299 BEAST_EXPECT(r.get == 1.0);
302 r.get * QUALITY_ONE);
306 doTests (supported_amendments(),
320 testcase (
"Gateway");
322 using namespace test::jtx;
324 Account
const alice (
"alice");
325 Account
const bob (
"bob");
326 Account
const gw (
"gateway");
327 auto const USD = gw[
"USD"];
334 env.fund(XRP(10000), gw, alice, bob);
336 env.trust(USD(10), alice, bob);
341 auto const amount = USD(1);
343 auto const amountWithRate =
346 env(pay(gw, alice, USD(10)));
348 env(pay(alice, bob, USD(1)), sendmax(USD(10)));
351 env.require(balance(alice, USD(10) - amountWithRate));
352 env.require(balance(bob, USD(1)));
366 env.fund(XRP(10000), gw, alice, bob);
368 env.trust(USD(10), alice, bob);
381 env.app().openLedger().modify(
392 std::make_shared<SLE>(*sle, sle->key());
399 auto const amount = USD(1);
400 auto const amountWithRate =
405 env(pay(gw, alice, USD(10)));
406 env(pay(alice, bob, amount), sendmax(USD(10)));
408 env.require(balance(alice, USD(10) - amountWithRate));
409 env.require(balance(bob, amount));
415 testcase (
"Bad inputs");
417 using namespace test::jtx;
419 Account
const alice (
"alice");
420 env.fund(XRP(10000), alice);
457 testcase (
"Require auth");
459 using namespace test::jtx;
461 Account
const alice (
"alice");
462 Account
const bob (
"bob");
464 env.fund(XRP(10000), alice);
471 env(signers(alice, 1, { { bob, 1} }));