rippled
Loading...
Searching...
No Matches
Env.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <test/jtx/Env.h>
21#include <test/jtx/JSONRPCClient.h>
22#include <test/jtx/balance.h>
23#include <test/jtx/fee.h>
24#include <test/jtx/flags.h>
25#include <test/jtx/pay.h>
26#include <test/jtx/require.h>
27#include <test/jtx/seq.h>
28#include <test/jtx/sig.h>
29#include <test/jtx/trust.h>
30#include <test/jtx/utility.h>
31#include <xrpld/app/ledger/LedgerMaster.h>
32#include <xrpld/app/misc/NetworkOPs.h>
33#include <xrpld/app/misc/TxQ.h>
34#include <xrpld/consensus/LedgerTiming.h>
35#include <xrpld/net/HTTPClient.h>
36#include <xrpld/net/RPCCall.h>
37#include <xrpl/basics/Slice.h>
38#include <xrpl/basics/contract.h>
39#include <xrpl/json/to_string.h>
40#include <xrpl/protocol/ErrorCodes.h>
41#include <xrpl/protocol/Feature.h>
42#include <xrpl/protocol/HashPrefix.h>
43#include <xrpl/protocol/Indexes.h>
44#include <xrpl/protocol/LedgerFormats.h>
45#include <xrpl/protocol/Serializer.h>
46#include <xrpl/protocol/SystemParameters.h>
47#include <xrpl/protocol/TER.h>
48#include <xrpl/protocol/TxFlags.h>
49#include <xrpl/protocol/UintTypes.h>
50#include <xrpl/protocol/jss.h>
51#include <memory>
52
53namespace ripple {
54namespace test {
55namespace jtx {
56
57//------------------------------------------------------------------------------
58
64 : AppBundle()
65{
66 using namespace beast::severities;
67 if (logs)
68 {
69 setDebugLogSink(logs->makeSink("Debug", kFatal));
70 }
71 else
72 {
73 logs = std::make_unique<SuiteLogs>(suite);
74 // Use kFatal threshold to reduce noise from STObject.
76 std::make_unique<SuiteJournalSink>("Debug", kFatal, suite));
77 }
78 auto timeKeeper_ = std::make_unique<ManualTimeKeeper>();
79 timeKeeper = timeKeeper_.get();
80 // Hack so we don't have to call Config::setup
83 std::move(config), std::move(logs), std::move(timeKeeper_));
84 app = owned.get();
85 app->logs().threshold(thresh);
86 if (!app->setup({}))
87 Throw<std::runtime_error>("Env::AppBundle: setup failed");
88 timeKeeper->set(app->getLedgerMaster().getClosedLedger()->info().closeTime);
89 app->start(false /*don't start timers*/);
90 thread = std::thread([&]() { app->run(); });
91
93}
94
96{
97 client.reset();
98 // Make sure all jobs finish, otherwise tests
99 // might not get the coverage they expect.
100 if (app)
101 {
103 app->signalStop();
104 }
105 if (thread.joinable())
106 thread.join();
107
108 // Remove the debugLogSink before the suite goes out of scope.
109 setDebugLogSink(nullptr);
110}
111
112//------------------------------------------------------------------------------
113
116{
118}
119
120bool
122 NetClock::time_point closeTime,
124{
125 // Round up to next distinguishable value
126 using namespace std::chrono_literals;
127 bool res = true;
128 closeTime += closed()->info().closeTimeResolution - 1s;
129 timeKeeper().set(closeTime);
130 // Go through the rpc interface unless we need to simulate
131 // a specific consensus delay.
132 if (consensusDelay)
133 app().getOPs().acceptLedger(consensusDelay);
134 else
135 {
136 auto resp = rpc("ledger_accept");
137 if (resp["result"]["status"] != std::string("success"))
138 {
139 std::string reason = "internal error";
140 if (resp.isMember("error_what"))
141 reason = resp["error_what"].asString();
142 else if (resp.isMember("error_message"))
143 reason = resp["error_message"].asString();
144 else if (resp.isMember("error"))
145 reason = resp["error"].asString();
146
147 JLOG(journal.error()) << "Env::close() failed: " << reason;
148 res = false;
149 }
150 }
151 timeKeeper().set(closed()->info().closeTime);
152 return res;
153}
154
155void
156Env::memoize(Account const& account)
157{
158 map_.emplace(account.id(), account);
159}
160
161Account const&
162Env::lookup(AccountID const& id) const
163{
164 auto const iter = map_.find(id);
165 if (iter == map_.end())
166 {
167 std::cout << "Unknown account: " << id << "\n";
168 Throw<std::runtime_error>("Env::lookup:: unknown account ID");
169 }
170 return iter->second;
171}
172
173Account const&
174Env::lookup(std::string const& base58ID) const
175{
176 auto const account = parseBase58<AccountID>(base58ID);
177 if (!account)
178 Throw<std::runtime_error>("Env::lookup: invalid account ID");
179 return lookup(*account);
180}
181
183Env::balance(Account const& account) const
184{
185 auto const sle = le(account);
186 if (!sle)
187 return XRP(0);
188 return {sle->getFieldAmount(sfBalance), ""};
189}
190
192Env::balance(Account const& account, Issue const& issue) const
193{
194 if (isXRP(issue.currency))
195 return balance(account);
196 auto const sle = le(keylet::line(account.id(), issue));
197 if (!sle)
198 return {STAmount(issue, 0), account.name()};
199 auto amount = sle->getFieldAmount(sfBalance);
200 amount.setIssuer(issue.account);
201 if (account.id() > issue.account)
202 amount.negate();
203 return {amount, lookup(issue.account).name()};
204}
205
207Env::ownerCount(Account const& account) const
208{
209 auto const sle = le(account);
210 if (!sle)
211 Throw<std::runtime_error>("missing account root");
212 return sle->getFieldU32(sfOwnerCount);
213}
214
216Env::seq(Account const& account) const
217{
218 auto const sle = le(account);
219 if (!sle)
220 Throw<std::runtime_error>("missing account root");
221 return sle->getFieldU32(sfSequence);
222}
223
225Env::le(Account const& account) const
226{
227 return le(keylet::account(account.id()));
228}
229
231Env::le(Keylet const& k) const
232{
233 return current()->read(k);
234}
235
236void
237Env::fund(bool setDefaultRipple, STAmount const& amount, Account const& account)
238{
239 memoize(account);
240 if (setDefaultRipple)
241 {
242 // VFALCO NOTE Is the fee formula correct?
243 apply(
244 pay(master, account, amount + drops(current()->fees().base)),
248 apply(
249 fset(account, asfDefaultRipple),
253 require(flags(account, asfDefaultRipple));
254 }
255 else
256 {
257 apply(
258 pay(master, account, amount),
263 }
264 require(jtx::balance(account, amount));
265}
266
267void
268Env::trust(STAmount const& amount, Account const& account)
269{
270 auto const start = balance(account);
271 apply(
272 jtx::trust(account, amount),
276 apply(
277 pay(master, account, drops(current()->fees().base)),
281 test.expect(balance(account) == start);
282}
283
286{
287 auto error = [](ParsedResult& parsed, Json::Value const& object) {
288 // Use an error code that is not used anywhere in the transaction
289 // engine to distinguish this case.
290 parsed.ter = telENV_RPC_FAILED;
291 // Extract information about the error
292 if (!object.isObject())
293 return;
294 if (object.isMember(jss::error_code))
295 parsed.rpcCode =
296 safe_cast<error_code_i>(object[jss::error_code].asInt());
297 if (object.isMember(jss::error_message))
298 parsed.rpcMessage = object[jss::error_message].asString();
299 if (object.isMember(jss::error))
300 parsed.rpcError = object[jss::error].asString();
301 if (object.isMember(jss::error_exception))
302 parsed.rpcException = object[jss::error_exception].asString();
303 };
304 ParsedResult parsed;
305 if (jr.isObject() && jr.isMember(jss::result))
306 {
307 auto const& result = jr[jss::result];
308 if (result.isMember(jss::engine_result_code))
309 {
310 parsed.ter = TER::fromInt(result[jss::engine_result_code].asInt());
311 parsed.rpcCode.emplace(rpcSUCCESS);
312 }
313 else
314 error(parsed, result);
315 }
316 else
317 error(parsed, jr);
318
319 return parsed;
320}
321
322void
324{
325 ParsedResult parsedResult;
326 auto const jr = [&]() {
327 if (jt.stx)
328 {
329 txid_ = jt.stx->getTransactionID();
330 Serializer s;
331 jt.stx->add(s);
332 auto const jr = rpc("submit", strHex(s.slice()));
333
334 parsedResult = parseResult(jr);
335 test.expect(parsedResult.ter, "ter uninitialized!");
336 ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
337
338 return jr;
339 }
340 else
341 {
342 // Parsing failed or the JTx is
343 // otherwise missing the stx field.
344 parsedResult.ter = ter_ = temMALFORMED;
345
346 return Json::Value();
347 }
348 }();
349 return postconditions(jt, parsedResult, jr);
350}
351
352void
354{
355 auto const account = lookup(jt.jv[jss::Account].asString());
356 auto const& passphrase = account.name();
357
358 Json::Value jr;
359 if (params.isNull())
360 {
361 // Use the command line interface
362 auto const jv = boost::lexical_cast<std::string>(jt.jv);
363 jr = rpc("submit", passphrase, jv);
364 }
365 else
366 {
367 // Use the provided parameters, and go straight
368 // to the (RPC) client.
369 assert(params.isObject());
370 if (!params.isMember(jss::secret) && !params.isMember(jss::key_type) &&
371 !params.isMember(jss::seed) && !params.isMember(jss::seed_hex) &&
372 !params.isMember(jss::passphrase))
373 {
374 params[jss::secret] = passphrase;
375 }
376 params[jss::tx_json] = jt.jv;
377 jr = client().invoke("submit", params);
378 }
379
380 if (!txid_.parseHex(jr[jss::result][jss::tx_json][jss::hash].asString()))
381 txid_.zero();
382
383 ParsedResult const parsedResult = parseResult(jr);
384 test.expect(parsedResult.ter, "ter uninitialized!");
385 ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED);
386
387 return postconditions(jt, parsedResult, jr);
388}
389
390void
392 JTx const& jt,
393 ParsedResult const& parsed,
394 Json::Value const& jr)
395{
396 bool bad = !test.expect(parsed.ter, "apply: No ter result!");
397 bad =
398 (jt.ter && parsed.ter &&
399 !test.expect(
400 *parsed.ter == *jt.ter,
401 "apply: Got " + transToken(*parsed.ter) + " (" +
402 transHuman(*parsed.ter) + "); Expected " +
403 transToken(*jt.ter) + " (" + transHuman(*jt.ter) + ")"));
404 using namespace std::string_literals;
405 bad = (jt.rpcCode &&
406 !test.expect(
407 parsed.rpcCode == jt.rpcCode->first &&
408 parsed.rpcMessage == jt.rpcCode->second,
409 "apply: Got RPC result "s +
410 (parsed.rpcCode
412 : "NO RESULT") +
413 " (" + parsed.rpcMessage + "); Expected " +
414 RPC::get_error_info(jt.rpcCode->first).token.c_str() + " (" +
415 jt.rpcCode->second + ")")) ||
416 bad;
417 // If we have an rpcCode (just checked), then the rpcException check is
418 // optional - the 'error' field may not be defined, but if it is, it must
419 // match rpcError.
420 bad =
421 (jt.rpcException &&
422 !test.expect(
423 (jt.rpcCode && parsed.rpcError.empty()) ||
424 (parsed.rpcError == jt.rpcException->first &&
425 (!jt.rpcException->second ||
426 parsed.rpcException == *jt.rpcException->second)),
427 "apply: Got RPC result "s + parsed.rpcError + " (" +
428 parsed.rpcException + "); Expected " + jt.rpcException->first +
429 " (" + jt.rpcException->second.value_or("n/a") + ")")) ||
430 bad;
431 if (bad)
432 {
433 test.log << pretty(jt.jv) << std::endl;
434 if (jr)
435 test.log << pretty(jr) << std::endl;
436 // Don't check postconditions if
437 // we didn't get the expected result.
438 return;
439 }
440 if (trace_)
441 {
442 if (trace_ > 0)
443 --trace_;
444 test.log << pretty(jt.jv) << std::endl;
445 }
446 for (auto const& f : jt.require)
447 f(*this);
448}
449
452{
453 close();
454 auto const item = closed()->txRead(txid_);
455 return item.second;
456}
457
459Env::tx() const
460{
461 return current()->txRead(txid_).first;
462}
463
464void
466{
467 auto& jv = jt.jv;
468 if (jt.signer)
469 return jt.signer(*this, jt);
470 if (!jt.fill_sig)
471 return;
472 auto const account = lookup(jv[jss::Account].asString());
473 if (!app().checkSigs())
474 {
475 jv[jss::SigningPubKey] = strHex(account.pk().slice());
476 // dummy sig otherwise STTx is invalid
477 jv[jss::TxnSignature] = "00";
478 return;
479 }
480 auto const ar = le(account);
481 if (ar && ar->isFieldPresent(sfRegularKey))
482 jtx::sign(jv, lookup(ar->getAccountID(sfRegularKey)));
483 else
484 jtx::sign(jv, account);
485}
486
487void
489{
490 auto& jv = jt.jv;
491 if (jt.fill_fee)
492 jtx::fill_fee(jv, *current());
493 if (jt.fill_seq)
494 jtx::fill_seq(jv, *current());
495
496 uint32_t networkID = app().config().NETWORK_ID;
497 if (!jv.isMember(jss::NetworkID) && networkID > 1024)
498 jv[jss::NetworkID] = std::to_string(networkID);
499
500 // Must come last
501 try
502 {
504 }
505 catch (parse_error const&)
506 {
508 test.log << "parse failed:\n" << pretty(jv) << std::endl;
509 Rethrow();
510 }
511}
512
515{
516 // The parse must succeed, since we
517 // generated the JSON ourselves.
519 try
520 {
521 obj = jtx::parse(jt.jv);
522 }
523 catch (jtx::parse_error const&)
524 {
525 test.log << "Exception: parse_error\n" << pretty(jt.jv) << std::endl;
526 Rethrow();
527 }
528
529 try
530 {
531 return sterilize(STTx{std::move(*obj)});
532 }
533 catch (std::exception const&)
534 {
535 }
536 return nullptr;
537}
538
541{
542 // The parse must succeed, since we
543 // generated the JSON ourselves.
545 try
546 {
547 obj = jtx::parse(jt.jv);
548 }
549 catch (jtx::parse_error const&)
550 {
551 test.log << "Exception: parse_error\n" << pretty(jt.jv) << std::endl;
552 Rethrow();
553 }
554
555 try
556 {
557 return std::make_shared<STTx const>(std::move(*obj));
558 }
559 catch (std::exception const&)
560 {
561 }
562 return nullptr;
563}
564
567 unsigned apiVersion,
568 std::vector<std::string> const& args,
570{
571 auto response =
572 rpcClient(args, app().config(), app().logs(), apiVersion, headers);
573
574 for (unsigned ctr = 0; (ctr < retries_) and (response.first == rpcINTERNAL);
575 ++ctr)
576 {
577 JLOG(journal.error())
578 << "Env::do_rpc error, retrying, attempt #" << ctr + 1 << " ...";
580
581 response =
582 rpcClient(args, app().config(), app().logs(), apiVersion, headers);
583 }
584
585 return response.second;
586}
587
588void
590{
591 // Env::close() must be called for feature
592 // enable to take place.
593 app().config().features.insert(feature);
594}
595
596void
598{
599 // Env::close() must be called for feature
600 // enable to take place.
601 app().config().features.erase(feature);
602}
603
604} // namespace jtx
605
606} // namespace test
607} // namespace ripple
constexpr const char * c_str() const
Definition: json_value.h:74
Represents a JSON value.
Definition: json_value.h:147
bool isObject() const
std::string asString() const
Returns the unquoted string value.
Definition: json_value.cpp:469
bool isNull() const
isNull() tests to see if this field is null.
Definition: json_value.cpp:980
bool isMember(const char *key) const
Return true if the object has a member named key.
Definition: json_value.cpp:943
Stream error() const
Definition: Journal.h:335
A testsuite class.
Definition: suite.h:53
log_os< char > log
Logging output stream.
Definition: suite.h:150
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition: suite.h:227
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 void signalStop(std::string msg="")=0
virtual LedgerMaster & getLedgerMaster()=0
virtual Logs & logs()=0
uint32_t NETWORK_ID
Definition: Config.h:163
std::unordered_set< uint256, beast::uhash<> > features
Definition: Config.h:284
static void initializeSSLContext(Config const &config, beast::Journal j)
Definition: HTTPClient.cpp:38
A currency issued by an account.
Definition: Issue.h:36
AccountID account
Definition: Issue.h:39
Currency currency
Definition: Issue.h:38
void rendezvous()
Block until no jobs running.
Definition: JobQueue.cpp:271
std::shared_ptr< Ledger const > getClosedLedger()
Definition: LedgerMaster.h:80
beast::severities::Severity threshold() const
Definition: Log.cpp:150
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:66
static constexpr TERSubset fromInt(int from)
Definition: TER.h:411
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Definition: base_uint.h:502
virtual Json::Value invoke(std::string const &cmd, Json::Value const &params={})=0
Submit a command synchronously.
Immutable cryptographic account descriptor.
Definition: Account.h:38
std::string const & name() const
Return the name.
Definition: Account.h:82
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
Definition: Env.cpp:115
void disableFeature(uint256 const feature)
Definition: Env.cpp:597
bool parseFailureExpected_
Definition: Env.h:716
static ParsedResult parseResult(Json::Value const &jr)
Gets the TER result and didApply flag from a RPC Json result object.
Definition: Env.cpp:285
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
Definition: Env.cpp:207
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition: Env.cpp:216
std::unordered_map< AccountID, Account > map_
Definition: Env.h:759
beast::unit_test::suite & test
Definition: Env.h:119
std::shared_ptr< STTx const > tx() const
Return the tx data for the last JTx.
Definition: Env.cpp:459
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition: Env.h:325
void postconditions(JTx const &jt, ParsedResult const &parsed, Json::Value const &jr=Json::Value())
Check expected postconditions of JTx submission.
Definition: Env.cpp:391
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:353
virtual void autofill(JTx &jt)
Definition: Env.cpp:488
AbstractClient & client()
Returns the connected client.
Definition: Env.h:285
void autofill_sig(JTx &jt)
Definition: Env.cpp:465
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition: Env.cpp:268
Json::Value do_rpc(unsigned apiVersion, std::vector< std::string > const &args, std::unordered_map< std::string, std::string > const &headers={})
Definition: Env.cpp:566
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:514
void enableFeature(uint256 const feature)
Definition: Env.cpp:589
Account const & master
Definition: Env.h:121
Account const & lookup(AccountID const &id) const
Returns the Account given the AccountID.
Definition: Env.cpp:162
unsigned retries_
Definition: Env.h:717
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
Definition: Env.h:490
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:540
Application & app()
Definition: Env.h:255
beast::Journal const journal
Definition: Env.h:158
ManualTimeKeeper & timeKeeper()
Definition: Env.h:267
virtual void submit(JTx const &jt)
Submit an existing JTx.
Definition: Env.cpp:323
Env & apply(JsonValue &&jv, FN const &... fN)
Apply funclets and submit.
Definition: Env.h:564
bool close()
Close and advance the ledger.
Definition: Env.h:387
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition: Env.cpp:237
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
Definition: Env.cpp:451
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition: Env.cpp:183
void memoize(Account const &account)
Associate AccountID with account.
Definition: Env.cpp:156
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition: Env.cpp:225
A balance matches.
Definition: balance.h:39
Set the fee on a JTx.
Definition: fee.h:36
Match set account flags.
Definition: flags.h:112
Match clear account flags.
Definition: flags.h:129
Check a set of conditions.
Definition: require.h:64
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition: rpc.h:34
Set the regular signature on a JTx.
Definition: sig.h:35
T emplace(T... args)
T empty(T... args)
T endl(T... args)
A namespace for easy access to logging severity values.
Definition: Journal.h:29
Severity
Severity level / threshold of a Journal message.
Definition: Journal.h:31
ErrorInfo const & get_error_info(error_code_i code)
Returns an ErrorInfo that reflects the error code.
Definition: ErrorCodes.cpp:173
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 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:65
static autofill_t const autofill
Definition: tags.h:42
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:30
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition: flags.cpp:28
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition: pay.cpp:29
void sign(Json::Value &jv, Account const &account)
Sign automatically.
Definition: utility.cpp:46
STObject parse(Json::Value const &jv)
Convert JSON to STObject.
Definition: utility.cpp:37
XRP_t const XRP
Converts to XRP Issue or STAmount.
Definition: amount.cpp:104
void fill_fee(Json::Value &jv, ReadView const &view)
Set the fee automatically.
Definition: utility.cpp:57
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:26
std::string transHuman(TER code)
Definition: TER.cpp:260
std::shared_ptr< STTx const > sterilize(STTx const &stx)
Sterilize a transaction.
Definition: STTx.cpp:604
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:1464
bool isXRP(AccountID const &c)
Definition: AccountID.h:91
@ telENV_RPC_FAILED
Definition: TER.h:68
@ rpcSUCCESS
Definition: ErrorCodes.h:44
@ rpcINTERNAL
Definition: ErrorCodes.h:130
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:30
std::string transToken(TER code)
Definition: TER.cpp:251
constexpr std::uint32_t asfDefaultRipple
Definition: TxFlags.h:83
beast::Journal debugLog()
Returns a debug journal.
Definition: Log.cpp:452
std::unique_ptr< beast::Journal::Sink > setDebugLogSink(std::unique_ptr< beast::Journal::Sink > sink)
Set the sink for the debug journal.
Definition: Log.cpp:446
void Rethrow()
Rethrow the exception currently being handled.
Definition: contract.h:48
@ temMALFORMED
Definition: TER.h:87
T sleep_for(T... args)
A pair of SHAMap key and LedgerEntryType.
Definition: Keylet.h:39
Json::StaticString token
Definition: ErrorCodes.h:210
std::unique_ptr< Application > owned
Definition: Env.h:141
ManualTimeKeeper * timeKeeper
Definition: Env.h:142
std::unique_ptr< AbstractClient > client
Definition: Env.h:144
Used by parseResult() and postConditions()
Definition: Env.h:125
std::optional< error_code_i > rpcCode
Definition: Env.h:131
std::optional< TER > ter
Definition: Env.h:126
Execution context for applying a JSON transaction.
Definition: JTx.h:44
std::optional< std::pair< error_code_i, std::string > > rpcCode
Definition: JTx.h:48
std::shared_ptr< STTx const > stx
Definition: JTx.h:54
Json::Value jv
Definition: JTx.h:45
std::optional< std::pair< std::string, std::optional< std::string > > > rpcException
Definition: JTx.h:50
std::function< void(Env &, JTx &)> signer
Definition: JTx.h:55
requires_t require
Definition: JTx.h:46
std::optional< TER > ter
Definition: JTx.h:47
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
Thrown when parse fails.
Definition: utility.h:36
Set the sequence number on a JTx.
Definition: seq.h:34
T to_string(T... args)
T value_or(T... args)