# This file is part of the Flowee project # Copyright (C) 2018 Tom Zander # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . project (bitcoin-protocol) include (testlib) # for some reason someone thought it was useful to compile the json files into the exe # instead of just reading them at runtime. # lets emulate that for now. find_program(HEXDUMP "hexdump") find_program(SED "sed") foreach (JSON_FILE data/script_valid.json data/script_invalid.json data/tx_invalid.json data/tx_valid.json) # generate 'sighash' array from 'data/sighash.json' get_filename_component(JSON_NAME ${JSON_FILE} NAME_WE) if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${JSON_FILE}.h") continue() endif () file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${JSON_FILE}.h "namespace json_tests{ static unsigned const char ${JSON_NAME}[] = {") # generate a C++ compatible hex format of the input file. execute_process(COMMAND ${HEXDUMP} -v -e "8/1 \"0x%02x, \"" -e "\"\n\"" ${CMAKE_CURRENT_SOURCE_DIR}/${JSON_FILE} OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${JSON_FILE}.hex ) execute_process(COMMAND ${SED} -e "s/0x ,//g" INPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${JSON_FILE}.hex OUTPUT_VARIABLE HEXDATA) file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${JSON_FILE}.h "${HEXDATA}};};") endforeach () set (TEST_SOURCES arith_uint256_tests.cpp bloom_tests.cpp checkdatasig_tests.cpp crypto_tests.cpp merkle_tests.cpp multisig_tests.cpp native_introspection_tests.cpp pmt_tests.cpp pow_tests.cpp uint256_tests.cpp sighash_utxos_tests.cpp script_P2SH_tests.cpp script_tests.cpp scriptnum_tests.cpp transaction_tests.cpp transaction_utils.cpp TestReverseBytes.cpp DoubleSpendProofTest.cpp main.cpp ) qt6_add_resources(TEST_SOURCES data/jsons.qrc) add_executable(test_protocol ${TEST_SOURCES}) target_link_libraries(test_protocol flowee_testlib_server univalue hub_server flowee_utils ${OPENSSL_LIBRARIES} Boost::filesystem ${BERKELEY_DB_LIBRARIES} ${MINIUPNP_LIBRARY} ) add_test(NAME FLOWEE_test_protocol COMMAND test_protocol)