Improve Env::ter and ter() funclet

This commit is contained in:
Vinnie Falco
2015-09-08 14:32:59 -07:00
committed by Edward Hennis
parent dd94de2830
commit 60002bf9bc
4 changed files with 21 additions and 11 deletions

View File

@@ -358,6 +358,13 @@ public:
} }
/** @} */ /** @} */
/** Return the TER for the last JTx. */
TER
ter() const
{
return ter_;
}
/** Return metadata for the last JTx. /** Return metadata for the last JTx.
Effects: Effects:
@@ -473,6 +480,7 @@ protected:
bool nosig_ = false; bool nosig_ = false;
TestStopwatch stopwatch_; TestStopwatch stopwatch_;
uint256 txid_; uint256 txid_;
TER ter_ = tesSUCCESS;
void void
autofill_sig (JTx& jt); autofill_sig (JTx& jt);

View File

@@ -42,7 +42,7 @@ struct JTx
{ {
Json::Value jv; Json::Value jv;
requires_t requires; requires_t requires;
TER ter = tesSUCCESS; boost::optional<TER> ter = tesSUCCESS;
bool fill_fee = true; bool fill_fee = true;
bool fill_seq = true; bool fill_seq = true;
bool fill_sig = true; bool fill_sig = true;

View File

@@ -243,7 +243,6 @@ Env::trust (STAmount const& amount,
void void
Env::submit (JTx const& jt) Env::submit (JTx const& jt)
{ {
TER ter;
bool didApply; bool didApply;
auto const& stx = jt.stx; auto const& stx = jt.stx;
if (stx) if (stx)
@@ -252,7 +251,7 @@ Env::submit (JTx const& jt)
openLedger.modify( openLedger.modify(
[&](OpenView& view, beast::Journal j) [&](OpenView& view, beast::Journal j)
{ {
std::tie(ter, didApply) = ripple::apply( std::tie(ter_, didApply) = ripple::apply(
app(), view, *stx, applyFlags(), app(), view, *stx, applyFlags(),
directSigVerify, config, directSigVerify, config,
beast::Journal{}); beast::Journal{});
@@ -263,12 +262,12 @@ Env::submit (JTx const& jt)
{ {
// Parsing failed or the JTx is // Parsing failed or the JTx is
// otherwise missing the stx field. // otherwise missing the stx field.
ter = temMALFORMED; ter_ = temMALFORMED;
didApply = false; didApply = false;
} }
if (! test.expect(ter == jt.ter, if (jt.ter && ! test.expect(ter_ == *jt.ter,
"apply: " + transToken(ter) + "apply: " + transToken(ter_) +
" (" + transHuman(ter) + ")")) " (" + transHuman(ter_) + ")"))
{ {
test.log << pretty(jt.jv); test.log << pretty(jt.jv);
// Don't check postconditions if // Don't check postconditions if
@@ -283,9 +282,6 @@ Env::submit (JTx const& jt)
} }
for (auto const& f : jt.requires) for (auto const& f : jt.requires)
f(*this); f(*this);
//if (isTerRetry(ter))
//if (! isTesSuccess(ter))
// held.insert(stx);
} }
std::shared_ptr<STObject const> std::shared_ptr<STObject const>

View File

@@ -21,6 +21,7 @@
#define RIPPLE_TEST_JTX_TER_H_INCLUDED #define RIPPLE_TEST_JTX_TER_H_INCLUDED
#include <ripple/test/jtx/Env.h> #include <ripple/test/jtx/Env.h>
#include <tuple>
namespace ripple { namespace ripple {
namespace test { namespace test {
@@ -32,9 +33,14 @@ namespace jtx {
class ter class ter
{ {
private: private:
TER v_; boost::optional<TER> v_;
public: public:
explicit
ter (decltype(std::ignore))
{
}
explicit explicit
ter (TER v) ter (TER v)
: v_(v) : v_(v)