remvoe const requirement and update unit tests for jsonrpc server

pull/38/head^2
Jeff Becker 6 years ago
parent 3e84915d47
commit 080c0da4a0
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -62,7 +62,7 @@ namespace abyss
protected:
virtual IRPCHandler*
CreateHandler(ConnImpl* connimpl) const = 0;
CreateHandler(ConnImpl* connimpl) = 0;
private:
static void

@ -74,7 +74,7 @@ struct DemoServer : public abyss::httpd::BaseReqHandler
}
abyss::httpd::IRPCHandler*
CreateHandler(abyss::httpd::ConnImpl* impl) const
CreateHandler(abyss::httpd::ConnImpl* impl)
{
return new DemoHandler(impl);
}

@ -157,7 +157,7 @@ namespace llarp
}
llarp_router* router;
::abyss::httpd::IRPCHandler*
CreateHandler(::abyss::httpd::ConnImpl* conn) const
CreateHandler(::abyss::httpd::ConnImpl* conn)
{
return new Handler(conn, router);
}

@ -13,6 +13,7 @@ struct AbyssTestBase : public ::testing::Test
abyss::httpd::BaseReqHandler* server = nullptr;
abyss::http::JSONRPC* client = nullptr;
const std::string method = "test.method";
bool called = false;
void
AssertMethod(const std::string& meth) const
@ -32,15 +33,7 @@ struct AbyssTestBase : public ::testing::Test
{
if(left)
return;
static_cast< AbyssTestBase* >(u)->Cancel();
}
/// cancel test because of timeout
void
Cancel()
{
Stop();
ASSERT_TRUE(false);
static_cast< AbyssTestBase* >(u)->Stop();
}
void
@ -118,8 +111,8 @@ struct ClientHandler : public abyss::http::IRPCClientHandler
struct ServerHandler : public abyss::httpd::IRPCHandler
{
const AbyssTestBase* test;
ServerHandler(abyss::httpd::ConnImpl* impl, const AbyssTestBase* parent)
AbyssTestBase* test;
ServerHandler(abyss::httpd::ConnImpl* impl, AbyssTestBase* parent)
: abyss::httpd::IRPCHandler(impl), test(parent)
{
}
@ -128,6 +121,7 @@ struct ServerHandler : public abyss::httpd::IRPCHandler
HandleJSONRPC(Method_t method, const Params& params, Response& response)
{
test->AssertMethod(method);
test->called = true;
return true;
}
};
@ -151,7 +145,7 @@ struct AbyssTest : public AbyssTestBase,
}
abyss::httpd::IRPCHandler*
CreateHandler(abyss::httpd::ConnImpl* impl) const
CreateHandler(abyss::httpd::ConnImpl* impl)
{
return new ServerHandler(impl, this);
}
@ -192,4 +186,5 @@ TEST_F(AbyssTest, TestClientAndServer)
std::bind(&AbyssTest::NewConn, this, std::placeholders::_1));
AsyncFlush();
RunLoop();
ASSERT_TRUE(called);
};
Loading…
Cancel
Save