Browse Source

msvc changes in tests, but tests not yet working there

cl-refactor
debris 10 years ago
parent
commit
5071446c68
  1. 2
      cmake/EthDependencies.cmake
  2. 36
      test/CMakeLists.txt
  3. 5
      test/jsonrpc.cpp
  4. 35
      test/solidityEndToEndTest.cpp
  5. 3
      test/solidityExpressionCompiler.cpp
  6. 2
      test/solidityJSONInterfaceTest.cpp
  7. 2
      test/solidityNatspecJSON.cpp

2
cmake/EthDependencies.cmake

@ -90,7 +90,7 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
set(Boost_COMPILER -vc120)
endif()
find_package(Boost 1.55.0 REQUIRED COMPONENTS thread date_time system regex chrono filesystem)
find_package(Boost 1.55.0 REQUIRED COMPONENTS thread date_time system regex chrono filesystem unit_test_framework)
message(" - boost header: ${Boost_INCLUDE_DIRS}")
message(" - boost lib : ${Boost_LIBRARIES}")

36
test/CMakeLists.txt

@ -3,53 +3,27 @@ cmake_policy(SET CMP0015 NEW)
aux_source_directory(. SRC_LIST)
list(REMOVE_ITEM SRC_LIST "./createRandomTest.cpp")
include_directories(..)
include_directories(${CRYPTOPP_INCLUDE_DIRS})
include_directories(${JSONCPP_INCLUDE_DIRS})
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
include_directories(..)
file(GLOB HEADERS "*.h")
add_executable(testeth ${SRC_LIST} ${HEADERS})
add_executable(createRandomTest createRandomTest.cpp vm.cpp TestHelper.cpp)
target_link_libraries(testeth ethereum)
target_link_libraries(testeth ethcore)
target_link_libraries(testeth secp256k1)
target_link_libraries(testeth gmp)
target_link_libraries(testeth solidity)
target_link_libraries(testeth webthree)
target_link_libraries(testeth ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY_RELEASE})
target_link_libraries(testeth ${CRYPTOPP_LIBRARIES})
if(JSON_RPC_CPP_FOUND)
target_link_libraries(testeth ${JSONCPP_LIBRARIES})
if (JSON_RPC_CPP_FOUND)
target_link_libraries(testeth web3jsonrpc)
target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARY})
endif()
target_link_libraries(createRandomTest ethereum)
target_link_libraries(createRandomTest ethcore)
target_link_libraries(createRandomTest boost_chrono)
target_link_libraries(createRandomTest boost_unit_test_framework)
target_link_libraries(createRandomTest ${CRYPTOPP_LIBRARIES})
if ("${TARGET_PLATFORM}" STREQUAL "w64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
target_link_libraries(testeth boost_system-mt-s)
target_link_libraries(testeth boost_filesystem-mt-s)
target_link_libraries(testeth boost_thread_win32-mt-s)
target_link_libraries(testeth gcc)
target_link_libraries(testeth gdi32)
target_link_libraries(testeth ws2_32)
target_link_libraries(testeth mswsock)
target_link_libraries(testeth shlwapi)
target_link_libraries(testeth iphlpapi)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
elseif (UNIX)
find_package(Boost 1.53 REQUIRED COMPONENTS unit_test_framework)
else ()
target_link_libraries(testeth boost_system)
target_link_libraries(testeth boost_filesystem)
find_package(Threads REQUIRED)
target_link_libraries(testeth ${CMAKE_THREAD_LIBS_INIT})
endif ()
target_link_libraries(createRandomTest ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY_RELEASE})

5
test/jsonrpc.cpp

