Browse Source

ethrpc separated && first tests

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
3c4da0eb20
  1. 3
      CMakeLists.txt
  2. 1
      eth/CMakeLists.txt
  3. 2
      eth/main.cpp
  4. 0
      libethrpc/BigInteger.js
  5. 57
      libethrpc/CMakeLists.txt
  6. 0
      libethrpc/EthStubServer.cpp
  7. 0
      libethrpc/EthStubServer.h
  8. 0
      libethrpc/abstractethstubserver.h
  9. 0
      libethrpc/eth.js
  10. 0
      libethrpc/ethString.js
  11. 0
      libethrpc/spec.json
  12. 1
      neth/CMakeLists.txt
  13. 5
      neth/main.cpp
  14. 2
      test/CMakeLists.txt
  15. 41
      test/jsonrpc.cpp

3
CMakeLists.txt

@ -335,6 +335,9 @@ endif()
endif()
add_subdirectory(lllc)
add_subdirectory(sc)
if(JSONRPC_LS)
add_subdirectory(libethrpc)
endif()
if (NOT LANGUAGES)
add_subdirectory(secp256k1)
add_subdirectory(libp2p)

1
eth/CMakeLists.txt

@ -20,6 +20,7 @@ target_link_libraries(${EXECUTABLE} ${LEVELDB_LS})
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS})
if(JSONRPC_LS)
target_link_libraries(${EXECUTABLE} ${JSONRPC_LS})
target_link_libraries(${EXECUTABLE} ethrpc)
endif()
if(READLINE_LS)
target_link_libraries(${EXECUTABLE} ${READLINE_LS})

2
eth/main.cpp

@ -39,7 +39,7 @@
#include <readline/history.h>
#endif
#if ETH_JSONRPC
#include "EthStubServer.h"
#include <libethrpc/EthStubServer.h>
#endif
#include "BuildInfo.h"
using namespace std;

0
eth/BigInteger.js → libethrpc/BigInteger.js

57
libethrpc/CMakeLists.txt

@ -0,0 +1,57 @@
cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRC_LIST)
include_directories(..)
link_directories(../libethcore)
link_directories(../libwebthree)
set(EXECUTABLE ethrpc)
if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${SRC_LIST})
else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST})
endif()
file(GLOB HEADERS "*.h")
target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} gmp)
if(MINIUPNPC_LS)
target_link_libraries(${EXECUTABLE} ${MINIUPNPC_LS})
endif()
target_link_libraries(${EXECUTABLE} ${LEVELDB_LS})
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS})
if(JSONRPC_LS)
target_link_libraries(${EXECUTABLE} ${JSONRPC_LS})
endif()
if(READLINE_LS)
target_link_libraries(${EXECUTABLE} ${READLINE_LS})
endif()
if ("${TARGET_PLATFORM}" STREQUAL "w64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
target_link_libraries(${EXECUTABLE} boost_system-mt-s)
target_link_libraries(${EXECUTABLE} boost_filesystem-mt-s)
target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s)
target_link_libraries(${EXECUTABLE} gcc)
target_link_libraries(${EXECUTABLE} gdi32)
target_link_libraries(${EXECUTABLE} ws2_32)
target_link_libraries(${EXECUTABLE} mswsock)
target_link_libraries(${EXECUTABLE} shlwapi)
target_link_libraries(${EXECUTABLE} iphlpapi)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
elseif (UNIX)
else ()
target_link_libraries(${EXECUTABLE} boost_system)
target_link_libraries(${EXECUTABLE} boost_filesystem)
find_package(Threads REQUIRED)
target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
endif ()
install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

0
eth/EthStubServer.cpp → libethrpc/EthStubServer.cpp

0
eth/EthStubServer.h → libethrpc/EthStubServer.h

0
eth/abstractethstubserver.h → libethrpc/abstractethstubserver.h

0
eth/eth.js → libethrpc/eth.js

0
eth/ethString.js → libethrpc/ethString.js

0
eth/spec.json → libethrpc/spec.json

1
neth/CMakeLists.txt

@ -22,6 +22,7 @@ target_link_libraries(${EXECUTABLE} ${LEVELDB_LS})
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS})
if(JSONRPC_LS)
target_link_libraries(${EXECUTABLE} ${JSONRPC_LS})
target_link_libraries(${EXECUTABLE} ethrpc)
endif()
if ("${TARGET_PLATFORM}" STREQUAL "w64")

5
neth/main.cpp

@ -33,9 +33,8 @@
#include <libevmface/Instruction.h>
#include <libethereum/All.h>
#if ETH_JSONRPC
#include <eth/EthStubServer.h>
#include <eth/EthStubServer.cpp>
#include <eth/abstractethstubserver.h>
#include <libethrpc/EthStubServer.h>
#include <libethrpc/abstractethstubserver.h>
#include <libdevcore/CommonJS.h>
#endif
#include <libwebthree/WebThree.h>

2
test/CMakeLists.txt

@ -17,7 +17,7 @@ target_link_libraries(testeth ${CRYPTOPP_LS})
target_link_libraries(testeth webthree)
if(JSONRPC_LS)
target_link_libraries(testeth ${JSONRPC_LS})
target_link_libraries(testeth ethrpc)
endif()
if ("${TARGET_PLATFORM}" STREQUAL "w64")

41
test/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

Loading…
Cancel
Save