aboutsummaryrefslogtreecommitdiffstats
path: root/jsonrpc.cpp
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2014-10-13 18:28:53 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2014-10-13 18:28:53 +0800
commitd47f9be77534022ad8c5e6fa614219d95302e79f (patch)
tree42fdd5d5538a67372935a729f7f82383acf2895d /jsonrpc.cpp
parent96f5f40dd82807540b23b243a498f6e9f33acc0a (diff)
downloaddexon-solidity-d47f9be77534022ad8c5e6fa614219d95302e79f.tar.gz
dexon-solidity-d47f9be77534022ad8c5e6fa614219d95302e79f.tar.zst
dexon-solidity-d47f9be77534022ad8c5e6fa614219d95302e79f.zip
ethrpc separated && first tests
Diffstat (limited to 'jsonrpc.cpp')
-rw-r--r--jsonrpc.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/jsonrpc.cpp b/jsonrpc.cpp
index 751539c6..101e3d25 100644
--- a/jsonrpc.cpp
+++ b/jsonrpc.cpp
@@ -5,9 +5,11 @@
#include <boost/test/unit_test.hpp>
#include <libdevcore/Log.h>
#include <libdevcore/CommonIO.h>
+#include <libdevcore/CommonJS.h>
#include <libwebthree/WebThree.h>
-#include <eth/EthStubServer.h>
+#include <libethrpc/EthStubServer.h>
#include <jsonrpc/connectors/httpserver.h>
+#include <jsonrpc/connectors/httpclient.h>
#include "JsonSpiritHeaders.h"
#include "ethstubclient.h"
@@ -17,11 +19,11 @@ using namespace dev::eth;
namespace js = json_spirit;
-
-
namespace jsonrpc_tests {
+KeyPair us;
auto_ptr<EthStubServer> jsonrpcServer;
+auto_ptr<EthStubClient> jsonrpcClient;
struct JsonrpcFixture {
@@ -32,7 +34,13 @@ struct JsonrpcFixture {
string dbPath;
dev::WebThreeDirect web3(name, dbPath);
web3.setIdealPeerCount(5);
+
+ us = KeyPair::create();
jsonrpcServer = auto_ptr<EthStubServer>(new EthStubServer(new jsonrpc::HttpServer(8080), web3));
+ jsonrpcServer->setKeys({us});
+ jsonrpcServer->StartListening();
+
+ jsonrpcClient = auto_ptr<EthStubClient>(new EthStubClient(new jsonrpc::HttpClient("http://localhost:8080")));
}
~JsonrpcFixture()
{
@@ -40,27 +48,26 @@ struct JsonrpcFixture {
}
};
-//BOOST_AUTO_TEST_CASE(jsonrpc_test)
-//{
-// cnote << "testing jsonrpc";
-// js::mValue v;
-// string s = asString(contents("../../jsonrpc.json"));
-// BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content from 'jsonrpc.json' is empty. Have you cloned the 'tests' repo branch develop?");
-// js::read_string(s, v);
-//}
-
BOOST_GLOBAL_FIXTURE(JsonrpcFixture)
-BOOST_AUTO_TEST_CASE( test_case1 )
+BOOST_AUTO_TEST_CASE(jsonrpc_key)
{
-// BOOST_CHECK( i == 1 );
+ cnote << "Testing jsonrpc key...";
+ Json::Value key = jsonrpcClient->key();
+ BOOST_CHECK_EQUAL(key.isString(), true);
+ BOOST_CHECK_EQUAL(jsToSecret(key.asString()), us.secret());
}
-
-BOOST_AUTO_TEST_CASE( test_case2 )
+
+BOOST_AUTO_TEST_CASE(jsonrpc_keys)
{
-// BOOST_CHECK_EQUAL( i, 0 );
+ cnote << "Testing jsonrpc keys...";
+ Json::Value keys = jsonrpcClient->keys();
+ BOOST_CHECK_EQUAL(keys.isArray(), true);
+ BOOST_CHECK_EQUAL(keys.size(), 1);
+ BOOST_CHECK_EQUAL(jsToSecret(keys[0u].asString()) , us.secret());
}
+
}
#endif