Add randomx unit tests

This commit is contained in:
Duke
2026-03-03 18:42:14 -05:00
parent 71a8a627bd
commit f15ac8ca8f
2 changed files with 48 additions and 6 deletions

View File

@@ -7,15 +7,13 @@ bin_PROGRAMS += hush-test
# tool for generating our public parameters
hush_test_SOURCES = test-hush/main.cpp \
test-hush/test_netbase_tests.cpp
test-hush/test_netbase_tests.cpp \
test-hush/randomx.cpp
# test-hush/testutils.cpp \
# test-hush/test_cryptoconditions.cpp \
# test-hush/test_coinimport.cpp \
# test-hush/test_addrman.cpp
hush_test_CPPFLAGS = $(hushd_CPPFLAGS)
#hush_test_LDADD = -lgtest $(hushd_LDADD)
hush_test_LDADD = $(hushd_LDADD)
hush_test_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static
hush_test_LDADD = $(hushd_LDADD)
hush_test_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static

44
src/test-hush/randomx.cpp Normal file
View File

@@ -0,0 +1,44 @@
// Copyright (c) 2016-now The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include "addrman.h"
#include <string>
#include "netbase.h"
#include <boost/test/unit_test.hpp>
#include "RandomX/src/randomx.h"
BOOST_AUTO_TEST_SUITE(randomx)
BOOST_AUTO_TEST_CASE(test_basic) {
randomx_flags flags = randomx_get_flags();
randomx_cache *randomxCache = randomx_alloc_cache(flags);
BOOST_CHECK_MESSAGE(randomxCache != NULL, "randomxCache is not null");
randomx_dataset *randomxDataset = randomx_alloc_dataset(flags);
BOOST_CHECK_MESSAGE(randomxDataset != NULL, "randomxDataset is not null");
auto datasetItemCount = randomx_dataset_item_count();
BOOST_CHECK_MESSAGE( datasetItemCount > 0, "datasetItemCount is positive");
// unknown location(0): fatal error: in "randomx/test_basic": memory access violation at address: 0x7f6983ce2000: invalid permissions
/* TODO
randomx_init_dataset(randomxDataset, randomxCache, 0, datasetItemCount);
char randomxHash[RANDOMX_HASH_SIZE];
randomx_vm *myVM = nullptr;
myVM = randomx_create_vm(flags, nullptr, randomxDataset);
BOOST_CHECK_MESSAGE(myVM != NULL, "randomx_vm is not null");
CDataStream randomxInput(SER_NETWORK, PROTOCOL_VERSION);
randomxInput << "stuff and things";
randomx_calculate_hash(myVM, &randomxInput, sizeof randomxInput, randomxHash);
*/
}
BOOST_AUTO_TEST_SUITE_END()