diff --git a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
index 422474a3a..3894c35e8 100644
--- a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
+++ b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj
@@ -81,15 +81,14 @@
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -310,7 +309,43 @@
true
true
-
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
true
true
true
@@ -322,30 +357,6 @@
true
true
-
- true
- true
- true
- true
-
-
- true
- true
- true
- true
-
-
- true
- true
- true
- true
-
-
- true
- true
- true
- true
-
true
diff --git a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
index f379219ba..c85fd8174 100644
--- a/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
+++ b/Subtrees/beast/Builds/VisualStudio2012/beast.vcxproj.filters
@@ -152,9 +152,6 @@
{422da6a1-e57e-4a96-9fce-e5958c16026e}
-
- {5d8ed68a-e3b5-49f3-938b-fbe7365f6293}
-
@@ -785,35 +782,32 @@
beast_asio\sockets
-
- beast_asio\tests\detail
-
beast_asio\tests
-
- beast_asio\tests\detail
-
beast_asio\tests
-
+
beast_asio\tests
-
- beast_asio\tests\detail
+
+ beast_asio\tests
-
- beast_asio\tests\detail
+
+ beast_asio\tests
-
- beast_asio\tests\detail
+
+ beast_asio\tests
-
- beast_asio\tests\detail
+
+ beast_asio\tests
-
- beast_asio\tests\detail
+
+ beast_asio\tests
+
+
+ beast_asio\tests
@@ -1240,26 +1234,32 @@
beast_asio\tests
-
- beast_asio\tests
-
beast_asio\sockets
beast_asio\sockets
-
- beast_asio\tests\detail
+
+ beast_asio\tests
-
- beast_asio\tests\detail
+
+ beast_asio\tests
-
- beast_asio\tests\detail
+
+ beast_asio\tests
-
- beast_asio\tests\detail
+
+ beast_asio\tests
+
+
+ beast_asio\tests
+
+
+ beast_asio\tests
+
+
+ beast_asio\tests
diff --git a/Subtrees/beast/modules/beast_asio/beast_asio.cpp b/Subtrees/beast/modules/beast_asio/beast_asio.cpp
index b77cf2460..b74854aa5 100644
--- a/Subtrees/beast/modules/beast_asio/beast_asio.cpp
+++ b/Subtrees/beast/modules/beast_asio/beast_asio.cpp
@@ -29,11 +29,13 @@ namespace beast
#include "sockets/beast_SslContext.cpp"
#include "tests/beast_TestPeerBasics.cpp"
-#include "tests/beast_TestPeerTests.cpp"
+#include "tests/beast_TestPeerLogic.cpp"
+#include "tests/beast_TestPeerLogicSyncServer.cpp"
+#include "tests/beast_TestPeerLogicSyncClient.cpp"
+#include "tests/beast_TestPeerLogicAsyncServer.cpp"
+#include "tests/beast_TestPeerLogicAsyncClient.cpp"
-#include "tests/detail/beast_TestPeerLogicSyncServer.cpp"
-#include "tests/detail/beast_TestPeerLogicSyncClient.cpp"
-#include "tests/detail/beast_TestPeerLogicAsyncServer.cpp"
-#include "tests/detail/beast_TestPeerLogicAsyncClient.cpp"
+#include "tests/beast_PeerTest.cpp"
+#include "tests/beast_TestPeerUnitTests.cpp"
}
diff --git a/Subtrees/beast/modules/beast_asio/beast_asio.h b/Subtrees/beast/modules/beast_asio/beast_asio.h
index d537fe1ca..f4a42d6e1 100644
--- a/Subtrees/beast/modules/beast_asio/beast_asio.h
+++ b/Subtrees/beast/modules/beast_asio/beast_asio.h
@@ -60,15 +60,13 @@ namespace beast
#include "tests/beast_TestPeer.h"
#include "tests/beast_TestPeerDetails.h"
#include "tests/beast_TestPeerLogic.h"
-#include "tests/beast_TestPeerTest.h"
-
-#include "tests/detail/beast_TestPeerLogicSyncServer.h"
-#include "tests/detail/beast_TestPeerLogicSyncClient.h"
-#include "tests/detail/beast_TestPeerLogicAsyncServer.h"
-#include "tests/detail/beast_TestPeerLogicAsyncClient.h"
-#include "tests/detail/beast_TestPeerType.h"
-#include "tests/detail/beast_TestPeerTestType.h"
-#include "tests/detail/beast_TestPeerDetailsTcp.h"
+#include "tests/beast_TestPeerLogicSyncServer.h"
+#include "tests/beast_TestPeerLogicSyncClient.h"
+#include "tests/beast_TestPeerLogicAsyncServer.h"
+#include "tests/beast_TestPeerLogicAsyncClient.h"
+#include "tests/beast_TestPeerType.h"
+#include "tests/beast_TestPeerDetailsTcp.h"
+#include "tests/beast_PeerTest.h"
}
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_PeerTest.cpp b/Subtrees/beast/modules/beast_asio/tests/beast_PeerTest.cpp
new file mode 100644
index 000000000..47cbebf62
--- /dev/null
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_PeerTest.cpp
@@ -0,0 +1,73 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+PeerTest::Result::Result ()
+ : m_ec (TestPeerBasics::make_error (TestPeerBasics::errc::skipped))
+ , m_message (m_ec.message ())
+{
+}
+
+PeerTest::Result::Result (boost::system::error_code const& ec, String const& prefix)
+ : m_ec (ec)
+ , m_message ((prefix == String::empty) ? ec.message ()
+ : prefix + " " + ec.message ())
+{
+}
+
+bool PeerTest::Result::failed () const noexcept
+{
+ return TestPeerBasics::failure (m_ec);
+}
+
+bool PeerTest::Result::timedout () const noexcept
+{
+ return m_ec == TestPeerBasics::make_error (TestPeerBasics::errc::timeout);
+}
+
+String PeerTest::Result::message () const noexcept
+{
+ return m_message;
+}
+
+bool PeerTest::Result::report (UnitTest& test, bool reportPassingTests)
+{
+ bool const success = test.unexpected (failed (), message ());
+ if (reportPassingTests && success)
+ test.logMessage (String ("pass ") + message());
+ return success;
+}
+
+//------------------------------------------------------------------------------
+
+PeerTest::Results::Results ()
+ : name ("unknown")
+{
+}
+
+bool PeerTest::Results::report (UnitTest& test, bool beginTestCase)
+{
+ if (beginTestCase)
+ test.beginTestCase (name);
+ bool success = true;
+ if (! client.report (test))
+ success = false;
+ if (! server.report (test))
+ success = false;
+ return success;
+}
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_PeerTest.h b/Subtrees/beast/modules/beast_asio/tests/beast_PeerTest.h
new file mode 100644
index 000000000..a07fa50e7
--- /dev/null
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_PeerTest.h
@@ -0,0 +1,205 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+#ifndef RIPPLE_PEERTEST_H_INCLUDED
+#define RIPPLE_PEERTEST_H_INCLUDED
+
+/** Performs a test of two peers defined by template parameters.
+*/
+class PeerTest
+{
+public:
+ enum
+ {
+ /** How long to wait before aborting a peer and reporting a timeout.
+
+ @note Aborting synchronous logics may cause undefined behavior.
+ */
+ defaultTimeoutSeconds = 30
+ };
+
+ //--------------------------------------------------------------------------
+
+ /** Holds the test results for one peer.
+ */
+ class Result
+ {
+ public:
+ /** Default constructor indicates the test was skipped.
+ */
+ Result ();
+
+ /** Construct from an error code.
+ The prefix is prepended to the error message.
+ */
+ explicit Result (boost::system::error_code const& ec, String const& prefix = "");
+
+ /** Returns true if the peer failed.
+ */
+ bool failed () const noexcept;
+
+ /** Convenience for determining if the peer timed out.
+ */
+ bool timedout () const noexcept;
+
+ /** Provides a descriptive message.
+ This is suitable to pass to UnitTest::fail.
+ */
+ String message () const noexcept;
+
+ /** Report the result to a UnitTest object.
+ A return value of true indicates success.
+ */
+ bool report (UnitTest& test, bool reportPassingTests = false);
+
+ private:
+ boost::system::error_code m_ec;
+ String m_message;
+ };
+
+ //--------------------------------------------------------------------------
+
+ /** Holds the results for both peers in a test.
+ */
+ struct Results
+ {
+ String name; // A descriptive name for this test case.
+ Result client;
+ Result server;
+
+ Results ();
+
+ /** Report the results to a UnitTest object.
+ A return value of true indicates success.
+ @param beginTestCase `true` to call test.beginTestCase for you
+ */
+ bool report (UnitTest& test, bool beginTestCase = true);
+ };
+
+ //--------------------------------------------------------------------------
+
+ /** Test two peers and return the results.
+ */
+ template
+ static Results run (Arg const& arg, int timeoutSeconds = defaultTimeoutSeconds)
+ {
+ Results results;
+
+ results.name = Details::getArgName (arg);
+
+ try
+ {
+ TestPeerType server (arg);
+
+ results.name << " / " << server.name ();
+
+ try
+ {
+ TestPeerType client (arg);
+
+ results.name << " / " << client.name ();
+
+ try
+ {
+ server.start ();
+
+ try
+ {
+ client.start ();
+
+ boost::system::error_code const ec =
+ client.join (timeoutSeconds);
+
+ results.client = Result (ec, client.name ());
+
+ try
+ {
+ boost::system::error_code const ec =
+ server.join (timeoutSeconds);
+
+ results.server = Result (ec, server.name ());
+
+ }
+ catch (...)
+ {
+ results.server = Result (TestPeerBasics::make_error (
+ TestPeerBasics::errc::exceptioned), server.name ());
+ }
+ }
+ catch (...)
+ {
+ results.client = Result (TestPeerBasics::make_error (
+ TestPeerBasics::errc::exceptioned), client.name ());
+ }
+ }
+ catch (...)
+ {
+ results.server = Result (TestPeerBasics::make_error (
+ TestPeerBasics::errc::exceptioned), server.name ());
+ }
+ }
+ catch (...)
+ {
+ results.client = Result (TestPeerBasics::make_error (
+ TestPeerBasics::errc::exceptioned), "client");
+ }
+ }
+ catch (...)
+ {
+ results.server = Result (TestPeerBasics::make_error (
+ TestPeerBasics::errc::exceptioned), "server");
+ }
+
+ return results;
+ }
+
+ //--------------------------------------------------------------------------
+
+ /** Reports tests of Details for all known asynchronous logic combinations to a UnitTest.
+ */
+ template
+ static void report_async (UnitTest& test, Arg const& arg,
+ int timeoutSeconds = defaultTimeoutSeconds,
+ bool beginTestCase = true)
+ {
+ run
+ (arg, timeoutSeconds).report (test, beginTestCase);
+ }
+
+ /** Reports tests of Details against all known logic combinations to a UnitTest.
+ */
+ template
+ static void report (UnitTest& test, Arg const& arg,
+ int timeoutSeconds = defaultTimeoutSeconds,
+ bool beginTestCase = true)
+ {
+ run
+ (arg, timeoutSeconds).report (test, beginTestCase);
+
+ run
+ (arg, timeoutSeconds).report (test, beginTestCase);
+
+ run
+ (arg, timeoutSeconds).report (test, beginTestCase);
+
+ report_async (test, arg, timeoutSeconds, beginTestCase);
+ }
+};
+
+#endif
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeer.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeer.h
index c87647605..6ffcc0b7b 100644
--- a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeer.h
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeer.h
@@ -22,9 +22,7 @@
/** An abstract peer for unit tests.
*/
-class TestPeer
- : public TestPeerBasics
- , public Uncopyable
+class TestPeer : public TestPeerBasics
{
public:
virtual ~TestPeer () { }
@@ -47,17 +45,6 @@ public:
@return Any error code generated during the server operation.
*/
virtual boost::system::error_code join (int timeoutSeconds = -1) = 0;
-
- /** Runs a unit test on the specified pair of peers.
- Returns true if the tests passed.
- */
-#if 0
- static bool runTest (UnitTest& test,
- TestPeer& server,
- TestPeer& client,
- int timeoutSeconds,
- String const& name);
-#endif
};
#endif
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerBasics.cpp b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerBasics.cpp
index d45a70de7..257ba0c56 100644
--- a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerBasics.cpp
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerBasics.cpp
@@ -17,6 +17,51 @@
*/
//==============================================================================
+TestPeerBasics::Role::Role (role_t role)
+ : m_role (role)
+{
+}
+
+String TestPeerBasics::Role::name () const noexcept
+{
+ if (m_role == server)
+ return "server";
+ return "client";
+}
+
+bool TestPeerBasics::Role::operator== (role_t role) const noexcept
+{
+ return m_role == role;
+}
+
+TestPeerBasics::Role::operator Socket::handshake_type () const noexcept
+{
+ if (m_role == server)
+ return Socket::server;
+ return Socket::client;
+}
+
+//------------------------------------------------------------------------------
+
+TestPeerBasics::Model::Model (model_t model)
+ : m_model (model)
+{
+}
+
+String TestPeerBasics::Model::name () const noexcept
+{
+ if (m_model == async)
+ return "async";
+ return "sync";
+}
+
+bool TestPeerBasics::Model::operator== (model_t model) const noexcept
+{
+ return m_model == model;
+}
+
+//------------------------------------------------------------------------------
+
boost::system::error_category const& TestPeerBasics::test_category () noexcept
{
struct test_category_type : boost::system::error_category
@@ -99,3 +144,5 @@ bool TestPeerBasics::unexpected (bool condition, boost::system::error_code& ec)
return ! expected (condition, ec);
}
+//------------------------------------------------------------------------------
+
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerBasics.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerBasics.h
index 8c57c1862..cf2c6f3f3 100644
--- a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerBasics.h
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerBasics.h
@@ -24,8 +24,48 @@
@see TestPeer
*/
-struct TestPeerBasics
+class TestPeerBasics
{
+public:
+ /** Identifies if the peer is a client or a server. */
+ struct Role
+ {
+ enum role_t
+ {
+ client,
+ server
+ };
+
+ Role (role_t role);
+ String name () const noexcept;
+ bool operator== (role_t role) const noexcept;
+ operator Socket::handshake_type () const noexcept;
+
+ private:
+ role_t m_role;
+ };
+
+ //--------------------------------------------------------------------------
+
+ /** Selects between synchronous or asynchronous networking i/o usage. */
+ struct Model
+ {
+ enum model_t
+ {
+ sync,
+ async
+ };
+
+ Model (model_t model);
+ String name () const noexcept;
+ bool operator== (model_t model) const noexcept;
+
+ private:
+ model_t m_model;
+ };
+
+ //--------------------------------------------------------------------------
+
// Custom error codes for distinguishing test conditions
struct errc
{
@@ -67,77 +107,6 @@ struct TestPeerBasics
/** Set the error based on a passed condition and return the success.
*/
static bool unexpected (bool condition, boost::system::error_code& ec) noexcept;
-
- //--------------------------------------------------------------------------
-
- struct Role
- {
- enum role_t
- {
- client,
- server
- };
-
- Role (role_t role)
- : m_role (role)
- {
- }
-
- String name () const noexcept
- {
- if (m_role == server)
- return "server";
- return "client";
- }
-
- bool operator== (role_t role) const noexcept
- {
- return m_role == role;
- }
-
- operator Socket::handshake_type () const noexcept
- {
- if (m_role == server)
- return Socket::server;
- return Socket::client;
- }
-
- private:
- role_t m_role;
- };
-
- //--------------------------------------------------------------------------
-
- struct Model
- {
- enum model_t
- {
- sync,
- async
- };
-
- Model (model_t model)
- : m_model (model)
- {
- }
-
- String name () const noexcept
- {
- if (m_model == async)
- return "async";
- return "sync";
- }
-
- bool operator== (model_t model) const noexcept
- {
- return m_model == model;
- }
-
- private:
- model_t m_model;
- };
-
- //--------------------------------------------------------------------------
};
#endif
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerDetails.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerDetails.h
index ec2a6b988..c03f4bd2b 100644
--- a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerDetails.h
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerDetails.h
@@ -22,7 +22,7 @@
/** Base class of all detail objects.
*/
-class TestPeerDetails : public Uncopyable
+class TestPeerDetails
{
public:
virtual ~TestPeerDetails () { }
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerDetailsTcp.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerDetailsTcp.h
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerDetailsTcp.h
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerDetailsTcp.h
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogic.cpp b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogic.cpp
new file mode 100644
index 000000000..d2d8e1adb
--- /dev/null
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogic.cpp
@@ -0,0 +1,58 @@
+//------------------------------------------------------------------------------
+/*
+ This file is part of Beast: https://github.com/vinniefalco/Beast
+ Copyright 2013, Vinnie Falco
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+//==============================================================================
+
+TestPeerLogic::TestPeerLogic (Socket& socket)
+ : m_socket (&socket)
+{
+}
+
+TestPeerLogic::error_code& TestPeerLogic::error () noexcept
+{
+ return m_ec;
+}
+
+TestPeerLogic::error_code const& TestPeerLogic::error () const noexcept
+{
+ return m_ec;
+}
+
+TestPeerLogic::error_code const& TestPeerLogic::error (error_code const& ec) noexcept
+{
+ return m_ec = ec;
+}
+
+Socket& TestPeerLogic::socket () noexcept
+{
+ return *m_socket;
+}
+
+void TestPeerLogic::on_connect ()
+{
+ pure_virtual ();
+}
+
+void TestPeerLogic::on_connect_async (error_code const&)
+{
+ pure_virtual ();
+}
+
+void TestPeerLogic::pure_virtual ()
+{
+ fatal_error ("A TestPeerLogic function was called incorrectly");
+}
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogic.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogic.h
index a0094a01a..bdb47cf35 100644
--- a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogic.h
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogic.h
@@ -22,62 +22,31 @@
/** Interface for implementing the logic part of a peer test.
*/
-class TestPeerLogic
- : public TestPeerBasics
- , public Uncopyable
+class TestPeerLogic : public TestPeerBasics
{
public:
typedef boost::system::error_code error_code;
- explicit TestPeerLogic (Socket& socket)
- : m_socket (socket)
- {
- }
+ explicit TestPeerLogic (Socket& socket);
- error_code& error () noexcept
- {
- return m_ec;
- }
+ error_code& error () noexcept;
+ error_code const& error () const noexcept;
+ error_code const& error (error_code const& ec) noexcept; // assigns to m_ec
- error_code const& error () const noexcept
- {
- return m_ec;
- }
-
- // also assigns, used for async handlers
- error_code const& error (error_code const& ec) noexcept
- {
- return m_ec = ec;
- }
-
- Socket& socket () noexcept
- {
- return m_socket;
- }
+ Socket& socket () noexcept;
virtual Role get_role () const noexcept = 0;
-
virtual Model get_model () const noexcept = 0;
- virtual void on_connect ()
- {
- pure_virtual ();
- }
-
- virtual void on_connect_async (error_code const&)
- {
- pure_virtual ();
- }
+ virtual void on_connect ();
+ virtual void on_connect_async (error_code const&);
protected:
- static void pure_virtual ()
- {
- fatal_error ("A TestPeerLogic function was called incorrectly");
- }
+ static void pure_virtual ();
private:
error_code m_ec;
- Socket& m_socket;
+ Socket* m_socket;
};
#endif
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicAsyncClient.cpp b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicAsyncClient.cpp
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicAsyncClient.cpp
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicAsyncClient.cpp
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicAsyncClient.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicAsyncClient.h
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicAsyncClient.h
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicAsyncClient.h
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicAsyncServer.cpp b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicAsyncServer.cpp
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicAsyncServer.cpp
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicAsyncServer.cpp
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicAsyncServer.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicAsyncServer.h
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicAsyncServer.h
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicAsyncServer.h
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicSyncClient.cpp b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicSyncClient.cpp
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicSyncClient.cpp
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicSyncClient.cpp
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicSyncClient.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicSyncClient.h
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicSyncClient.h
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicSyncClient.h
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicSyncServer.cpp b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicSyncServer.cpp
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicSyncServer.cpp
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicSyncServer.cpp
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicSyncServer.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicSyncServer.h
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerLogicSyncServer.h
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerLogicSyncServer.h
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerTest.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerTest.h
deleted file mode 100644
index 628359461..000000000
--- a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerTest.h
+++ /dev/null
@@ -1,128 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef RIPPLE_TESTPEERTEST_H_INCLUDED
-#define RIPPLE_TESTPEERTEST_H_INCLUDED
-
-/** Performs a test of two peers defined by template parameters.
-*/
-struct TestPeerTest : protected TestPeerBasics
-{
- enum
- {
- /** How long to wait before aborting a peer and reporting a timeout.
-
- @note Aborting synchronous logics may cause undefined behavior.
- */
- defaultTimeoutSeconds = 30
- };
-
- /** Holds the results for one peer. */
- class Result : protected TestPeerBasics
- {
- public:
- /** Default constructor indicates the test was skipped.
- */
- Result ()
- : m_ec (make_error (errc::skipped))
- , m_message (m_ec.message ())
- {
- }
-
- /** Construct from an error code.
- The prefix is prepended to the error message.
- */
- explicit Result (boost::system::error_code const& ec, String const& prefix = "")
- : m_ec (ec)
- , m_message ((prefix == String::empty) ? ec.message ()
- : prefix + " " + ec.message ())
- {
- }
-
- /** Returns true if the peer failed.
- */
- bool failed () const noexcept
- {
- return failure (m_ec);
- }
-
- /** Convenience for determining if the peer timed out. */
- bool timedout () const noexcept
- {
- return m_ec == make_error (errc::timeout);
- }
-
- /** Provides a descriptive message.
- This is suitable to pass to UnitTest::fail.
- */
- String message () const noexcept
- {
- return m_message;
- }
-
- /** Report the result to a UnitTest object.
- A return value of true indicates success.
- */
- bool report (UnitTest& test)
- {
- bool const success = test.unexpected (failed (), message ());
-#if 0
- // Option to report passing tests
- if (success)
- test.logMessage (String ("passed ") + message());
-#endif
- return success;
- }
-
- private:
- boost::system::error_code m_ec;
- String m_message;
- };
-
- //--------------------------------------------------------------------------
-
- /** Holds the results for both peers. */
- struct Results
- {
- String name; // A descriptive name for this test case.
- Result client;
- Result server;
-
- Results () : name ("unknown")
- {
- }
-
- /** Report the results to a UnitTest object.
- A return value of true indicates success.
- */
- bool report (UnitTest& test, bool beginTestCase = true)
- {
- if (beginTestCase)
- test.beginTestCase (name);
- bool success = true;
- if (! client.report (test))
- success = false;
- if (! server.report (test))
- success = false;
- return success;
- }
- };
-};
-
-#endif
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerType.h b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerType.h
similarity index 100%
rename from Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerType.h
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerType.h
diff --git a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerTests.cpp b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerUnitTests.cpp
similarity index 84%
rename from Subtrees/beast/modules/beast_asio/tests/beast_TestPeerTests.cpp
rename to Subtrees/beast/modules/beast_asio/tests/beast_TestPeerUnitTests.cpp
index f67e7abe3..878216ac2 100644
--- a/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerTests.cpp
+++ b/Subtrees/beast/modules/beast_asio/tests/beast_TestPeerUnitTests.cpp
@@ -17,7 +17,9 @@
*/
//==============================================================================
-class TestPeerTests : public UnitTest
+/** UnitTest for the TestPeer family of objects.
+*/
+class TestPeerUnitTests : public UnitTest
{
public:
enum
@@ -25,14 +27,14 @@ public:
timeoutSeconds = 3
};
- TestPeerTests () : UnitTest ("TestPeer", "beast", runManual)
+ TestPeerUnitTests () : UnitTest ("TestPeer", "beast")
{
}
template
void testDetails (Arg const& arg = Arg ())
{
- TestPeerTestType::test (*this, arg, timeoutSeconds);
+ PeerTest::report (*this, arg, timeoutSeconds);
}
void runTest ()
@@ -43,4 +45,4 @@ public:
}
};
-static TestPeerTests testPeerTests;
+static TestPeerUnitTests testPeerUnitTests;
diff --git a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerTestType.h b/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerTestType.h
deleted file mode 100644
index e7763b2d5..000000000
--- a/Subtrees/beast/modules/beast_asio/tests/detail/beast_TestPeerTestType.h
+++ /dev/null
@@ -1,119 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of Beast: https://github.com/vinniefalco/Beast
- Copyright 2013, Vinnie Falco
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef RIPPLE_TESTPEERTESTTYPE_H_INCLUDED
-#define RIPPLE_TESTPEERTESTTYPE_H_INCLUDED
-
-/** Performs a test of two peers defined by template parameters.
-*/
-class TestPeerTestType : public TestPeerTest
-{
-public:
- /** Test two peers and return the results.
- */
- template
- static Results run (Arg const& arg, int timeoutSeconds = defaultTimeoutSeconds)
- {
- Results results;
-
- results.name = Details::getArgName (arg);
-
- try
- {
- TestPeerType server (arg);
-
- results.name << " / " << server.name ();
-
- try
- {
- TestPeerType client (arg);
-
- results.name << " / " << client.name ();
-
- try
- {
- server.start ();
-
- try
- {
- client.start ();
-
- boost::system::error_code const ec =
- client.join (timeoutSeconds);
-
- results.client = Result (ec, client.name ());
-
- try
- {
- boost::system::error_code const ec =
- server.join (timeoutSeconds);
-
- results.server = Result (ec, server.name ());
-
- }
- catch (...)
- {
- results.server = Result (make_error (
- errc::exceptioned), server.name ());
- }
- }
- catch (...)
- {
- results.client = Result (make_error (
- errc::exceptioned), client.name ());
- }
- }
- catch (...)
- {
- results.server = Result (make_error (
- errc::exceptioned), server.name ());
- }
- }
- catch (...)
- {
- results.client = Result (make_error (
- errc::exceptioned), "client");
- }
- }
- catch (...)
- {
- results.server = Result (make_error (
- errc::exceptioned), "server");
- }
-
- return results;
- }
-
- //--------------------------------------------------------------------------
-
- /** Reports tests of Details against all known logic combinations to a UnitTest.
- */
- template
- static void test (UnitTest& test, Arg const& arg,
- int timeoutSeconds = defaultTimeoutSeconds,
- bool beginTestCase = true)
- {
- run (arg, timeoutSeconds).report (test, beginTestCase);
- run (arg, timeoutSeconds).report (test, beginTestCase);
- run (arg, timeoutSeconds).report (test, beginTestCase);
- run (arg, timeoutSeconds).report (test, beginTestCase);
- }
-};
-
-#endif
diff --git a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp
index e9724d155..82a10351e 100644
--- a/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp
+++ b/Subtrees/beast/modules/beast_core/diagnostic/beast_UnitTest.cpp
@@ -264,8 +264,6 @@ UnitTests::TestList UnitTests::selectTests (
// If no trailing slash on package, try tests
if (list.size () == 0 && indexOfDot == -1)
{
- std::cout << "Trying package as test" << std::endl;
-
// Try "package" as a testname
list = selectTest (package, tests);
}
diff --git a/modules/ripple_asio/sockets/ripple_MultiSocket.cpp b/modules/ripple_asio/sockets/ripple_MultiSocket.cpp
index e0c5e2cfc..de108d4c7 100644
--- a/modules/ripple_asio/sockets/ripple_MultiSocket.cpp
+++ b/modules/ripple_asio/sockets/ripple_MultiSocket.cpp
@@ -183,17 +183,11 @@ public:
timeoutSeconds = 3
};
- template
- void testAsync (Arg const& arg)
- {
- TestPeerTestType::run
- (arg, timeoutSeconds).report (*this);
- }
-
template
void testProtocol (Arg const& arg)
{
- testAsync > (arg);
+ PeerTest::report_async , Arg>
+ (*this, timeoutSeconds, true);
}
void testOptions (int flags)