More refactoring

This commit is contained in:
Peter Conrad 2015-07-23 23:20:17 +02:00
parent 5f4ff1aa21
commit ca896b2c85
3 changed files with 30 additions and 32 deletions

View file

@ -322,20 +322,20 @@ add_executable( api tests/api.cpp )
target_link_libraries( api fc )
if( ECC_IMPL STREQUAL secp256k1 )
add_executable( blind tests/blind.cpp )
add_executable( blind tests/all_tests.cpp tests/blind.cpp )
target_link_libraries( blind fc )
endif()
include_directories( vendor/websocketpp )
add_executable( ntp_test ntp_test.cpp )
add_executable( ntp_test tests/all_tests.cpp tests/ntp_test.cpp )
target_link_libraries( ntp_test fc )
add_executable( task_cancel_test tests/all_tests.cpp tests/task_cancel.cpp )
target_link_libraries( task_cancel_test fc )
add_executable( bloom_test tests/bloom_test.cpp )
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 )
@ -360,7 +360,8 @@ target_link_libraries( ecc_test fc )
add_executable( all_tests tests/all_tests.cpp tests/blind.cpp
tests/bloom_test.cpp
tests/compress.cpp tests/real128_test.cpp
tests/compress.cpp tests/ntp_test.cpp
tests/real128_test.cpp
tests/task_cancel.cpp )
target_link_libraries( all_tests fc )

View file

@ -1,28 +0,0 @@
#include <fc/network/ntp.hpp>
#include <fc/log/logger.hpp>
#include <fc/thread/thread.hpp>
int main( int argc, char** argv )
{
fc::ntp ntp_service;
ntp_service.set_request_interval(5);
fc::usleep(fc::seconds(4) );
auto time = ntp_service.get_time();
if( time )
{
auto ntp_time = *time;
auto delta = ntp_time - fc::time_point::now();
auto minutes = delta.count() / 1000000 / 60;
auto hours = delta.count() / 1000000 / 60 / 60;
auto seconds = delta.count() / 1000000;
auto msec= delta.count() / 1000;
idump( (fc::time_point::now() ) );
idump( (ntp_time)(delta)(msec)(seconds)(minutes)(hours) );
}
else
{
elog( "no response" );
}
return 0;
}

25
tests/ntp_test.cpp Normal file
View file

@ -0,0 +1,25 @@
#include <boost/test/unit_test.hpp>
#include <fc/network/ntp.hpp>
#include <fc/log/logger.hpp>
#include <fc/thread/thread.hpp>
BOOST_AUTO_TEST_SUITE(fc_network)
BOOST_AUTO_TEST_CASE( ntp_test )
{
fc::ntp ntp_service;
ntp_service.set_request_interval(5);
fc::usleep(fc::seconds(4) );
auto time = ntp_service.get_time();
BOOST_CHECK( time );
auto ntp_time = *time;
auto delta = ntp_time - fc::time_point::now();
// auto minutes = delta.count() / 1000000 / 60;
// auto hours = delta.count() / 1000000 / 60 / 60;
// auto seconds = delta.count() / 1000000;
auto msec= delta.count() / 1000;
BOOST_CHECK( msec < 100 );
}
BOOST_AUTO_TEST_SUITE_END()