20 #include <ripple/basics/StringUtilities.h>
21 #include <ripple/protocol/AmountConversions.h>
22 #include <ripple/protocol/Feature.h>
23 #include <ripple/protocol/Quality.h>
24 #include <ripple/protocol/Rate.h>
25 #include <ripple/protocol/jss.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);
50 testcase(
"Most Flags");
52 using namespace test::jtx;
53 Account
const alice(
"alice");
57 env.fund(XRP(10000), noripple(alice));
62 env(regkey(alice, alie));
65 auto testFlags = [
this, &alice, &alie, &env](
69 flag < std::numeric_limits<std::uint32_t>::digits;
79 std::find(goodFlags.begin(), goodFlags.end(), flag) !=
83 env.require(nflags(alice, flag));
84 env(fset(alice, flag), sig(alice));
86 env.require(flags(alice, flag));
87 env(fclear(alice, flag), sig(alie));
89 env.require(nflags(alice, flag));
91 BEAST_EXPECT(now_flags == orig_flags);
96 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
97 env(fset(alice, flag), sig(alice));
99 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
100 env(fclear(alice, flag), sig(alie));
102 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
132 testcase(
"Set and reset AccountTxnID");
134 using namespace test::jtx;
136 Account
const alice(
"alice");
137 env.fund(XRP(10000), noripple(alice));
149 BEAST_EXPECT(now_flags == orig_flags);
155 testcase(
"Set NoFreeze");
157 using namespace test::jtx;
159 Account
const alice(
"alice");
160 env.fund(XRP(10000), noripple(alice));
162 env(regkey(alice,
"eric"));
178 using namespace test::jtx;
180 Account
const alice(
"alice");
181 env.fund(XRP(10000), alice);
182 auto jt = noop(alice);
196 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfDomain));
202 for (
std::size_t len = maxLength - 1; len <= maxLength + 1; ++len)
207 BEAST_EXPECT(domain2.
length() == len);
211 if (len <= maxLength)
226 testcase(
"MessageKey");
228 using namespace test::jtx;
230 Account
const alice(
"alice");
231 env.fund(XRP(10000), alice);
232 auto jt = noop(alice);
239 strHex(rkp.first.slice()));
243 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfMessageKey));
245 using namespace std::string_literals;
253 testcase(
"WalletID");
255 using namespace test::jtx;
257 Account
const alice(
"alice");
258 env.fund(XRP(10000), alice);
259 auto jt = noop(alice);
261 uint256 somehash = from_hex_text<uint256>(
262 "9633ec8af54f16b5286db1d7b519ef49eefc050c0c8ac4384f1d88acd1bfdf05");
275 testcase(
"EmailHash");
277 using namespace test::jtx;
279 Account
const alice(
"alice");
280 env.fund(XRP(10000), alice);
281 auto jt = noop(alice);
284 from_hex_text<uint128>(
"fff680681c2f5e6095324e2e08838f221a72ab4f");
287 BEAST_EXPECT((*env.le(alice))[
sfEmailHash] == somehash);
291 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfEmailHash));
304 testcase(
"TransferRate");
306 using namespace test::jtx;
307 auto doTests = [
this](
310 Env env(*
this, features);
312 Account
const alice(
"alice");
313 env.fund(XRP(10000), alice);
315 for (
auto const& r : testData)
317 env(rate(alice, r.set), ter(r.code));
322 BEAST_EXPECT(r.get == 1.0);
326 r.get * QUALITY_ONE);
331 supported_amendments(),
346 using namespace test::jtx;
348 Account
const alice(
"alice");
349 Account
const bob(
"bob");
350 Account
const gw(
"gateway");
351 auto const USD = gw[
"USD"];
358 env.fund(XRP(10000), gw, alice, bob);
360 env.trust(USD(10), alice, bob);
365 auto const amount = USD(1);
367 auto const amountWithRate =
370 env(pay(gw, alice, USD(10)));
372 env(pay(alice, bob, USD(1)), sendmax(USD(10)));
375 env.require(balance(alice, USD(10) - amountWithRate));
376 env.require(balance(bob, USD(1)));
390 env.fund(XRP(10000), gw, alice, bob);
392 env.trust(USD(10), alice, bob);
405 env.app().openLedger().modify(
414 auto replacement = std::make_shared<SLE>(*sle, sle->key());
421 auto const amount = USD(1);
425 env(pay(gw, alice, USD(10)));
426 env(pay(alice, bob, amount), sendmax(USD(10)));
428 env.require(balance(alice, USD(10) - amountWithRate));
429 env.require(balance(bob, amount));
436 testcase(
"Bad inputs");
438 using namespace test::jtx;
440 Account
const alice(
"alice");
441 env.fund(XRP(10000), alice);
479 testcase(
"Require auth");
481 using namespace test::jtx;
483 Account
const alice(
"alice");
484 Account
const bob(
"bob");
486 env.fund(XRP(10000), alice);
493 env(signers(alice, 1, {{bob, 1}}));