clean up tests and add some utility methods
This commit is contained in:
parent
9ce9270f82
commit
ee6ee27290
6 changed files with 99 additions and 75 deletions
|
|
@ -151,6 +151,11 @@ ENDIF()
|
||||||
|
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
|
|
||||||
|
set(RAPIDJSON_USE_SSE2 ON)
|
||||||
|
set(RAPIDJSON_USE_SSE42 ON)
|
||||||
|
find_package(RapidJSON REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
set( CMAKE_FIND_LIBRARY_SUFFIXES ${ORIGINAL_LIB_SUFFIXES} )
|
set( CMAKE_FIND_LIBRARY_SUFFIXES ${ORIGINAL_LIB_SUFFIXES} )
|
||||||
|
|
||||||
option( UNITY_BUILD OFF )
|
option( UNITY_BUILD OFF )
|
||||||
|
|
@ -375,76 +380,9 @@ add_definitions(-DBOOST_TEST_DYN_LINK)
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
add_executable( bip_lock tests/bip_lock.cpp )
|
|
||||||
target_link_libraries( bip_lock fc )
|
|
||||||
|
|
||||||
add_executable( api tests/api.cpp )
|
|
||||||
target_link_libraries( api fc )
|
|
||||||
|
|
||||||
if( ECC_IMPL STREQUAL secp256k1 )
|
|
||||||
add_executable( blind tests/all_tests.cpp tests/crypto/blind.cpp )
|
|
||||||
target_link_libraries( blind fc )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories( vendor/websocketpp )
|
include_directories( vendor/websocketpp )
|
||||||
|
|
||||||
add_executable( ntp_test tests/all_tests.cpp tests/network/ntp_test.cpp )
|
add_subdirectory(tests)
|
||||||
target_link_libraries( ntp_test fc )
|
|
||||||
|
|
||||||
add_executable( task_cancel_test tests/all_tests.cpp tests/thread/task_cancel.cpp )
|
|
||||||
target_link_libraries( task_cancel_test fc )
|
|
||||||
|
|
||||||
|
|
||||||
add_executable( bloom_test tests/all_tests.cpp tests/bloom_test.cpp )
|
|
||||||
target_link_libraries( bloom_test fc )
|
|
||||||
|
|
||||||
add_executable( real128_test tests/all_tests.cpp tests/real128_test.cpp )
|
|
||||||
target_link_libraries( real128_test fc )
|
|
||||||
|
|
||||||
add_executable( hmac_test tests/hmac_test.cpp )
|
|
||||||
target_link_libraries( hmac_test fc )
|
|
||||||
|
|
||||||
add_executable( blinding_test tests/blinding_test.cpp )
|
|
||||||
target_link_libraries( blinding_test fc )
|
|
||||||
|
|
||||||
|
|
||||||
add_executable( udt_server tests/udts.cpp )
|
|
||||||
target_link_libraries( udt_server fc udt )
|
|
||||||
|
|
||||||
add_executable( udt_client tests/udtc.cpp )
|
|
||||||
target_link_libraries( udt_client fc udt )
|
|
||||||
|
|
||||||
add_executable( ecc_test tests/crypto/ecc_test.cpp )
|
|
||||||
target_link_libraries( ecc_test fc )
|
|
||||||
|
|
||||||
add_executable( log_test tests/crypto/log_test.cpp )
|
|
||||||
target_link_libraries( log_test fc )
|
|
||||||
|
|
||||||
#add_executable( test_aes tests/aes_test.cpp )
|
|
||||||
#target_link_libraries( test_aes fc ${rt_library} ${pthread_library} )
|
|
||||||
#add_executable( test_sleep tests/sleep.cpp )
|
|
||||||
#target_link_libraries( test_sleep fc )
|
|
||||||
#add_executable( test_rate_limiting tests/rate_limiting.cpp )
|
|
||||||
#target_link_libraries( test_rate_limiting fc )
|
|
||||||
|
|
||||||
add_executable( all_tests tests/all_tests.cpp
|
|
||||||
tests/compress/compress.cpp
|
|
||||||
tests/crypto/aes_test.cpp
|
|
||||||
tests/crypto/base_n_tests.cpp
|
|
||||||
tests/crypto/bigint_test.cpp
|
|
||||||
tests/crypto/blind.cpp
|
|
||||||
tests/crypto/blowfish_test.cpp
|
|
||||||
tests/crypto/dh_test.cpp
|
|
||||||
tests/crypto/rand_test.cpp
|
|
||||||
tests/crypto/sha_tests.cpp
|
|
||||||
tests/network/ntp_test.cpp
|
|
||||||
tests/network/http/websocket_test.cpp
|
|
||||||
tests/thread/task_cancel.cpp
|
|
||||||
tests/bloom_test.cpp
|
|
||||||
tests/real128_test.cpp
|
|
||||||
tests/utf8_test.cpp
|
|
||||||
)
|
|
||||||
target_link_libraries( all_tests fc )
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# add addtional import library on windows platform
|
# add addtional import library on windows platform
|
||||||
|
|
|
||||||
|
|
@ -45,3 +45,5 @@ mark_as_advanced(
|
||||||
Readline_INCLUDE_DIR
|
Readline_INCLUDE_DIR
|
||||||
Readline_LIBRARY
|
Readline_LIBRARY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
MESSAGE( STATUS "Found Readline: ${Readline_LIBRARY}" )
|
||||||
|
|
|
||||||
|
|
@ -118,5 +118,17 @@ namespace std
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
struct hash<fc::sha256>
|
||||||
|
{
|
||||||
|
size_t operator()( const fc::sha256& s )const
|
||||||
|
{
|
||||||
|
return s._hash[3];//*((size_t*)&s);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
#include <fc/reflect/reflect.hpp>
|
#include <fc/reflect/reflect.hpp>
|
||||||
FC_REFLECT_TYPENAME( fc::sha256 )
|
FC_REFLECT_TYPENAME( fc::sha256 )
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ namespace fc {
|
||||||
template<typename Storage> class fixed_string;
|
template<typename Storage> class fixed_string;
|
||||||
|
|
||||||
namespace raw {
|
namespace raw {
|
||||||
|
template<typename T>
|
||||||
|
inline size_t pack_size( const T& v );
|
||||||
|
|
||||||
template<typename Stream, typename Storage> inline void pack( Stream& s, const fc::fixed_string<Storage>& u );
|
template<typename Stream, typename Storage> inline void pack( Stream& s, const fc::fixed_string<Storage>& u );
|
||||||
template<typename Stream, typename Storage> inline void unpack( Stream& s, fc::fixed_string<Storage>& u );
|
template<typename Stream, typename Storage> inline void unpack( Stream& s, fc::fixed_string<Storage>& u );
|
||||||
|
|
||||||
|
|
|
||||||
69
tests/CMakeLists.txt
Normal file
69
tests/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
|
||||||
|
add_executable( bip_lock bip_lock.cpp )
|
||||||
|
target_link_libraries( bip_lock fc )
|
||||||
|
|
||||||
|
add_executable( api api.cpp )
|
||||||
|
target_link_libraries( api fc )
|
||||||
|
|
||||||
|
if( ECC_IMPL STREQUAL secp256k1 )
|
||||||
|
add_executable( blind all_tests.cpp crypto/blind.cpp )
|
||||||
|
target_link_libraries( blind fc )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable( ntp_test all_tests.cpp network/ntp_test.cpp )
|
||||||
|
target_link_libraries( ntp_test fc )
|
||||||
|
|
||||||
|
add_executable( task_cancel_test all_tests.cpp thread/task_cancel.cpp )
|
||||||
|
target_link_libraries( task_cancel_test fc )
|
||||||
|
|
||||||
|
|
||||||
|
add_executable( bloom_test all_tests.cpp bloom_test.cpp )
|
||||||
|
target_link_libraries( bloom_test fc )
|
||||||
|
|
||||||
|
add_executable( real128_test all_tests.cpp real128_test.cpp )
|
||||||
|
target_link_libraries( real128_test fc )
|
||||||
|
|
||||||
|
add_executable( hmac_test hmac_test.cpp )
|
||||||
|
target_link_libraries( hmac_test fc )
|
||||||
|
|
||||||
|
add_executable( blinding_test blinding_test.cpp )
|
||||||
|
target_link_libraries( blinding_test fc )
|
||||||
|
|
||||||
|
|
||||||
|
add_executable( udt_server udts.cpp )
|
||||||
|
target_link_libraries( udt_server fc udt )
|
||||||
|
|
||||||
|
add_executable( udt_client udtc.cpp )
|
||||||
|
target_link_libraries( udt_client fc udt )
|
||||||
|
|
||||||
|
add_executable( ecc_test crypto/ecc_test.cpp )
|
||||||
|
target_link_libraries( ecc_test fc )
|
||||||
|
|
||||||
|
add_executable( log_test crypto/log_test.cpp )
|
||||||
|
target_link_libraries( log_test fc )
|
||||||
|
|
||||||
|
#add_executable( test_aes aes_test.cpp )
|
||||||
|
#target_link_libraries( test_aes fc ${rt_library} ${pthread_library} )
|
||||||
|
#add_executable( test_sleep sleep.cpp )
|
||||||
|
#target_link_libraries( test_sleep fc )
|
||||||
|
#add_executable( test_rate_limiting rate_limiting.cpp )
|
||||||
|
#target_link_libraries( test_rate_limiting fc )
|
||||||
|
|
||||||
|
add_executable( all_tests all_tests.cpp
|
||||||
|
compress/compress.cpp
|
||||||
|
crypto/aes_test.cpp
|
||||||
|
crypto/base_n_tests.cpp
|
||||||
|
crypto/bigint_test.cpp
|
||||||
|
crypto/blind.cpp
|
||||||
|
crypto/blowfish_test.cpp
|
||||||
|
crypto/dh_test.cpp
|
||||||
|
crypto/rand_test.cpp
|
||||||
|
crypto/sha_tests.cpp
|
||||||
|
network/ntp_test.cpp
|
||||||
|
network/http/websocket_test.cpp
|
||||||
|
thread/task_cancel.cpp
|
||||||
|
bloom_test.cpp
|
||||||
|
real128_test.cpp
|
||||||
|
utf8_test.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries( all_tests fc )
|
||||||
|
|
@ -50,15 +50,15 @@ BOOST_AUTO_TEST_CASE(blind_test)
|
||||||
auto B4 = fc::sha256::hash("B4");
|
auto B4 = fc::sha256::hash("B4");
|
||||||
auto C1 = fc::ecc::blind( B1, 1 );
|
auto C1 = fc::ecc::blind( B1, 1 );
|
||||||
auto C2 = fc::ecc::blind( B2, 2 );
|
auto C2 = fc::ecc::blind( B2, 2 );
|
||||||
auto c3 = fc::ecc::blind( b3, 3 );
|
/*auto c3 = */fc::ecc::blind( b3, 3 );
|
||||||
auto C4 = fc::ecc::blind( B4, -1 );
|
/*auto C4 = */fc::ecc::blind( B4, -1 );
|
||||||
|
|
||||||
auto B3 = fc::ecc::blind_sum( {B1,B2}, 2 );
|
auto B3 = fc::ecc::blind_sum( {B1,B2}, 2 );
|
||||||
auto C3 = fc::ecc::blind( B3, 3 );
|
auto C3 = fc::ecc::blind( B3, 3 );
|
||||||
|
|
||||||
|
|
||||||
auto B2m1 = fc::ecc::blind_sum( {B2,B1}, 1 );
|
auto B2m1 = fc::ecc::blind_sum( {B2,B1}, 1 );
|
||||||
auto C2m1 = fc::ecc::blind( B2m1, 1 );
|
/*auto C2m1 = */fc::ecc::blind( B2m1, 1 );
|
||||||
|
|
||||||
BOOST_CHECK( fc::ecc::verify_sum( {C1,C2}, {C3}, 0 ) );
|
BOOST_CHECK( fc::ecc::verify_sum( {C1,C2}, {C3}, 0 ) );
|
||||||
BOOST_CHECK( fc::ecc::verify_sum( {C1,C2}, {C3}, 0 ) );
|
BOOST_CHECK( fc::ecc::verify_sum( {C1,C2}, {C3}, 0 ) );
|
||||||
|
|
@ -68,9 +68,9 @@ BOOST_AUTO_TEST_CASE(blind_test)
|
||||||
|
|
||||||
{
|
{
|
||||||
auto B1 = fc::sha256::hash("B1");
|
auto B1 = fc::sha256::hash("B1");
|
||||||
auto B2 = fc::sha256::hash("B2");
|
/*auto B2 = */fc::sha256::hash("B2");
|
||||||
auto B3 = fc::sha256::hash("B3");
|
/*auto B3 = */fc::sha256::hash("B3");
|
||||||
auto B4 = fc::sha256::hash("B4");
|
/*auto B4 = */fc::sha256::hash("B4");
|
||||||
|
|
||||||
//secp256k1_scalar_get_b32((unsigned char*)&B1, (const secp256k1_scalar_t*)&B2);
|
//secp256k1_scalar_get_b32((unsigned char*)&B1, (const secp256k1_scalar_t*)&B2);
|
||||||
//B1 = fc::variant("b2e5da56ef9f2a34d3e22fd12634bc99261e95c87b9960bf94ed3d27b30").as<fc::sha256>();
|
//B1 = fc::variant("b2e5da56ef9f2a34d3e22fd12634bc99261e95c87b9960bf94ed3d27b30").as<fc::sha256>();
|
||||||
|
|
@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(blind_test)
|
||||||
auto C1 = fc::ecc::blind( B1, INT64_MAX );
|
auto C1 = fc::ecc::blind( B1, INT64_MAX );
|
||||||
auto C2 = fc::ecc::blind( B1, 0 );
|
auto C2 = fc::ecc::blind( B1, 0 );
|
||||||
auto C3 = fc::ecc::blind( B1, 1 );
|
auto C3 = fc::ecc::blind( B1, 1 );
|
||||||
auto C4 = fc::ecc::blind( B1, 2 );
|
/*auto C4 = */fc::ecc::blind( B1, 2 );
|
||||||
|
|
||||||
BOOST_CHECK( fc::ecc::verify_sum( {C2}, {C3}, -1 ) );
|
BOOST_CHECK( fc::ecc::verify_sum( {C2}, {C3}, -1 ) );
|
||||||
BOOST_CHECK( fc::ecc::verify_sum( {C1}, {C1}, 0 ) );
|
BOOST_CHECK( fc::ecc::verify_sum( {C1}, {C1}, 0 ) );
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue