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