#include #include #include BOOST_AUTO_TEST_SUITE(tcp_tests) /*** * Running this test through valgrind will show * a memory leak due to lack of logic in destructor. * See https://github.com/bitshares/bitshares-fc/blob/51688042b0b9f99f03224f54fb937fe024fe5ced/src/asio.cpp#L152 */ BOOST_AUTO_TEST_CASE(tcpconstructor_test) { fc::tcp_socket socket; } class my_io_class : public fc::asio::default_io_service_scope { public: uint16_t get_num_threads() { return fc::asio::default_io_service_scope::num_io_threads; } static void reset_num_threads() { fc::asio::default_io_service_scope::num_io_threads = 0; } }; /*** * Test the control of number of threads from outside */ BOOST_AUTO_TEST_CASE( number_threads_test ) { // to erase leftovers from previous tests my_io_class::reset_num_threads(); fc::asio::default_io_service_scope::set_num_threads(12); my_io_class my_class; BOOST_CHECK_EQUAL( 12, my_class.get_num_threads() ); } /*** * Test the control of number of threads from outside */ BOOST_AUTO_TEST_CASE( default_number_threads_test ) { // to erase leftovers from previous tests my_io_class::reset_num_threads(); my_io_class my_class; fc::asio::default_io_service(); BOOST_CHECK( my_class.get_num_threads() > 1 ); } BOOST_AUTO_TEST_SUITE_END()