Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #292

Merged
merged 33 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d9bd0de
Daemon testnet
AxVultis Apr 9, 2022
648e9f5
Daemon testnet tests
AxVultis Apr 9, 2022
6aef9c3
Update testnet checkpoints
AxVultis Apr 9, 2022
379f8cb
WalletLegacy testnet
AxVultis Apr 9, 2022
07016a7
PaymentGateService testnet
AxVultis Apr 9, 2022
c607808
Update PaymentGate default bind port
AxVultis Apr 9, 2022
7fde676
Build CryptoTests, TransfersTests, UnitTests, HashTargetTests and Has…
AxVultis May 19, 2022
760f7b9
Merge branch 'master' into development
AxVultis May 21, 2022
8ee7f9f
Update BlockReward tests
AxVultis May 22, 2022
e85c89a
Update Checkpoints tests
AxVultis May 22, 2022
e2229b0
Update TestUpgradeDetector tests
AxVultis May 22, 2022
311e8b6
Update runtime_error messages
AxVultis May 27, 2022
9317680
Update serialization
AxVultis May 27, 2022
f5381fd
Update TestTransactionPoolDetach tests
AxVultis May 28, 2022
8b2e91e
Update TestWalletService tests
AxVultis May 28, 2022
261b438
Add unit_tests to check
AxVultis May 28, 2022
ce180ec
Add one test to filter
AxVultis May 28, 2022
b07b754
Possible to build with mingw
AxVultis May 31, 2022
5b8d0f0
Update TransactionPool
AxVultis Jun 6, 2022
36a583d
Update cn_slow_hash_soft
AxVultis Jun 6, 2022
7b77baa
Merge branch 'strings' into unit-tests
AxVultis Jun 6, 2022
9551b91
Merge branch 'mingw' into unit-tests
AxVultis Jun 6, 2022
795ccd9
Update BOOST_ROOT
AxVultis Jun 6, 2022
dac14cb
Update tests
AxVultis Jun 6, 2022
ac6feca
Update Json Serialization
AxVultis Jun 6, 2022
1e522ce
Add MinGW to build check
AxVultis Jun 6, 2022
87f81b2
Merge branch 'unit-tests' into mingw
AxVultis Jun 6, 2022
8783041
Update NetNode
AxVultis Jun 6, 2022
56c2509
Merge branch 'mingw' into unit-tests
AxVultis Jun 6, 2022
4a9e2cc
Update TransactionPool tests
AxVultis Jun 25, 2022
5838f91
Update TestWalletLegacy
AxVultis Jul 3, 2022
54a4257
Update TestWalletLegacy
AxVultis Jul 8, 2022
6dd475e
Update TestWalletLegacy
AxVultis Jul 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 110 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Windows
runs-on: windows-2019
env:
BOOST_ROOT: C:/tools/boost/x86_64
BOOST_ROOT: C:/local/boost_1_72_0
steps:
- uses: actions/checkout@master

Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
mv build/src/Release/concealwallet.exe build/conceal
mv build/src/Release/optimizer.exe build/conceal
mv build/src/Release/walletd.exe build/conceal
mv build/tests/Release/*_tests.exe build/conceal
cp build/tests/Release/*_tests.exe build/conceal

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -82,6 +82,90 @@ jobs:
run: |
cd build/conceal
./performance_tests.exe

- name: unit_tests
shell: powershell
run: |
cd build/tests
ctest -R UnitTests --output-on-failure

build-mingw:
name: MinGW
runs-on: windows-2019
steps:
- uses: msys2/setup-msys2@v2
with:
update: true
install: >-
git
base-devel
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-boost
mingw-w64-x86_64-cmake

- uses: actions/checkout@master

- name: Prepare version
shell: powershell
id: setup
run: |
$os="mingw"
$ccx_version="${{ github.sha }}".SubString(0,7)
$release_name="ccx-cli-$os-dev-$ccx_version"
echo "::set-output name=release_name::${release_name}"

- name: Build
shell: msys2 {0}
id: build
run: |
ls
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DSTATIC=ON
cmake --build . --config Release

- name: Prepare release
shell: msys2 {0}
run: |
mkdir build/conceal
mv build/src/conceald.exe build/conceal
mv build/src/concealwallet.exe build/conceal
mv build/src/optimizer.exe build/conceal
mv build/src/walletd.exe build/conceal
cp build/tests/*_tests.exe build/conceal

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.setup.outputs.release_name }}
path: build/conceal
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: core_tests
shell: powershell
run: |
cd build/conceal
./core_tests.exe --generate_and_play_test_data

- name: difficulty_tests
shell: powershell
run: |
cp tests/Difficulty/data.txt build/conceal
cd build/conceal
./difficulty_tests.exe data.txt

- name: performance_tests
shell: powershell
run: |
cd build/conceal
./performance_tests.exe

- name: unit_tests
shell: powershell
run: |
cd build/tests
ctest -R UnitTests --output-on-failure

build-ubuntu18:
name: Ubuntu 18.04
Expand Down Expand Up @@ -117,7 +201,7 @@ jobs:
mv build/src/concealwallet build/conceal
mv build/src/optimizer build/conceal
mv build/src/walletd build/conceal
mv build/tests/*_tests build/conceal
cp build/tests/*_tests build/conceal

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -147,6 +231,11 @@ jobs:
run: |
cd build/conceal
./system_tests

- name: unit_tests
run: |
cd build/tests
ctest -R UnitTests --output-on-failure

build-ubuntu20:
name: Ubuntu 20.04
Expand Down Expand Up @@ -182,7 +271,7 @@ jobs:
mv build/src/concealwallet build/conceal
mv build/src/optimizer build/conceal
mv build/src/walletd build/conceal
mv build/tests/*_tests build/conceal
cp build/tests/*_tests build/conceal

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -213,6 +302,11 @@ jobs:
cd build/conceal
./system_tests

- name: unit_tests
run: |
cd build/tests
ctest -R UnitTests --output-on-failure

build-ubuntu20-clang:
name: Ubuntu 20.04 clang
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -247,7 +341,7 @@ jobs:
mv build/src/concealwallet build/conceal
mv build/src/optimizer build/conceal
mv build/src/walletd build/conceal
mv build/tests/*_tests build/conceal
cp build/tests/*_tests build/conceal

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -278,6 +372,11 @@ jobs:
cd build/conceal
./system_tests

- name: unit_tests
run: |
cd build/tests
ctest -R UnitTests --output-on-failure

build-macos11:
name: macOS
runs-on: macos-11
Expand Down Expand Up @@ -311,7 +410,7 @@ jobs:
mv build/src/concealwallet build/conceal
mv build/src/optimizer build/conceal
mv build/src/walletd build/conceal
mv build/tests/*_tests build/conceal
cp build/tests/*_tests build/conceal

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v2
Expand All @@ -336,3 +435,8 @@ jobs:
run: |
cd build/conceal
./performance_tests

- name: unit_tests
run: |
cd build/tests
ctest -R UnitTests --output-on-failure
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Windows
runs-on: windows-2019
env:
BOOST_ROOT: C:/hostedtoolcache/windows/Boost/1.72.0/x86_64
BOOST_ROOT: C:/local/boost_1_72_0
steps:
- uses: actions/checkout@master

Expand Down
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if(APPLE OR FREEBSD)
enable_language(ASM)
endif()

if(MSVC)
if(MSVC OR MINGW)
include_directories(src/Platform/Windows)
elseif(APPLE)
include_directories(src/Platform/OSX)
Expand Down Expand Up @@ -82,6 +82,10 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAG}")

set(STATIC ${MSVC} CACHE BOOL "Link libraries statically")

if(MINGW AND STATIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
endif()

if(MSVC)
add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D_VARIADIC_MAX=8 /D__SSE4_1__")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10485760")
Expand Down Expand Up @@ -120,7 +124,7 @@ else()
set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes")
set(CXX_WARNINGS "-Wno-reorder -Wno-missing-field-initializers")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 ${MINGW_FLAG} ${WARNINGS} ${C_WARNINGS}")
if(NOT APPLE)
if(NOT APPLE AND NOT MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS}")
Expand Down Expand Up @@ -151,7 +155,7 @@ find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread date_time c
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})

if(MINGW)
set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock")
set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock;bcrypt")
elseif(APPLE)
set(Boost_LIBRARIES "${Boost_LIBRARIES}")
elseif(NOT MSVC)
Expand Down Expand Up @@ -199,5 +203,9 @@ else()
endif()
endif()

if(MINGW AND STATIC)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
endif()

add_subdirectory(external)
add_subdirectory(src)
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ file(GLOB_RECURSE JsonRpcServer JsonRpcServer/*)
file(GLOB_RECURSE PaymentGate PaymentGate/*)
file(GLOB_RECURSE PaymentGateService PaymentGateService/*)

if(MSVC)
if(MSVC OR MINGW)
file(GLOB_RECURSE System System/* Platform/Windows/System/*)
elseif(APPLE)
file(GLOB_RECURSE System System/* Platform/OSX/System/*)
Expand Down Expand Up @@ -59,6 +59,12 @@ if (MSVC)
target_link_libraries(System ws2_32)
endif ()

if (MINGW)
target_link_libraries(Common dnsapi)
target_link_libraries(P2P bcrypt)
target_link_libraries(System ws2_32)
endif ()

target_link_libraries(Daemon CryptoNoteCore P2P Rpc System Http Logging Common crypto libminiupnpc-static BlockchainExplorer ${Boost_LIBRARIES} Serialization)
target_link_libraries(SimpleWallet Wallet NodeRpcProxy Transfers Rpc Http CryptoNoteCore System Logging Common crypto ${Boost_LIBRARIES} Serialization)
target_link_libraries(PaymentGateService PaymentGate JsonRpcServer Wallet NodeRpcProxy Transfers CryptoNoteCore crypto P2P Rpc Http System Logging Common InProcessNode libminiupnpc-static BlockchainExplorer ${Boost_LIBRARIES} Serialization)
Expand Down
5 changes: 5 additions & 0 deletions src/Common/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ namespace command_line
const arg_descriptor<bool> arg_help = {"help", "Produce help message"};
const arg_descriptor<bool> arg_version = {"version", "Output version information"};
const arg_descriptor<std::string> arg_data_dir = {"data-dir", "Specify data directory"};
const command_line::arg_descriptor<bool> arg_testnet_on = {
"testnet",
"Use testnet instead of mainnet",
false
};
}
1 change: 1 addition & 0 deletions src/Common/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,5 @@ namespace command_line
extern const arg_descriptor<bool> arg_help;
extern const arg_descriptor<bool> arg_version;
extern const arg_descriptor<std::string> arg_data_dir;
extern const command_line::arg_descriptor<bool> arg_testnet_on;
}
12 changes: 6 additions & 6 deletions src/Common/StreamTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void read(IInputStream& in, void* data, size_t size) {
while (size > 0) {
size_t readSize = in.readSome(data, size);
if (readSize == 0) {
throw std::runtime_error("Failed to read from IInputStream");
throw std::runtime_error("Reading from IInputStream failed");
}

data = static_cast<uint8_t*>(data) + readSize;
Expand Down Expand Up @@ -85,7 +85,7 @@ void readVarint(IInputStream& in, uint8_t& value) {
temp |= static_cast<size_t>(piece & 0x7f) << shift;
if ((piece & 0x80) == 0) {
if (piece == 0 && shift != 0) {
throw std::runtime_error("readVarint, invalid value representation");
throw std::runtime_error("readVarint, unrepresentable value");
}

break;
Expand All @@ -107,7 +107,7 @@ void readVarint(IInputStream& in, uint16_t& value) {
temp |= static_cast<size_t>(piece & 0x7f) << shift;
if ((piece & 0x80) == 0) {
if (piece == 0 && shift != 0) {
throw std::runtime_error("readVarint, invalid value representation");
throw std::runtime_error("readVarint, unrepresentable value");
}

break;
Expand All @@ -129,7 +129,7 @@ void readVarint(IInputStream& in, uint32_t& value) {
temp |= static_cast<size_t>(piece & 0x7f) << shift;
if ((piece & 0x80) == 0) {
if (piece == 0 && shift != 0) {
throw std::runtime_error("readVarint, invalid value representation");
throw std::runtime_error("readVarint, unrepresentable value");
}

break;
Expand All @@ -151,7 +151,7 @@ void readVarint(IInputStream& in, uint64_t& value) {
temp |= static_cast<uint64_t>(piece & 0x7f) << shift;
if ((piece & 0x80) == 0) {
if (piece == 0 && shift != 0) {
throw std::runtime_error("readVarint, invalid value representation");
throw std::runtime_error("readVarint, unrepresentable value");
}

break;
Expand All @@ -165,7 +165,7 @@ void write(IOutputStream& out, const void* data, size_t size) {
while (size > 0) {
size_t writtenSize = out.writeSome(data, size);
if (writtenSize == 0) {
throw std::runtime_error("Failed to write to IOutputStream");
throw std::runtime_error("IOutputStream could not be written to");
}

data = static_cast<const uint8_t*>(data) + writtenSize;
Expand Down
6 changes: 3 additions & 3 deletions src/Common/StringTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ bool fromHex(char character, uint8_t& value) {

size_t fromHex(const std::string& text, void* data, size_t bufferSize) {
if ((text.size() & 1) != 0) {
throw std::runtime_error("fromHex: invalid string size");
throw std::runtime_error("incorrect string size in fromHex");
}

if (text.size() >> 1 > bufferSize) {
throw std::runtime_error("fromHex: invalid buffer size");
throw std::runtime_error("incorrect buffer size in fromHex");
}

for (size_t i = 0; i < text.size() >> 1; ++i) {
Expand Down Expand Up @@ -109,7 +109,7 @@ bool fromHex(const std::string& text, void* data, size_t bufferSize, size_t& siz

std::vector<uint8_t> fromHex(const std::string& text) {
if ((text.size() & 1) != 0) {
throw std::runtime_error("fromHex: invalid string size");
throw std::runtime_error("incorrect string size in fromHex");
}

std::vector<uint8_t> data(text.size() >> 1);
Expand Down
8 changes: 4 additions & 4 deletions src/Common/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ std::string get_nix_version_display_string()
}
#endif

std::string getDefaultDataDirectory()
std::string getDefaultDataDirectory(bool testnet)
{
//namespace fs = boost::filesystem;
// Windows < Vista: C:\Documents and Settings\Username\Application Data\BLOCKCHAIN_DIR
Expand All @@ -299,8 +299,8 @@ std::string get_nix_version_display_string()
config_folder = get_special_folder_path(CSIDL_APPDATA, true) + "/" + cn::BLOCKCHAIN_DIR;
#else
std::string pathRet;
char* pszHome = getenv("HOME");
if (pszHome == NULL || strlen(pszHome) == 0)
const char* pszHome = getenv("HOME");
if (pszHome == nullptr || strlen(pszHome) == 0)
pathRet = "/";
else
pathRet = pszHome;
Expand All @@ -314,7 +314,7 @@ std::string get_nix_version_display_string()
#endif
#endif

return config_folder;
return config_folder + (testnet ? "/testnet" : "");
}

bool create_directories_if_necessary(const std::string& path)
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace tools
{
std::string getDefaultDataDirectory();
std::string getDefaultDataDirectory(bool testnet = false);
std::string get_os_version_string();
bool create_directories_if_necessary(const std::string& path);
std::error_code replace_file(const std::string& replacement_name, const std::string& replaced_name);
Expand Down
Loading