@ -62,7 +62,7 @@ struct Setup
web3->setIdealPeerCount(5);
web3->ethereum()->setForceMining(true);
auto server = new jsonrpc::CorsHttpServer(8080);
auto server = new jsonrpc::HttpServer(8080);
jsonrpcServer = unique_ptr<WebThreeStubServer>(new WebThreeStubServer(*server, *web3, {}));
jsonrpcServer->setIdentities({});
jsonrpcServer->StartListening();
@ -302,8 +302,11 @@ BOOST_AUTO_TEST_CASE(contract_storage)
Json::Value storage = jsonrpcClient->eth_storageAt(contractAddress);
BOOST_CHECK_EQUAL(storage.getMemberNames().size(), 1);
// bracers are required, cause msvc couldnt handle this macro in for statement
for (auto name: storage.getMemberNames())
{
BOOST_CHECK_EQUAL(storage[name].asString(), "0x03");
}
}
BOOST_AUTO_TEST_SUITE_END()

35
test/solidityEndToEndTest.cpp

@ -519,22 +519,23 @@ BOOST_AUTO_TEST_CASE(simple_mapping)
" }\n"
"}";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes({0x00})) == bytes({0x00}));
BOOST_CHECK(callContractFunction(0, bytes({0x01})) == bytes({0x00}));
BOOST_CHECK(callContractFunction(0, bytes({0xa7})) == bytes({0x00}));
// msvc seems to have problems with initializer-list, when there is only 1 param in the list
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x01, 0xa1}));
BOOST_CHECK(callContractFunction(0, bytes({0x00})) == bytes({0x00}));
BOOST_CHECK(callContractFunction(0, bytes({0x01})) == bytes({0xa1}));
BOOST_CHECK(callContractFunction(0, bytes({0xa7})) == bytes({0x00}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0xa1));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x00, 0xef}));
BOOST_CHECK(callContractFunction(0, bytes({0x00})) == bytes({0xef}));
BOOST_CHECK(callContractFunction(0, bytes({0x01})) == bytes({0xa1}));
BOOST_CHECK(callContractFunction(0, bytes({0xa7})) == bytes({0x00}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0xef));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0xa1));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x01, 0x05}));
BOOST_CHECK(callContractFunction(0, bytes({0x00})) == bytes({0xef}));
BOOST_CHECK(callContractFunction(0, bytes({0x01})) == bytes({0x05}));
BOOST_CHECK(callContractFunction(0, bytes({0xa7})) == bytes({0x00}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0xef));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0x05));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00));
}
BOOST_AUTO_TEST_CASE(mapping_state)
@ -702,9 +703,9 @@ BOOST_AUTO_TEST_CASE(structs)
" }\n"
"}\n";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0) == bytes({0x00}));
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(1) == bytes());
BOOST_CHECK(callContractFunction(0) == bytes({0x01}));
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x01));
}
BOOST_AUTO_TEST_CASE(struct_reference)
@ -730,9 +731,9 @@ BOOST_AUTO_TEST_CASE(struct_reference)
" }\n"
"}\n";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0) == bytes({0x00}));
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(1) == bytes());
BOOST_CHECK(callContractFunction(0) == bytes({0x01}));
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x01));
}
BOOST_AUTO_TEST_CASE(constructor)

3
test/solidityExpressionCompiler.cpp

@ -76,8 +76,11 @@ Declaration const& resolveDeclaration(vector<string> const& _namespacedName,
NameAndTypeResolver const& _resolver)
{
Declaration const* declaration = nullptr;
// bracers are required, cause msvc couldnt handle this macro in for statement
for (string const& namePart: _namespacedName)
{
BOOST_REQUIRE(declaration = _resolver.resolveName(namePart, declaration));
}
BOOST_REQUIRE(declaration);
return *declaration;
}

2
test/solidityJSONInterfaceTest.cpp

@ -22,7 +22,7 @@
#include <boost/test/unit_test.hpp>
#include <libsolidity/CompilerStack.h>
#include <jsonrpc/json/json.h>
#include <jsoncpp/json/json.h>
#include <libdevcore/Exceptions.h>
namespace dev

2
test/solidityNatspecJSON.cpp

@ -22,7 +22,7 @@
#include <boost/test/unit_test.hpp>
#include <libsolidity/CompilerStack.h>
#include <jsonrpc/json/json.h>
#include <jsoncpp/json/json.h>
#include <libdevcore/Exceptions.h>
namespace dev

Loading…
Cancel
Save