diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index a95e5edb4..4a392460d 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -363,6 +363,8 @@ public: boost::asio::signal_set m_signals; beast::WaitableEvent m_stop; + std::atomic checkSigs_; + std::unique_ptr m_resolver; io_latency_sampler m_io_latency_sampler; @@ -490,6 +492,8 @@ public: , m_signals (get_io_service()) + , checkSigs_(true) + , m_resolver (ResolverAsio::New (get_io_service(), logs_->journal("Resolver"))) , m_io_latency_sampler (m_collectorManager->collector()->make_event ("ios_latency"), @@ -526,6 +530,8 @@ public: void run() override; bool isShutdown() override; void signalStop() override; + bool checkSigs() const override; + void checkSigs(bool) override; //-------------------------------------------------------------------------- @@ -1171,6 +1177,16 @@ ApplicationImp::isShutdown() return isStopped(); } +bool ApplicationImp::checkSigs() const +{ + return checkSigs_; +} + +void ApplicationImp::checkSigs(bool check) +{ + checkSigs_ = check; +} + //------------------------------------------------------------------------------ void diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h index 1e47e9edf..56db54776 100644 --- a/src/ripple/app/main/Application.h +++ b/src/ripple/app/main/Application.h @@ -97,6 +97,8 @@ public: virtual void run() = 0; virtual bool isShutdown () = 0; virtual void signalStop () = 0; + virtual bool checkSigs() const = 0; + virtual void checkSigs(bool) = 0; // // --- diff --git a/src/ripple/app/tests/OversizeMeta_test.cpp b/src/ripple/app/tests/OversizeMeta_test.cpp index fbb88d54c..7e47ce325 100644 --- a/src/ripple/app/tests/OversizeMeta_test.cpp +++ b/src/ripple/app/tests/OversizeMeta_test.cpp @@ -54,7 +54,7 @@ public: } void - run() + run() override { test(10000); } @@ -64,6 +64,21 @@ BEAST_DEFINE_TESTSUITE_MANUAL(PlumpBook,tx,ripple); //------------------------------------------------------------------------------ +// Ensure that unsigned transactions succeed during automatic test runs. +class ThinBook_test : public PlumpBook_test +{ +public: + void + run() override + { + test(1); + } +}; + +BEAST_DEFINE_TESTSUITE(ThinBook, tx, ripple); + +//------------------------------------------------------------------------------ + class OversizeMeta_test : public beast::unit_test::suite { public: diff --git a/src/ripple/rpc/handlers/Submit.cpp b/src/ripple/rpc/handlers/Submit.cpp index 29c680db7..82340d9d7 100644 --- a/src/ripple/rpc/handlers/Submit.cpp +++ b/src/ripple/rpc/handlers/Submit.cpp @@ -82,7 +82,11 @@ Json::Value doSubmit (RPC::Context& context) return jvResult; } + { + if (!context.app.checkSigs()) + forceValidity(context.app.getHashRouter(), + stpTrans->getTransactionID(), Validity::SigGoodOnly); auto validity = checkValidity(context.app.getHashRouter(), *stpTrans, context.ledgerMaster.getCurrentLedger()->rules(), context.app.config()); diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index 7f79bf30d..1e6d8dd19 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -546,6 +546,9 @@ transactionConstructImpl (std::shared_ptr const& stpTrans, // Check the signature if that's called for. auto sttxNew = std::make_shared (sit); + if (!app.checkSigs()) + forceValidity(app.getHashRouter(), + sttxNew->getTransactionID(), Validity::SigGoodOnly); if (checkValidity(app.getHashRouter(), *sttxNew, rules, app.config()).first != Validity::Valid) { diff --git a/src/ripple/test/jtx/Env.h b/src/ripple/test/jtx/Env.h index 8ff584bd3..ce5554ec6 100644 --- a/src/ripple/test/jtx/Env.h +++ b/src/ripple/test/jtx/Env.h @@ -301,7 +301,7 @@ public: void disable_sigs() { - nosig_ = true; + app().checkSigs(false); } /** Associate AccountID with account. */ @@ -542,7 +542,6 @@ public: protected: int trace_ = 0; bool testing_ = true; - bool nosig_ = false; TestStopwatch stopwatch_; uint256 txid_; TER ter_ = tesSUCCESS; @@ -567,9 +566,6 @@ protected: std::shared_ptr st (JTx const& jt); - ApplyFlags - applyFlags() const; - inline void invoke (STTx& stx) diff --git a/src/ripple/test/jtx/impl/Env.cpp b/src/ripple/test/jtx/impl/Env.cpp index c70f563c3..2165eacc9 100644 --- a/src/ripple/test/jtx/impl/Env.cpp +++ b/src/ripple/test/jtx/impl/Env.cpp @@ -361,7 +361,9 @@ Env::postconditions(JTx const& jt, TER ter, bool didApply) { if (jt.ter && ! test.expect(ter == *jt.ter, "apply: " + transToken(ter) + - " (" + transHuman(ter) + ")")) + " (" + transHuman(ter) + ") != " + + transToken(*jt.ter) + " (" + + transHuman(*jt.ter) + ")")) { test.log << pretty(jt.jv); // Don't check postconditions if @@ -396,7 +398,7 @@ Env::autofill_sig (JTx& jt) return; auto const account = lookup(jv[jss::Account].asString()); - if (nosig_) + if (!app().checkSigs()) { jv[jss::SigningPubKey] = strHex(account.pk().slice()); @@ -462,15 +464,6 @@ Env::st (JTx const& jt) return nullptr; } -ApplyFlags -Env::applyFlags() const -{ - ApplyFlags flags = tapNONE; - if (nosig_) - flags = flags | tapNO_CHECK_SIGN; - return flags; -} - Json::Value Env::do_rpc(std::vector const& args) {