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/app/misc/NetworkOPs.h>
14#include <xrpld/rpc/RPCCall.h>
15
16#include <xrpl/basics/Slice.h>
17#include <xrpl/basics/contract.h>
18#include <xrpl/basics/scope.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
29#include <memory>
30#include <source_location>
31
32namespace xrpl {
33namespace test {
34namespace jtx {
35
36//------------------------------------------------------------------------------
37
43 : AppBundle()
44{
45 using namespace beast::severities;
46 if (logs)
47 {
48 setDebugLogSink(logs->makeSink("Debug", kFatal));
49 }
50 else
51 {
52 logs = std::make_unique<SuiteLogs>(suite);
53 // Use kFatal threshold to reduce noise from STObject.
55 }
56 auto timeKeeper_ = std::make_unique<ManualTimeKeeper>();
57 timeKeeper = timeKeeper_.get();
58 // Hack so we don't have to call Config::setup
59 HTTPClient::initializeSSLContext(config->SSL_VERIFY_DIR, config->SSL_VERIFY_FILE, config->SSL_VERIFY, debugLog());
60 owned = make_Application(std::move(config), std::move(logs), std::move(timeKeeper_));
61 app = owned.get();
62 app->logs().threshold(thresh);
63 if (!app->setup({}))
64 Throw<std::runtime_error>("Env::AppBundle: setup failed");
65 timeKeeper->set(app->getLedgerMaster().getClosedLedger()->header().closeTime);
66 app->start(false /*don't start timers*/);
67 thread = std::thread([&]() { app->run(); });
68
70}
71
73{
74 client.reset();
75 // Make sure all jobs finish, otherwise tests
76 // might not get the coverage they expect.
77 if (app)
78 {
80 app->signalStop("~AppBundle");
81 }
82 if (thread.joinable())
83 thread.join();
84
85 // Remove the debugLogSink before the suite goes out of scope.
86 setDebugLogSink(nullptr);
87}
88
89//------------------------------------------------------------------------------
90
96
97bool
99{
100 // Round up to next distinguishable value
101 using namespace std::chrono_literals;
102 bool res = true;
103 closeTime += closed()->header().closeTimeResolution - 1s;
104 timeKeeper().set(closeTime);
105 // Go through the rpc interface unless we need to simulate
106 // a specific consensus delay.
107 if (consensusDelay)
108 app().getOPs().acceptLedger(consensusDelay);
109 else
110 {
111 auto resp = rpc("ledger_accept");
112 if (resp["result"]["status"] != std::string("success"))
113 {
114 std::string reason = "internal error";
115 if (resp.isMember("error_what"))
116 reason = resp["error_what"].asString();
117 else if (resp.isMember("error_message"))
118 reason = resp["error_message"].asString();
119 else if (resp.isMember("error"))
120 reason = resp["error"].asString();
121
122 JLOG(journal.error()) << "Env::close() failed: " << reason;
123 res = false;
124 }
125 }
126 timeKeeper().set(closed()->header().closeTime);
127 return res;
128}
129
130void
131Env::memoize(Account const& account)
132{
133 map_.emplace(account.id(), account);
134}
135
136Account const&
137Env::lookup(AccountID const& id) const
138{
139 auto const iter = map_.find(id);
140 if (iter == map_.end())
141 {
142 std::cout << "Unknown account: " << id << "\n";
143 Throw<std::runtime_error>("Env::lookup:: unknown account ID");
144 }
145 return iter->second;
146}
147
148Account const&
149Env::lookup(std::string const& base58ID) const
150{
151 auto const account = parseBase58<AccountID>(base58ID);
152 if (!account)
153 Throw<std::runtime_error>("Env::lookup: invalid account ID");
154 return lookup(*account);
155}
156
158Env::balance(Account const& account) const
159{
160 auto const sle = le(account);
161 if (!sle)
162 return XRP(0);
163 return {sle->getFieldAmount(sfBalance), ""};
164}
165
167Env::balance(Account const& account, Issue const& issue) const
168{
169 if (isXRP(issue.currency))
170 return balance(account);
171 auto const sle = le(keylet::line(account.id(), issue));
172 if (!sle)
173 return {STAmount(issue, 0), account.name()};
174 auto amount = sle->getFieldAmount(sfBalance);
175 amount.setIssuer(issue.account);
176 if (account.id() > issue.account)
177 amount.negate();
178 return {amount, lookup(issue.account).name()};
179}
180
182Env::balance(Account const& account, MPTIssue const& mptIssue) const
183{
184 MPTID const id = mptIssue.getMptID();
185 if (!id)
186 return {STAmount(mptIssue, 0), account.name()};
187
188 AccountID const issuer = mptIssue.getIssuer();
189 if (account.id() == issuer)
190 {
191 // Issuer balance
192 auto const sle = le(keylet::mptIssuance(id));
193 if (!sle)
194 return {STAmount(mptIssue, 0), account.name()};
195
196 // Make it negative
197 STAmount const amount{mptIssue, sle->getFieldU64(sfOutstandingAmount), 0, true};
198 return {amount, lookup(issuer).name()};
199 }
200 else
201 {
202 // Holder balance
203 auto const sle = le(keylet::mptoken(id, account));
204 if (!sle)
205 return {STAmount(mptIssue, 0), account.name()};
206
207 STAmount const amount{mptIssue, sle->getFieldU64(sfMPTAmount)};
208 return {amount, lookup(issuer).name()};
209 }
210}
211
213Env::balance(Account const& account, Asset const& asset) const
214{
215 return std::visit([&](auto const& issue) { return balance(account, issue); }, asset.value());
216}
217
219Env::limit(Account const& account, Issue const& issue) const
220{
221 auto const sle = le(keylet::line(account.id(), issue));
222 if (!sle)
223 return {STAmount(issue, 0), account.name()};
224 auto const aHigh = account.id() > issue.account;
225 if (sle && sle->isFieldPresent(aHigh ? sfLowLimit : sfHighLimit))
226 return {(*sle)[aHigh ? sfLowLimit : sfHighLimit], account.name()};
227 return {STAmount(issue, 0), account.name()};
228}
229
231Env::ownerCount(Account const& account) const
232{
233 auto const sle = le(account);
234 if (!sle)
235 Throw<std::runtime_error>("missing account root");
236 return sle->getFieldU32(sfOwnerCount);
237}
238
240Env::seq(Account const& account) const
241{
242 auto const sle = le(account);
243 if (!sle)
244 Throw<std::runtime_error>("missing account root");
245 return sle->getFieldU32(sfSequence);
246}
247
249Env::le(Account const& account) const
250{
251 return le(keylet::account(account.id()));
252}
253
255Env::le(Keylet const& k) const
256{
257 return current()->read(k);
258}
259
260void
261Env::fund(bool setDefaultRipple, STAmount const& amount, Account const& account)
262{
263 memoize(account);
264 if (setDefaultRipple)
265 {
266 // VFALCO NOTE Is the fee formula correct?
267 apply(
268 pay(master, account, amount + drops(current()->fees().base)),
273 require(flags(account, asfDefaultRipple));
274 }
275 else
276 {
279 }
280 require(jtx::balance(account, amount));
281}
282
283void
284Env::trust(STAmount const& amount, Account const& account)
285{
286 auto const start = balance(account);
288 apply(
289 pay(master, account, drops(current()->fees().base)),
293 test.expect(balance(account) == start);
294}
295
298{
299 auto error = [](ParsedResult& parsed, Json::Value const& object) {
300 // Use an error code that is not used anywhere in the transaction
301 // engine to distinguish this case.
302 parsed.ter = telENV_RPC_FAILED;
303 // Extract information about the error
304 if (!object.isObject())
305 return;
306 if (object.isMember(jss::error_code))
307 parsed.rpcCode = safe_cast<error_code_i>(object[jss::error_code].asInt());
308 if (object.isMember(jss::error_message))
309 parsed.rpcMessage = object[jss::error_message].asString();
310 if (object.isMember(jss::error))
311 parsed.rpcError = object[jss::error].asString();
312 if (object.isMember(jss::error_exception))
313 parsed.rpcException = object[jss::error_exception].asString();
314 };
315 ParsedResult parsed;
316 if (jr.isObject() && jr.isMember(jss::result))
317 {
318 auto const& result = jr[jss::result];
319 if (result.isMember(jss::engine_result_code))
320 {
321 parsed.ter = TER::fromInt(result[jss::engine_result_code].asInt());
322 parsed.rpcCode.emplace(rpcSUCCESS);
323 }
324 else
325 error(parsed, result);
326 }
327 else
328 error(parsed, jr);
329
330 return parsed;
331}
332
333void
335{
336 ParsedResult parsedResult;
337 auto const jr = [&]() {
338 if (jt.stx)
339 {
340 txid_ = jt.stx->getTransactionID();
341 Serializer s;
342 jt.stx->add(s);
343 auto const jr = rpc("submit", strHex(s.slice()));
344
345 parsedResult = parseResult(jr);
346 test.expect(parsedResult.ter, "ter uninitialized!");
347 ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
348
349 return jr;
350 }
351 else
352 {
353 // Parsing failed or the JTx is
354 // otherwise missing the stx field.
355 parsedResult.ter = ter_ = temMALFORMED;
356
357 return Json::Value();
358 }
359 }();
360 return postconditions(jt, parsedResult, jr, loc);
361}
362
363void
365{
366 auto const account = lookup(jt.jv[jss::Account].asString());
367 auto const& passphrase = account.name();
368
369 Json::Value jr;
370 if (params.isNull())
371 {
372 // Use the command line interface
373 auto const jv = to_string(jt.jv);
374 jr = rpc("submit", passphrase, jv);
375 }
376 else
377 {
378 // Use the provided parameters, and go straight
379 // to the (RPC) client.
380 assert(params.isObject());
381 if (!params.isMember(jss::secret) && !params.isMember(jss::key_type) && !params.isMember(jss::seed) &&
382 !params.isMember(jss::seed_hex) && !params.isMember(jss::passphrase))
383 {
384 params[jss::secret] = passphrase;
385 }
386 params[jss::tx_json] = jt.jv;
387 jr = client().invoke("submit", params);
388 }
389
390 if (!txid_.parseHex(jr[jss::result][jss::tx_json][jss::hash].asString()))
391 txid_.zero();
392
393 ParsedResult const parsedResult = parseResult(jr);
394 test.expect(parsedResult.ter, "ter uninitialized!");
395 ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
396
397 return postconditions(jt, parsedResult, jr, loc);
398}
399
400void
401Env::postconditions(JTx const& jt, ParsedResult const& parsed, Json::Value const& jr, std::source_location const& loc)
402{
403 auto const line = jt.testLine ? " (" + to_string(*jt.testLine) + ")" : "";
404 auto const locStr = std::string("(") + loc.file_name() + ":" + to_string(loc.line()) + ")";
405 bool bad = !test.expect(parsed.ter, "apply " + locStr + ": No ter result!" + line);
406 bad =
407 (jt.ter && parsed.ter &&
408 !test.expect(
409 *parsed.ter == *jt.ter,
410 "apply " + locStr + ": Got " + transToken(*parsed.ter) + " (" + transHuman(*parsed.ter) + "); Expected " +
411 transToken(*jt.ter) + " (" + transHuman(*jt.ter) + ")" + line));
412 using namespace std::string_literals;
413 bad = (jt.rpcCode &&
414 !test.expect(
415 parsed.rpcCode == jt.rpcCode->first && parsed.rpcMessage == jt.rpcCode->second,
416 "apply " + locStr + ": Got RPC result "s +
417 (parsed.rpcCode ? RPC::get_error_info(*parsed.rpcCode).token.c_str() : "NO RESULT") + " (" +
418 parsed.rpcMessage + "); Expected " + RPC::get_error_info(jt.rpcCode->first).token.c_str() + " (" +
419 jt.rpcCode->second + ")" + line)) ||
420 bad;
421 // If we have an rpcCode (just checked), then the rpcException check is
422 // optional - the 'error' field may not be defined, but if it is, it must
423 // match rpcError.
424 bad =
425 (jt.rpcException &&
426 !test.expect(
427 (jt.rpcCode && parsed.rpcError.empty()) ||
428 (parsed.rpcError == jt.rpcException->first &&
429 (!jt.rpcException->second || parsed.rpcException == *jt.rpcException->second)),
430 "apply " + locStr + ": Got RPC result "s + parsed.rpcError + " (" + parsed.rpcException + "); Expected " +
431 jt.rpcException->first + " (" + jt.rpcException->second.value_or("n/a") + ")" + line)) ||
432 bad;
433 if (bad)
434 {
435 test.log << pretty(jt.jv) << std::endl;
436 if (jr)
437 test.log << pretty(jr) << std::endl;
438 // Don't check postconditions if
439 // we didn't get the expected result.
440 return;
441 }
442 if (trace_)
443 {
444 if (trace_ > 0)
445 --trace_;
446 test.log << pretty(jt.jv) << std::endl;
447 }
448 for (auto const& f : jt.require)
449 f(*this);
450}
451
454{
455 if (current()->txCount() != 0)
456 {
457 // close the ledger if it has not already been closed
458 // (metadata is not finalized until the ledger is closed)
459 close();
460 }
461 auto const item = closed()->txRead(txid_);
462 auto const result = item.second;
463 if (result == nullptr)
464 {
465 test.log << "Env::meta: no metadata for txid: " << txid_ << std::endl;
466 test.log << "This is probably because the transaction failed with a "
467 "non-tec error."
468 << std::endl;
469 Throw<std::runtime_error>("Env::meta: no metadata for txid");
470 }
471 return result;
472}
473
475Env::tx() const
476{
477 return current()->txRead(txid_).first;
478}
479
480void
482{
483 auto& jv = jt.jv;
484
485 scope_success success([&]() {
486 // Call all the post-signers after the main signers or autofill are done
487 for (auto const& signer : jt.postSigners)
488 signer(*this, jt);
489 });
490
491 // Call all the main signers
492 if (!jt.mainSigners.empty())
493 {
494 for (auto const& signer : jt.mainSigners)
495 signer(*this, jt);
496 return;
497 }
498
499 // If the sig is still needed, get it here.
500 if (!jt.fill_sig)
501 return;
502 auto const account = jv.isMember(sfDelegate.jsonName) ? lookup(jv[sfDelegate.jsonName].asString())
503 : lookup(jv[jss::Account].asString());
504 if (!app().checkSigs())
505 {
506 jv[jss::SigningPubKey] = strHex(account.pk().slice());
507 // dummy sig otherwise STTx is invalid
508 jv[jss::TxnSignature] = "00";
509 return;
510 }
511 auto const ar = le(account);
512 if (ar && ar->isFieldPresent(sfRegularKey))
513 jtx::sign(jv, lookup(ar->getAccountID(sfRegularKey)));
514 else
515 jtx::sign(jv, account);
516}
517
518void
520{
521 auto& jv = jt.jv;
522 if (jt.fill_fee)
523 jtx::fill_fee(jv, *current());
524 if (jt.fill_seq)
525 jtx::fill_seq(jv, *current());
526
527 if (jt.fill_netid)
528 {
529 uint32_t networkID = app().config().NETWORK_ID;
530 if (!jv.isMember(jss::NetworkID) && networkID > 1024)
531 jv[jss::NetworkID] = std::to_string(networkID);
532 }
533
534 // Must come last
535 try
536 {
538 }
539 catch (parse_error const&)
540 {
542 test.log << "parse failed:\n" << pretty(jv) << std::endl;
543 Rethrow();
544 }
545}
546
549{
550 // The parse must succeed, since we
551 // generated the JSON ourselves.
553 try
554 {
555 obj = jtx::parse(jt.jv);
556 }
557 catch (jtx::parse_error const&)
558 {
559 test.log << "Exception: parse_error\n" << pretty(jt.jv) << std::endl;
560 Rethrow();
561 }
562
563 try
564 {
565 return sterilize(STTx{std::move(*obj)});
566 }
567 catch (std::exception const&)
568 {
569 }
570 return nullptr;
571}
572
575{
576 // The parse must succeed, since we
577 // generated the JSON ourselves.
579 try
580 {
581 obj = jtx::parse(jt.jv);
582 }
583 catch (jtx::parse_error const&)
584 {
585 test.log << "Exception: parse_error\n" << pretty(jt.jv) << std::endl;
586 Rethrow();
587 }
588
589 try
590 {
591 return std::make_shared<STTx const>(std::move(*obj));
592 }
593 catch (std::exception const&)
594 {
595 }
596 return nullptr;
597}
598
601 unsigned apiVersion,
602 std::vector<std::string> const& args,
604{
605 auto response = rpcClient(args, app().config(), app().logs(), apiVersion, headers);
606
607 for (unsigned ctr = 0; (ctr < retries_) and (response.first == rpcINTERNAL); ++ctr)
608 {
609 JLOG(journal.error()) << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ...";
611
612 response = rpcClient(args, app().config(), app().logs(), apiVersion, headers);
613 }
614
615 return response.second;
616}
617
618void
620{
621 // Env::close() must be called for feature
622 // enable to take place.
623 app().config().features.insert(feature);
624}
625
626void
628{
629 // Env::close() must be called for feature
630 // enable to take place.
631 app().config().features.erase(feature);
632}
633
634} // namespace jtx
635} // namespace test
636} // 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:318
A testsuite class.
Definition suite.h:51
log_os< char > log
Logging output stream.
Definition suite.h:144
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition suite.h:221
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 Logs & logs()=0
virtual void start(bool withTimers)=0
constexpr value_type const & value() const
Definition Asset.h:154
uint32_t NETWORK_ID
Definition Config.h:137
std::unordered_set< uint256, beast::uhash<> > features
Definition Config.h:256
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:229
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 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 JobQueue & getJobQueue()=0
virtual NetworkOPs & getOPs()=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:471
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:251
static ParsedResult parseResult(Json::Value const &jr)
Gets the TER result and didApply flag from a RPC Json result object.
Definition Env.cpp:297
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:548
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:401
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
Definition Env.cpp:231
void autofill_sig(JTx &jt)
Definition Env.cpp:481
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
Definition Env.cpp:92
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition Env.cpp:249
Account const & lookup(AccountID const &id) const
Returns the Account given the AccountID.
Definition Env.cpp:137
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:261
virtual void submit(JTx const &jt, std::source_location const &loc=std::source_location::current())
Submit an existing JTx.
Definition Env.cpp:334
void enableFeature(uint256 const feature)
Definition Env.cpp:619
PrettyAmount limit(Account const &account, Issue const &issue) const
Returns the IOU limit on an account.
Definition Env.cpp:219
void disableFeature(uint256 const feature)
Definition Env.cpp:627
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:240
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:364
virtual void autofill(JTx &jt)
Definition Env.cpp:519
bool close()
Close and advance the ledger.
Definition Env.h:379
Account const & master
Definition Env.h:123
Json::Value do_rpc(unsigned apiVersion, std::vector< std::string > const &args, std::unordered_map< std::string, std::string > const &headers={})
Definition Env.cpp:600
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
Definition Env.h:494
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition Env.cpp:158
unsigned retries_
Definition Env.h:745
uint256 txid_
Definition Env.h:742
beast::unit_test::suite & test
Definition Env.h:121
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:284
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:574
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
Definition Env.cpp:453
std::unordered_map< AccountID, Account > map_
Definition Env.h:787
Env & apply(WithSourceLocation< Json::Value > jv, FN const &... fN)
Apply funclets and submit.
Definition Env.h:572
ManualTimeKeeper & timeKeeper()
Definition Env.h:263
bool parseFailureExpected_
Definition Env.h:744
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
Definition Env.cpp:475
void memoize(Account const &account)
Associate AccountID with account.
Definition Env.cpp:131
beast::Journal const journal
Definition Env.h:160
AbstractClient & client()
Returns the connected client.
Definition Env.h:281
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:319
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:462
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:214
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:474
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:160
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:90
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:445
std::unique_ptr< beast::Journal::Sink > setDebugLogSink(std::unique_ptr< beast::Journal::Sink > sink)
Set the sink for the debug journal.
Definition Log.cpp:439
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:597
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:1437
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:767
@ 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:185
ManualTimeKeeper * timeKeeper
Definition Env.h:144
std::unique_ptr< AbstractClient > client
Definition Env.h:146
std::unique_ptr< Application > owned
Definition Env.h:143
Used by parseResult() and postConditions()
Definition Env.h:127
std::optional< TER > ter
Definition Env.h:128
std::optional< error_code_i > rpcCode
Definition Env.h:133
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)