rippled
Loading...
Searching...
No Matches
Env.cpp
1#include <test/jtx/Env.h>
2#include <test/jtx/JSONRPCClient.h>
3#include <test/jtx/balance.h>
4#include <test/jtx/fee.h>
5#include <test/jtx/flags.h>
6#include <test/jtx/pay.h>
7#include <test/jtx/seq.h>
8#include <test/jtx/sig.h>
9#include <test/jtx/trust.h>
10#include <test/jtx/utility.h>
11
12#include <xrpld/app/ledger/LedgerMaster.h>
13#include <xrpld/rpc/RPCCall.h>
14
15#include <xrpl/basics/Slice.h>
16#include <xrpl/basics/contract.h>
17#include <xrpl/basics/scope.h>
18#include <xrpl/core/NetworkIDService.h>
19#include <xrpl/json/to_string.h>
20#include <xrpl/net/HTTPClient.h>
21#include <xrpl/protocol/ErrorCodes.h>
22#include <xrpl/protocol/Indexes.h>
23#include <xrpl/protocol/Serializer.h>
24#include <xrpl/protocol/TER.h>
25#include <xrpl/protocol/TxFlags.h>
26#include <xrpl/protocol/UintTypes.h>
27#include <xrpl/protocol/jss.h>
28#include <xrpl/server/NetworkOPs.h>
29
30#include <memory>
31#include <source_location>
32
33namespace xrpl {
34namespace test {
35namespace jtx {
36
37//------------------------------------------------------------------------------
38
44 : AppBundle()
45{
46 using namespace beast::severities;
47 if (logs)
48 {
49 setDebugLogSink(logs->makeSink("Debug", kFatal));
50 }
51 else
52 {
53 logs = std::make_unique<SuiteLogs>(suite);
54 // Use kFatal threshold to reduce noise from STObject.
56 }
57 auto timeKeeper_ = std::make_unique<ManualTimeKeeper>();
58 timeKeeper = timeKeeper_.get();
59 // Hack so we don't have to call Config::setup
61 config->SSL_VERIFY_DIR, config->SSL_VERIFY_FILE, config->SSL_VERIFY, debugLog());
62 owned = make_Application(std::move(config), std::move(logs), std::move(timeKeeper_));
63 app = owned.get();
64 app->logs().threshold(thresh);
65 if (!app->setup({}))
66 Throw<std::runtime_error>("Env::AppBundle: setup failed");
67 timeKeeper->set(app->getLedgerMaster().getClosedLedger()->header().closeTime);
68 app->start(false /*don't start timers*/);
69 thread = std::thread([&]() { app->run(); });
70
72}
73
75{
76 client.reset();
77 // Make sure all jobs finish, otherwise tests
78 // might not get the coverage they expect.
79 if (app)
80 {
82 app->signalStop("~AppBundle");
83 }
84 if (thread.joinable())
85 thread.join();
86
87 // Remove the debugLogSink before the suite goes out of scope.
88 setDebugLogSink(nullptr);
89}
90
91//------------------------------------------------------------------------------
92
98
99bool
101{
102 // Round up to next distinguishable value
103 using namespace std::chrono_literals;
104 bool res = true;
105 closeTime += closed()->header().closeTimeResolution - 1s;
106 timeKeeper().set(closeTime);
107 // Go through the rpc interface unless we need to simulate
108 // a specific consensus delay.
109 if (consensusDelay)
110 app().getOPs().acceptLedger(consensusDelay);
111 else
112 {
113 auto resp = rpc("ledger_accept");
114 if (resp["result"]["status"] != std::string("success"))
115 {
116 std::string reason = "internal error";
117 if (resp.isMember("error_what"))
118 reason = resp["error_what"].asString();
119 else if (resp.isMember("error_message"))
120 reason = resp["error_message"].asString();
121 else if (resp.isMember("error"))
122 reason = resp["error"].asString();
123
124 JLOG(journal.error()) << "Env::close() failed: " << reason;
125 res = false;
126 }
127 }
128 timeKeeper().set(closed()->header().closeTime);
129 return res;
130}
131
132void
133Env::memoize(Account const& account)
134{
135 map_.emplace(account.id(), account);
136}
137
138Account const&
139Env::lookup(AccountID const& id) const
140{
141 auto const iter = map_.find(id);
142 if (iter == map_.end())
143 {
144 std::cout << "Unknown account: " << id << "\n";
145 Throw<std::runtime_error>("Env::lookup:: unknown account ID");
146 }
147 return iter->second;
148}
149
150Account const&
151Env::lookup(std::string const& base58ID) const
152{
153 auto const account = parseBase58<AccountID>(base58ID);
154 if (!account)
155 Throw<std::runtime_error>("Env::lookup: invalid account ID");
156 return lookup(*account);
157}
158
160Env::balance(Account const& account) const
161{
162 auto const sle = le(account);
163 if (!sle)
164 return XRP(0);
165 return {sle->getFieldAmount(sfBalance), ""};
166}
167
169Env::balance(Account const& account, Issue const& issue) const
170{
171 if (isXRP(issue.currency))
172 return balance(account);
173 auto const sle = le(keylet::line(account.id(), issue));
174 if (!sle)
175 return {STAmount(issue, 0), account.name()};
176 auto amount = sle->getFieldAmount(sfBalance);
177 amount.setIssuer(issue.account);
178 if (account.id() > issue.account)
179 amount.negate();
180 return {amount, lookup(issue.account).name()};
181}
182
184Env::balance(Account const& account, MPTIssue const& mptIssue) const
185{
186 MPTID const id = mptIssue.getMptID();
187 if (!id)
188 return {STAmount(mptIssue, 0), account.name()};
189
190 AccountID const issuer = mptIssue.getIssuer();
191 if (account.id() == issuer)
192 {
193 // Issuer balance
194 auto const sle = le(keylet::mptIssuance(id));
195 if (!sle)
196 return {STAmount(mptIssue, 0), account.name()};
197
198 // Make it negative
199 STAmount const amount{mptIssue, sle->getFieldU64(sfOutstandingAmount), 0, true};
200 return {amount, lookup(issuer).name()};
201 }
202 else
203 {
204 // Holder balance
205 auto const sle = le(keylet::mptoken(id, account));
206 if (!sle)
207 return {STAmount(mptIssue, 0), account.name()};
208
209 STAmount const amount{mptIssue, sle->getFieldU64(sfMPTAmount)};
210 return {amount, lookup(issuer).name()};
211 }
212}
213
215Env::balance(Account const& account, Asset const& asset) const
216{
217 return std::visit([&](auto const& issue) { return balance(account, issue); }, asset.value());
218}
219
221Env::limit(Account const& account, Issue const& issue) const
222{
223 auto const sle = le(keylet::line(account.id(), issue));
224 if (!sle)
225 return {STAmount(issue, 0), account.name()};
226 auto const aHigh = account.id() > issue.account;
227 if (sle && sle->isFieldPresent(aHigh ? sfLowLimit : sfHighLimit))
228 return {(*sle)[aHigh ? sfLowLimit : sfHighLimit], account.name()};
229 return {STAmount(issue, 0), account.name()};
230}
231
233Env::ownerCount(Account const& account) const
234{
235 auto const sle = le(account);
236 if (!sle)
237 Throw<std::runtime_error>("missing account root");
238 return sle->getFieldU32(sfOwnerCount);
239}
240
242Env::seq(Account const& account) const
243{
244 auto const sle = le(account);
245 if (!sle)
246 Throw<std::runtime_error>("missing account root");
247 return sle->getFieldU32(sfSequence);
248}
249
251Env::le(Account const& account) const
252{
253 return le(keylet::account(account.id()));
254}
255
257Env::le(Keylet const& k) const
258{
259 return current()->read(k);
260}
261
262void
263Env::fund(bool setDefaultRipple, STAmount const& amount, Account const& account)
264{
265 memoize(account);
266 if (setDefaultRipple)
267 {
268 // VFALCO NOTE Is the fee formula correct?
269 apply(
270 pay(master, account, amount + drops(current()->fees().base)),
274 apply(
275 fset(account, asfDefaultRipple),
279 require(flags(account, asfDefaultRipple));
280 }
281 else
282 {
283 apply(
284 pay(master, account, amount),
289 }
290 require(jtx::balance(account, amount));
291}
292
293void
294Env::trust(STAmount const& amount, Account const& account)
295{
296 auto const start = balance(account);
297 apply(
298 jtx::trust(account, amount),
302 apply(
303 pay(master, account, drops(current()->fees().base)),
307 test.expect(balance(account) == start);
308}
309
312{
313 auto error = [](ParsedResult& parsed, Json::Value const& object) {
314 // Use an error code that is not used anywhere in the transaction
315 // engine to distinguish this case.
316 parsed.ter = telENV_RPC_FAILED;
317 // Extract information about the error
318 if (!object.isObject())
319 return;
320 if (object.isMember(jss::error_code))
321 parsed.rpcCode = safe_cast<error_code_i>(object[jss::error_code].asInt());
322 if (object.isMember(jss::error_message))
323 parsed.rpcMessage = object[jss::error_message].asString();
324 if (object.isMember(jss::error))
325 parsed.rpcError = object[jss::error].asString();
326 if (object.isMember(jss::error_exception))
327 parsed.rpcException = object[jss::error_exception].asString();
328 };
329 ParsedResult parsed;
330 if (jr.isObject() && jr.isMember(jss::result))
331 {
332 auto const& result = jr[jss::result];
333 if (result.isMember(jss::engine_result_code))
334 {
335 parsed.ter = TER::fromInt(result[jss::engine_result_code].asInt());
336 parsed.rpcCode.emplace(rpcSUCCESS);
337 }
338 else
339 error(parsed, result);
340 }
341 else
342 error(parsed, jr);
343
344 return parsed;
345}
346
347void
349{
350 ParsedResult parsedResult;
351 auto const jr = [&]() {
352 if (jt.stx)
353 {
354 txid_ = jt.stx->getTransactionID();
355 Serializer s;
356 jt.stx->add(s);
357 auto const jr = rpc("submit", strHex(s.slice()));
358
359 parsedResult = parseResult(jr);
360 test.expect(parsedResult.ter, "ter uninitialized!");
361 ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
362
363 return jr;
364 }
365 else
366 {
367 // Parsing failed or the JTx is
368 // otherwise missing the stx field.
369 parsedResult.ter = ter_ = temMALFORMED;
370
371 return Json::Value();
372 }
373 }();
374 return postconditions(jt, parsedResult, jr, loc);
375}
376
377void
379{
380 auto const account = lookup(jt.jv[jss::Account].asString());
381 auto const& passphrase = account.name();
382
383 Json::Value jr;
384 if (params.isNull())
385 {
386 // Use the command line interface
387 auto const jv = to_string(jt.jv);
388 jr = rpc("submit", passphrase, jv);
389 }
390 else
391 {
392 // Use the provided parameters, and go straight
393 // to the (RPC) client.
394 assert(params.isObject());
395 if (!params.isMember(jss::secret) && !params.isMember(jss::key_type) &&
396 !params.isMember(jss::seed) && !params.isMember(jss::seed_hex) &&
397 !params.isMember(jss::passphrase))
398 {
399 params[jss::secret] = passphrase;
400 }
401 params[jss::tx_json] = jt.jv;
402 jr = client().invoke("submit", params);
403 }
404
405 if (!txid_.parseHex(jr[jss::result][jss::tx_json][jss::hash].asString()))
406 txid_.zero();
407
408 ParsedResult const parsedResult = parseResult(jr);
409 test.expect(parsedResult.ter, "ter uninitialized!");
410 ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
411
412 return postconditions(jt, parsedResult, jr, loc);
413}
414
415void
417 JTx const& jt,
418 ParsedResult const& parsed,
419 Json::Value const& jr,
420 std::source_location const& loc)
421{
422 auto const line = jt.testLine ? " (" + to_string(*jt.testLine) + ")" : "";
423 auto const locStr = std::string("(") + loc.file_name() + ":" + to_string(loc.line()) + ")";
424 bool bad = !test.expect(parsed.ter, "apply " + locStr + ": No ter result!" + line);
425 bad =
426 (jt.ter && parsed.ter &&
427 !test.expect(
428 *parsed.ter == *jt.ter,
429 "apply " + locStr + ": Got " + transToken(*parsed.ter) + " (" +
430 transHuman(*parsed.ter) + "); Expected " + transToken(*jt.ter) + " (" +
431 transHuman(*jt.ter) + ")" + line));
432 using namespace std::string_literals;
433 bad = (jt.rpcCode &&
434 !test.expect(
435 parsed.rpcCode == jt.rpcCode->first && parsed.rpcMessage == jt.rpcCode->second,
436 "apply " + locStr + ": Got RPC result "s +
437 (parsed.rpcCode ? RPC::get_error_info(*parsed.rpcCode).token.c_str()
438 : "NO RESULT") +
439 " (" + parsed.rpcMessage + "); Expected " +
440 RPC::get_error_info(jt.rpcCode->first).token.c_str() + " (" +
441 jt.rpcCode->second + ")" + line)) ||
442 bad;
443 // If we have an rpcCode (just checked), then the rpcException check is
444 // optional - the 'error' field may not be defined, but if it is, it must
445 // match rpcError.
446 bad = (jt.rpcException &&
447 !test.expect(
448 (jt.rpcCode && parsed.rpcError.empty()) ||
449 (parsed.rpcError == jt.rpcException->first &&
450 (!jt.rpcException->second || parsed.rpcException == *jt.rpcException->second)),
451 "apply " + locStr + ": Got RPC result "s + parsed.rpcError + " (" +
452 parsed.rpcException + "); Expected " + jt.rpcException->first + " (" +
453 jt.rpcException->second.value_or("n/a") + ")" + line)) ||
454 bad;
455 if (bad)
456 {
457 test.log << pretty(jt.jv) << std::endl;
458 if (jr)
459 test.log << pretty(jr) << std::endl;
460 // Don't check postconditions if
461 // we didn't get the expected result.
462 return;
463 }
464 if (trace_)
465 {
466 if (trace_ > 0)
467 --trace_;
468 test.log << pretty(jt.jv) << std::endl;
469 }
470 for (auto const& f : jt.require)
471 f(*this);
472}
473
476{
477 if (current()->txCount() != 0)
478 {
479 // close the ledger if it has not already been closed
480 // (metadata is not finalized until the ledger is closed)
481 close();
482 }
483 auto const item = closed()->txRead(txid_);
484 auto const result = item.second;
485 if (result == nullptr)
486 {
487 test.log << "Env::meta: no metadata for txid: " << txid_ << std::endl;
488 test.log << "This is probably because the transaction failed with a "
489 "non-tec error."
490 << std::endl;
491 Throw<std::runtime_error>("Env::meta: no metadata for txid");
492 }
493 return result;
494}
495
497Env::tx() const
498{
499 return current()->txRead(txid_).first;
500}
501
502void
504{
505 auto& jv = jt.jv;
506
507 scope_success success([&]() {
508 // Call all the post-signers after the main signers or autofill are done
509 for (auto const& signer : jt.postSigners)
510 signer(*this, jt);
511 });
512
513 // Call all the main signers
514 if (!jt.mainSigners.empty())
515 {
516 for (auto const& signer : jt.mainSigners)
517 signer(*this, jt);
518 return;
519 }
520
521 // If the sig is still needed, get it here.
522 if (!jt.fill_sig)
523 return;
524 auto const account = jv.isMember(sfDelegate.jsonName)
525 ? lookup(jv[sfDelegate.jsonName].asString())
526 : lookup(jv[jss::Account].asString());
527 if (!app().checkSigs())
528 {
529 jv[jss::SigningPubKey] = strHex(account.pk().slice());
530 // dummy sig otherwise STTx is invalid
531 jv[jss::TxnSignature] = "00";
532 return;
533 }
534 auto const ar = le(account);
535 if (ar && ar->isFieldPresent(sfRegularKey))
536 jtx::sign(jv, lookup(ar->getAccountID(sfRegularKey)));
537 else
538 jtx::sign(jv, account);
539}
540
541void
543{
544 auto& jv = jt.jv;
545 if (jt.fill_fee)
546 jtx::fill_fee(jv, *current());
547 if (jt.fill_seq)
548 jtx::fill_seq(jv, *current());
549
550 if (jt.fill_netid)
551 {
552 uint32_t networkID = app().getNetworkIDService().getNetworkID();
553 if (!jv.isMember(jss::NetworkID) && networkID > 1024)
554 jv[jss::NetworkID] = std::to_string(networkID);
555 }
556
557 // Must come last
558 try
559 {
561 }
562 catch (parse_error const&)
563 {
565 test.log << "parse failed:\n" << pretty(jv) << std::endl;
566 Rethrow();
567 }
568}
569
572{
573 // The parse must succeed, since we
574 // generated the JSON ourselves.
576 try
577 {
578 obj = jtx::parse(jt.jv);
579 }
580 catch (jtx::parse_error const&)
581 {
582 test.log << "Exception: parse_error\n" << pretty(jt.jv) << std::endl;
583 Rethrow();
584 }
585
586 try
587 {
588 return sterilize(STTx{std::move(*obj)});
589 }
590 catch (std::exception const&)
591 {
592 }
593 return nullptr;
594}
595
598{
599 // The parse must succeed, since we
600 // generated the JSON ourselves.
602 try
603 {
604 obj = jtx::parse(jt.jv);
605 }
606 catch (jtx::parse_error const&)
607 {
608 test.log << "Exception: parse_error\n" << pretty(jt.jv) << std::endl;
609 Rethrow();
610 }
611
612 try
613 {
614 return std::make_shared<STTx const>(std::move(*obj));
615 }
616 catch (std::exception const&)
617 {
618 }
619 return nullptr;
620}
621
624 unsigned apiVersion,
625 std::vector<std::string> const& args,
627{
628 auto response = rpcClient(args, app().config(), app().logs(), apiVersion, headers);
629
630 for (unsigned ctr = 0; (ctr < retries_) and (response.first == rpcINTERNAL); ++ctr)
631 {
632 JLOG(journal.error()) << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ...";
634
635 response = rpcClient(args, app().config(), app().logs(), apiVersion, headers);
636 }
637
638 return response.second;
639}
640
641void
643{
644 // Env::close() must be called for feature
645 // enable to take place.
646 app().config().features.insert(feature);
647}
648
649void
651{
652 // Env::close() must be called for feature
653 // enable to take place.
654 app().config().features.erase(feature);
655}
656
657} // namespace jtx
658} // namespace test
659} // namespace xrpl
constexpr char const * c_str() const
Definition json_value.h:57
Represents a JSON value.
Definition json_value.h:130
bool isObject() const
std::string asString() const
Returns the unquoted string value.
bool isNull() const
isNull() tests to see if this field is null.
bool isMember(char const *key) const
Return true if the object has a member named key.
Stream error() const
Definition Journal.h:319
A testsuite class.
Definition suite.h:51
log_os< char > log
Logging output stream.
Definition suite.h:147
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition suite.h:224
virtual bool setup(boost::program_options::variables_map const &options)=0
virtual Config & config()=0
virtual void signalStop(std::string msg)=0
virtual void run()=0
virtual void start(bool withTimers)=0
constexpr value_type const & value() const
Definition Asset.h:154
std::unordered_set< uint256, beast::uhash<> > features
Definition Config.h:257
static void initializeSSLContext(std::string const &sslVerifyDir, std::string const &sslVerifyFile, bool sslVerify, beast::Journal j)
A currency issued by an account.
Definition Issue.h:13
Currency currency
Definition Issue.h:15
AccountID account
Definition Issue.h:16
void rendezvous()
Block until no jobs running.
Definition JobQueue.cpp:233
std::shared_ptr< Ledger const > getClosedLedger()
beast::severities::Severity threshold() const
Definition Log.cpp:140
constexpr MPTID const & getMptID() const
Definition MPTIssue.h:26
AccountID const & getIssuer() const
Definition MPTIssue.cpp:21
virtual std::uint32_t getNetworkID() const noexcept=0
Get the configured network ID.
virtual std::uint32_t acceptLedger(std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)=0
Accepts the current transaction tree, return the new ledger's sequence.
Slice slice() const noexcept
Definition Serializer.h:44
virtual Logs & logs()=0
virtual JobQueue & getJobQueue()=0
virtual NetworkOPs & getOPs()=0
virtual NetworkIDService & getNetworkIDService()=0
virtual LedgerMaster & getLedgerMaster()=0
static constexpr TERSubset fromInt(int from)
Definition TER.h:413
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Definition base_uint.h:474
virtual Json::Value invoke(std::string const &cmd, Json::Value const &params={})=0
Submit a command synchronously.
Immutable cryptographic account descriptor.
Definition Account.h:19
std::string const & name() const
Return the name.
Definition Account.h:63
Application & app()
Definition Env.h:258
static ParsedResult parseResult(Json::Value const &jr)
Gets the TER result and didApply flag from a RPC Json result object.
Definition Env.cpp:311
std::shared_ptr< STTx const > st(JTx const &jt)
Create a STTx from a JTx The framework requires that JSON is valid.
Definition Env.cpp:571
void postconditions(JTx const &jt, ParsedResult const &parsed, Json::Value const &jr=Json::Value(), std::source_location const &loc=std::source_location::current())
Check expected postconditions of JTx submission.
Definition Env.cpp:416
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
Definition Env.cpp:233
void autofill_sig(JTx &jt)
Definition Env.cpp:503
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
Definition Env.cpp:94
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition Env.cpp:251
Account const & lookup(AccountID const &id) const
Returns the Account given the AccountID.
Definition Env.cpp:139
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:263
virtual void submit(JTx const &jt, std::source_location const &loc=std::source_location::current())
Submit an existing JTx.
Definition Env.cpp:348
void enableFeature(uint256 const feature)
Definition Env.cpp:642
PrettyAmount limit(Account const &account, Issue const &issue) const
Returns the IOU limit on an account.
Definition Env.cpp:221
void disableFeature(uint256 const feature)
Definition Env.cpp:650
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:242
void sign_and_submit(JTx const &jt, Json::Value params=Json::nullValue, std::source_location const &loc=std::source_location::current())
Use the submit RPC command with a provided JTx object.
Definition Env.cpp:378
virtual void autofill(JTx &jt)
Definition Env.cpp:542
bool close()
Close and advance the ledger.
Definition Env.h:390
Account const & master
Definition Env.h:125
Json::Value do_rpc(unsigned apiVersion, std::vector< std::string > const &args, std::unordered_map< std::string, std::string > const &headers={})
Definition Env.cpp:623
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
Definition Env.h:505
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition Env.cpp:160
unsigned retries_
Definition Env.h:756
uint256 txid_
Definition Env.h:753
beast::unit_test::suite & test
Definition Env.h:123
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:294
std::shared_ptr< STTx const > ust(JTx const &jt)
Create a STTx from a JTx without sanitizing Use to inject bogus values into test transactions by firs...
Definition Env.cpp:597
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
Definition Env.cpp:475
std::unordered_map< AccountID, Account > map_
Definition Env.h:798
Env & apply(WithSourceLocation< Json::Value > jv, FN const &... fN)
Apply funclets and submit.
Definition Env.h:583
ManualTimeKeeper & timeKeeper()
Definition Env.h:270
bool parseFailureExpected_
Definition Env.h:755
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
Definition Env.cpp:497
void memoize(Account const &account)
Associate AccountID with account.
Definition Env.cpp:133
beast::Journal const journal
Definition Env.h:162
AbstractClient & client()
Returns the connected client.
Definition Env.h:288
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:328
A balance matches.
Definition balance.h:19
Set the fee on a JTx.
Definition fee.h:17
Match set account flags.
Definition flags.h:108
Match clear account flags.
Definition flags.h:124
Check a set of conditions.
Definition require.h:46
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition rpc.h:15
Set the regular signature on a JTx.
Definition sig.h:15
T emplace(T... args)
T empty(T... args)
T endl(T... args)
T file_name(T... args)
T is_same_v
A namespace for easy access to logging severity values.
Definition Journal.h:10
Severity
Severity level / threshold of a Journal message.
Definition Journal.h:12
ErrorInfo const & get_error_info(error_code_i code)
Returns an ErrorInfo that reflects the error code.
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:474
Keylet line(AccountID const &id0, AccountID const &id1, Currency const &currency) noexcept
The index of a trust line for a given currency.
Definition Indexes.cpp:220
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:486
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
void fill_seq(Json::Value &jv, ReadView const &view)
Set the sequence number automatically.
Definition utility.cpp:52
Json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:13
XRP_t const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:91
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:11
static autofill_t const autofill
Definition tags.h:22
void sign(Json::Value &jv, Account const &account, Json::Value &sigObject)
Sign automatically into a specific Json field of the jv object.
Definition utility.cpp:27
STObject parse(Json::Value const &jv)
Convert JSON to STObject.
Definition utility.cpp:18
auto const amount
void fill_fee(Json::Value &jv, ReadView const &view)
Set the fee automatically.
Definition utility.cpp:44
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition flags.cpp:10
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
std::unique_ptr< AbstractClient > makeJSONRPCClient(Config const &cfg, unsigned rpc_version)
Returns a client using JSON-RPC over HTTP/S.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ telENV_RPC_FAILED
Definition TER.h:48
bool isXRP(AccountID const &c)
Definition AccountID.h:70
beast::Journal debugLog()
Returns a debug journal.
Definition Log.cpp:449
std::unique_ptr< beast::Journal::Sink > setDebugLogSink(std::unique_ptr< beast::Journal::Sink > sink)
Set the sink for the debug journal.
Definition Log.cpp:443
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:600
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:10
std::string transHuman(TER code)
Definition TER.cpp:252
std::pair< int, Json::Value > rpcClient(std::vector< std::string > const &args, Config const &config, Logs &logs, unsigned int apiVersion, std::unordered_map< std::string, std::string > const &headers)
Internal invocation of RPC client.
Definition RPCCall.cpp:1449
std::string transToken(TER code)
Definition TER.cpp:243
std::unique_ptr< Application > make_Application(std::unique_ptr< Config > config, std::unique_ptr< Logs > logs, std::unique_ptr< TimeKeeper > timeKeeper)
constexpr std::uint32_t asfDefaultRipple
Definition TxFlags.h:64
@ temMALFORMED
Definition TER.h:67
void Rethrow()
Rethrow the exception currently being handled.
Definition contract.h:28
std::shared_ptr< STTx const > sterilize(STTx const &stx)
Sterilize a transaction.
Definition STTx.cpp:782
@ rpcINTERNAL
Definition ErrorCodes.h:110
@ rpcSUCCESS
Definition ErrorCodes.h:24
T sleep_for(T... args)
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
Json::StaticString token
Definition ErrorCodes.h:190
ManualTimeKeeper * timeKeeper
Definition Env.h:146
std::unique_ptr< AbstractClient > client
Definition Env.h:148
std::unique_ptr< Application > owned
Definition Env.h:145
Used by parseResult() and postConditions()
Definition Env.h:129
std::optional< TER > ter
Definition Env.h:130
std::optional< error_code_i > rpcCode
Definition Env.h:135
Execution context for applying a JSON transaction.
Definition JTx.h:25
std::optional< TER > ter
Definition JTx.h:28
std::vector< std::function< void(Env &, JTx &)> > postSigners
Definition JTx.h:40
std::vector< std::function< void(Env &, JTx &)> > mainSigners
Definition JTx.h:37
requires_t require
Definition JTx.h:27
std::shared_ptr< STTx const > stx
Definition JTx.h:35
std::optional< std::pair< error_code_i, std::string > > rpcCode
Definition JTx.h:29
std::optional< std::pair< std::string, std::optional< std::string > > > rpcException
Definition JTx.h:30
std::optional< int > testLine
Definition JTx.h:43
Json::Value jv
Definition JTx.h:26
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
Thrown when parse fails.
Definition utility.h:18
Set the sequence number on a JTx.
Definition seq.h:14
A signer in a SignerList.
Definition multisign.h:19
T to_string(T... args)
T value_or(T... args)
T visit(T... args)