rippled
|
A transaction testing environment. More...
Classes | |
struct | AppBundle |
Public Member Functions | |
Env ()=delete | |
Env & | operator= (Env const &)=delete |
Env (Env const &)=delete | |
Env (beast::unit_test::suite &suite_, std::unique_ptr< Config > config, FeatureBitset features, std::unique_ptr< Logs > logs=nullptr, beast::severities::Severity thresh=beast::severities::kError) | |
Create Env using suite, Config pointer, and explicit features. More... | |
Env (beast::unit_test::suite &suite_, FeatureBitset features) | |
Create Env with default config and specified features. More... | |
Env (beast::unit_test::suite &suite_, std::unique_ptr< Config > config, std::unique_ptr< Logs > logs=nullptr, beast::severities::Severity thresh=beast::severities::kError) | |
Create Env using suite and Config pointer. More... | |
Env (beast::unit_test::suite &suite_) | |
Create Env with only the current test suite. More... | |
virtual | ~Env ()=default |
Application & | app () |
Application const & | app () const |
ManualTimeKeeper & | timeKeeper () |
NetClock::time_point | now () |
Returns the current network time. More... | |
AbstractClient & | client () |
Returns the connected client. More... | |
template<class... Args> | |
Json::Value | rpc (std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args) |
Execute an RPC command. More... | |
template<class... Args> | |
Json::Value | rpc (std::string const &cmd, Args &&... args) |
std::shared_ptr< OpenView const > | current () const |
Returns the current ledger. More... | |
std::shared_ptr< ReadView const > | closed () |
Returns the last closed ledger. More... | |
bool | close (NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt) |
Close and advance the ledger. More... | |
template<class Rep , class Period > | |
bool | close (std::chrono::duration< Rep, Period > const &elapsed) |
Close and advance the ledger. More... | |
bool | close () |
Close and advance the ledger. More... | |
void | trace (int howMany=-1) |
Turn on JSON tracing. More... | |
void | notrace () |
Turn off JSON tracing. More... | |
void | disable_sigs () |
Turn off signature checks. More... | |
void | memoize (Account const &account) |
Associate AccountID with account. More... | |
PrettyAmount | balance (Account const &account) const |
Returns the XRP balance on an account. More... | |
std::uint32_t | seq (Account const &account) const |
Returns the next sequence number on account. More... | |
PrettyAmount | balance (Account const &account, Issue const &issue) const |
Return the balance on an account. More... | |
std::shared_ptr< SLE const > | le (Account const &account) const |
Return an account root. More... | |
std::shared_ptr< SLE const > | le (Keylet const &k) const |
Return a ledger entry. More... | |
template<class JsonValue , class... FN> | |
JTx | jt (JsonValue &&jv, FN const &... fN) |
Create a JTx from parameters. More... | |
template<class JsonValue , class... FN> | |
Json::Value | json (JsonValue &&jv, FN const &... fN) |
Create JSON from parameters. More... | |
template<class... Args> | |
void | require (Args const &... args) |
Check a set of requirements. More... | |
virtual void | submit (JTx const &jt) |
Submit an existing JTx. More... | |
void | sign_and_submit (JTx const &jt, Json::Value params=Json::nullValue) |
Use the submit RPC command with a provided JTx object. More... | |
void | postconditions (JTx const &jt, TER ter, bool didApply) |
Check expected postconditions of JTx submission. More... | |
TER | ter () const |
Return the TER for the last JTx. More... | |
std::shared_ptr< STObject const > | meta () |
Return metadata for the last JTx. More... | |
std::shared_ptr< STTx const > | tx () const |
Return the tx data for the last JTx. More... | |
void | enableFeature (uint256 const feature) |
void | disableFeature (uint256 const feature) |
template<class Arg , class... Args> | |
void | fund (STAmount const &amount, Arg const &arg, Args const &... args) |
Create a new account with some XRP. More... | |
Account const & | lookup (AccountID const &id) const |
Returns the Account given the AccountID. More... | |
Account const & | lookup (std::string const &base58ID) const |
template<class JsonValue , class... FN> | |
void | apply (JsonValue &&jv, FN const &... fN) |
Apply funclets and submit. More... | |
template<class JsonValue , class... FN> | |
void | operator() (JsonValue &&jv, FN const &... fN) |
void | trust (STAmount const &amount, Account const &account) |
Establish trust lines. More... | |
template<class... Accounts> | |
void | trust (STAmount const &amount, Account const &to0, Account const &to1, Accounts const &... toN) |
Static Public Member Functions | |
static std::pair< TER, bool > | parseResult (Json::Value const &jr) |
Gets the TER result and didApply flag from a RPC Json result object. More... | |
Public Attributes | |
beast::unit_test::suite & | test |
Account const & | master = Account::master |
const beast::Journal | journal |
Protected Member Functions | |
Json::Value | do_rpc (std::vector< std::string > const &args, std::unordered_map< std::string, std::string > const &headers={}) |
void | autofill_sig (JTx &jt) |
virtual void | autofill (JTx &jt) |
std::shared_ptr< STTx const > | st (JTx const &jt) |
Create a STTx from a JTx The framework requires that JSON is valid. More... | |
template<class... FN> | |
void | invoke (STTx &stx, FN const &... fN) |
template<class... FN> | |
void | invoke (JTx &jt, FN const &... fN) |
Protected Attributes | |
int | trace_ = 0 |
TestStopwatch | stopwatch_ |
uint256 | txid_ |
TER | ter_ = tesSUCCESS |
std::unordered_map< AccountID, Account > | map_ |
Private Member Functions | |
void | fund (bool setDefaultRipple, STAmount const &amount, Account const &account) |
void | fund_arg (STAmount const &amount, Account const &account) |
template<std::size_t N> | |
void | fund_arg (STAmount const &amount, std::array< Account, N > const &list) |
Private Attributes | |
AppBundle | bundle_ |
|
delete |
|
delete |
ripple::test::jtx::Env::Env | ( | beast::unit_test::suite & | suite_, |
std::unique_ptr< Config > | config, | ||
FeatureBitset | features, | ||
std::unique_ptr< Logs > | logs = nullptr , |
||
beast::severities::Severity | thresh = beast::severities::kError |
||
) |
Create Env using suite, Config pointer, and explicit features.
This constructor will create an Env with the specified configuration and takes ownership the passed Config pointer. Features will be enabled according to rules described below (see next constructor).
suite_ | the current unit_test::suite |
config | The desired Config - ownership will be taken by moving the pointer. See envconfig and related functions for common config tweaks. |
args | with_only_features() to explicitly enable or supported_features_except() to enable all and disable specific features. |
ripple::test::jtx::Env::Env | ( | beast::unit_test::suite & | suite_, |
FeatureBitset | features | ||
) |
Create Env with default config and specified features.
This constructor will create an Env with the standard Env configuration (from envconfig()) and features explicitly specified. Use with_only_features(...) or supported_features_except(...) to create a collection of features appropriate for passing here.
suite_ | the current unit_test::suite |
args | collection of features |
ripple::test::jtx::Env::Env | ( | beast::unit_test::suite & | suite_, |
std::unique_ptr< Config > | config, | ||
std::unique_ptr< Logs > | logs = nullptr , |
||
beast::severities::Severity | thresh = beast::severities::kError |
||
) |
Create Env using suite and Config pointer.
This constructor will create an Env with the specified configuration and takes ownership the passed Config pointer. All supported amendments are enabled by this version of the constructor.
suite_ | the current unit_test::suite |
config | The desired Config - ownership will be taken by moving the pointer. See envconfig and related functions for common config tweaks. |
ripple::test::jtx::Env::Env | ( | beast::unit_test::suite & | suite_ | ) |
|
virtualdefault |
Application& ripple::test::jtx::Env::app | ( | ) |
Application const& ripple::test::jtx::Env::app | ( | ) | const |
ManualTimeKeeper& ripple::test::jtx::Env::timeKeeper | ( | ) |
NetClock::time_point ripple::test::jtx::Env::now | ( | ) |
AbstractClient& ripple::test::jtx::Env::client | ( | ) |
Json::Value ripple::test::jtx::Env::rpc | ( | std::unordered_map< std::string, std::string > const & | headers, |
std::string const & | cmd, | ||
Args &&... | args | ||
) |
Json::Value ripple::test::jtx::Env::rpc | ( | std::string const & | cmd, |
Args &&... | args | ||
) |
std::shared_ptr<OpenView const> ripple::test::jtx::Env::current | ( | ) | const |
std::shared_ptr< ReadView const > ripple::test::jtx::Env::closed | ( | ) |
bool ripple::test::jtx::Env::close | ( | NetClock::time_point | closeTime, |
std::optional< std::chrono::milliseconds > | consensusDelay = std::nullopt |
||
) |
Close and advance the ledger.
The resulting close time will be different and greater than the previous close time, and at or after the passed-in close time.
Effects:
Creates a new closed ledger from the last closed ledger. All transactions that made it into the open ledger are applied to the closed ledger. The Application network time is set to the close time of the resulting ledger.
bool ripple::test::jtx::Env::close | ( | std::chrono::duration< Rep, Period > const & | elapsed | ) |
bool ripple::test::jtx::Env::close | ( | ) |
void ripple::test::jtx::Env::trace | ( | int | howMany = -1 | ) |
void ripple::test::jtx::Env::notrace | ( | ) |
void ripple::test::jtx::Env::disable_sigs | ( | ) |
void ripple::test::jtx::Env::memoize | ( | Account const & | account | ) |
Account const & ripple::test::jtx::Env::lookup | ( | std::string const & | base58ID | ) | const |
PrettyAmount ripple::test::jtx::Env::balance | ( | Account const & | account | ) | const |
std::uint32_t ripple::test::jtx::Env::seq | ( | Account const & | account | ) | const |
PrettyAmount ripple::test::jtx::Env::balance | ( | Account const & | account, |
Issue const & | issue | ||
) | const |
std::shared_ptr< SLE const > ripple::test::jtx::Env::le | ( | Account const & | account | ) | const |
std::shared_ptr< SLE const > ripple::test::jtx::Env::le | ( | Keylet const & | k | ) | const |
JTx ripple::test::jtx::Env::jt | ( | JsonValue && | jv, |
FN const &... | fN | ||
) |
Json::Value ripple::test::jtx::Env::json | ( | JsonValue && | jv, |
FN const &... | fN | ||
) |
void ripple::test::jtx::Env::require | ( | Args const &... | args | ) |
|
static |
|
virtual |
void ripple::test::jtx::Env::sign_and_submit | ( | JTx const & | jt, |
Json::Value | params = Json::nullValue |
||
) |
void ripple::test::jtx::Env::apply | ( | JsonValue && | jv, |
FN const &... | fN | ||
) |
void ripple::test::jtx::Env::operator() | ( | JsonValue && | jv, |
FN const &... | fN | ||
) |
TER ripple::test::jtx::Env::ter | ( | ) | const |
std::shared_ptr< STObject const > ripple::test::jtx::Env::meta | ( | ) |
std::shared_ptr< STTx const > ripple::test::jtx::Env::tx | ( | ) | const |
void ripple::test::jtx::Env::enableFeature | ( | uint256 const | feature | ) |
void ripple::test::jtx::Env::disableFeature | ( | uint256 const | feature | ) |
|
private |
void ripple::test::jtx::Env::fund | ( | STAmount const & | amount, |
Arg const & | arg, | ||
Args const &... | args | ||
) |
Create a new account with some XRP.
These convenience functions are for easy set-up of the environment, they bypass fee, seq, and sig settings. The XRP is transferred from the master account.
Preconditions: The account must not already exist
Effects: The asfDefaultRipple on the account is set, and the sequence number is incremented, unless the account is wrapped with a call to noripple.
The account's XRP balance is set to amount.
Generates a test that the balance is set.
amount | The amount of XRP to transfer to each account. |
args | A heterogeneous list of accounts to fund or calls to noripple with lists of accounts to fund. |
Establish trust lines.
These convenience functions are for easy set-up of the environment, they bypass fee, seq, and sig settings.
Preconditions: The account must already exist
Effects: A trust line is added for the account. The account's sequence number is incremented. The account is refunded for the transaction fee to set the trust line.
The refund comes from the master account.
|
protected |
|
protected |
|
protectedvirtual |
|
protected |
Create a STTx from a JTx The framework requires that JSON is valid.
On a parse error, the JSON is logged and an exception thrown. Throws: parse_error
|
protected |
|
protected |
Account const& ripple::test::jtx::Env::master = Account::master |
const beast::Journal ripple::test::jtx::Env::journal |
|
protected |
|
protected |
|
protected |