From ca896b2c8547aee30e133e5bd7de268362d34bd7 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 23 Jul 2015 23:20:17 +0200 Subject: [PATCH] More refactoring --- CMakeLists.txt | 9 +++++---- ntp_test.cpp | 28 ---------------------------- tests/ntp_test.cpp | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 ntp_test.cpp create mode 100644 tests/ntp_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 18b5c56..0ad167e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/ntp_test.cpp b/ntp_test.cpp deleted file mode 100644 index b3937b1..0000000 --- a/ntp_test.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -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; -} diff --git a/tests/ntp_test.cpp b/tests/ntp_test.cpp new file mode 100644 index 0000000..f0c02d4 --- /dev/null +++ b/tests/ntp_test.cpp @@ -0,0 +1,25 @@ +#include + +#include +#include +#include + +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()