From 9907b6ec54894c01e1f6dcfd80764f08ac84743a Mon Sep 17 00:00:00 2001 From: Bohdan Date: Tue, 17 Mar 2020 12:02:37 +0000 Subject: [PATCH 01/14] Fix (#29) --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4273532c0f6fe..1e7c6d51acd01 100644 --- a/configure.ac +++ b/configure.ac @@ -1250,6 +1250,7 @@ if test x$use_pkgconfig = xyes; then [PKG_CHECK_MODULES], [ echo "pkg-config is used..." + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig PKG_CHECK_MODULES([GRPC], [grpc++ protobuf],, [AC_MSG_ERROR(grpc++/protobuf not found.)]) PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)]) PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)]) @@ -1296,7 +1297,8 @@ else if test x$use_tests != xno; then AC_CHECK_HEADER([gmock/gmock.h],,AC_MSG_ERROR(libgmock headers missing)) - AC_CHECK_LIB([gmock],[main],[GMOCK_LIBS=" -lgmock"],AC_MSG_ERROR(libgmock missing)) + AC_CHECK_LIB([gtest],[main],[GMOCK_LIBS=" -lgtest"],AC_MSG_ERROR(libgtest missing)) + AC_CHECK_LIB([gmock],[main],[GMOCK_LIBS+=" -lgmock"],AC_MSG_ERROR(libgmock missing)) fi AC_ARG_VAR(GRPC_LIBS, "linker flags for GRPC") From 01cf37c2725ac19a8c3c26faca71f523fcf05c66 Mon Sep 17 00:00:00 2001 From: Andrew Lekar Date: Fri, 27 Mar 2020 13:39:27 +0000 Subject: [PATCH 02/14] Try linking --- configure.ac | 1 + src/Makefile.am | 5 +++-- src/Makefile.test.include | 2 +- src/test/addrman_tests.cpp | 8 ++++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 1e7c6d51acd01..abb576777f1f4 100644 --- a/configure.ac +++ b/configure.ac @@ -1254,6 +1254,7 @@ if test x$use_pkgconfig = xyes; then PKG_CHECK_MODULES([GRPC], [grpc++ protobuf],, [AC_MSG_ERROR(grpc++/protobuf not found.)]) PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)]) PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)]) + PKG_CHECK_MODULES([ALT_INT], [altintegration],,[AC_MSG_ERROR(altintegration not found.)]) if test x$use_tests != xno; then PKG_CHECK_MODULES([GMOCK], [gmock],,[AC_MSG_ERROR(gmock not found.)]) fi diff --git a/src/Makefile.am b/src/Makefile.am index c66b08d441999..baae913d8c688 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -623,7 +623,8 @@ bitcoind_LDADD = \ $(LIBLEVELDB_SSE42) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ - $(GRPC_LIBS) + $(GRPC_LIBS) \ + $(ALT_INT_LIBS) bitcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) @@ -710,7 +711,7 @@ if GLIBC_BACK_COMPAT endif libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) -libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1) +libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1) $(ALT_INT_LIBS) libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 3b38c1ca94ca7..3d2ec1023f092 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -242,7 +242,7 @@ endif test_test_bitcoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) \ $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(GRPC_LIBS) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) \ - $(GMOCK_LIBS) + $(GMOCK_LIBS) $(ALT_INT_LIBS) test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -g -Og test_test_bitcoin_LDADD += $(BDB_LIBS) $(MINIUPNPC_LIBS) $(RAPIDCHECK_LIBS) diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index c034216bc119f..55a5bcecd4a52 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -9,6 +9,7 @@ #include #include #include +#include class CAddrManTest : public CAddrMan { @@ -91,6 +92,9 @@ BOOST_AUTO_TEST_CASE(addrman_simple) CNetAddr source = ResolveIP("252.2.2.2"); + altintegration::ArithUint256 abc = altintegration::ArithUint256(100); + BOOST_CHECK_EQUAL(abc.getLow64(), 100); + // Test: Does Addrman respond correctly when empty. BOOST_CHECK_EQUAL(addrman.size(), 0U); CAddrInfo addr_null = addrman.Select(); @@ -134,7 +138,7 @@ BOOST_AUTO_TEST_CASE(addrman_simple) BOOST_CHECK(addrman.size() >= 1); } -BOOST_AUTO_TEST_CASE(addrman_ports) +/*BOOST_AUTO_TEST_CASE(addrman_ports) { CAddrManTest addrman; @@ -669,7 +673,7 @@ BOOST_AUTO_TEST_CASE(addrman_evictionworks) addrman.ResolveCollisions(); BOOST_CHECK(addrman.SelectTriedCollision().ToString() == "[::]:0"); -} +}*/ BOOST_AUTO_TEST_SUITE_END() From 63b9e28a1141ce82a72d9049dd38283cee1cdf4d Mon Sep 17 00:00:00 2001 From: Andrew Lekar Date: Fri, 27 Mar 2020 13:43:24 +0000 Subject: [PATCH 03/14] Add configure without pkg-config --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index abb576777f1f4..fe0b3e4070e89 100644 --- a/configure.ac +++ b/configure.ac @@ -1295,6 +1295,7 @@ else AC_CHECK_LIB([crypto],[main],[GRPC_LIBS+=" -lcrypto"],AC_MSG_ERROR(crypto missing)) AC_CHECK_LIB([protobuf],[main],[GRPC_LIBS+=" -lprotobuf"],AC_MSG_ERROR(protobuf missing)) AC_CHECK_LIB([address_sorting],[main],[GRPC_LIBS+=" -laddress_sorting"],AC_MSG_ERROR(protobuf missing)) + AC_CHECK_LIB([altintegration],[main],[ALT_INT_LIBS+=" -laltintegration"],AC_MSG_ERROR(altintegration missing)) if test x$use_tests != xno; then AC_CHECK_HEADER([gmock/gmock.h],,AC_MSG_ERROR(libgmock headers missing)) From 7b9e913345139a101e7376739e43aecac9511801 Mon Sep 17 00:00:00 2001 From: blackyblack Date: Thu, 2 Apr 2020 16:46:38 +0200 Subject: [PATCH 04/14] Sample alt-integration --- build_msvc/test_bitcoin/test_bitcoin.vcxproj | 6 ++++++ src/test/addrman_tests.cpp | 20 ++++++++++++++++++++ src/test/cuckoocache_tests.cpp | 2 ++ 3 files changed, 28 insertions(+) diff --git a/build_msvc/test_bitcoin/test_bitcoin.vcxproj b/build_msvc/test_bitcoin/test_bitcoin.vcxproj index 10fd73e143993..bc12970bac519 100644 --- a/build_msvc/test_bitcoin/test_bitcoin.vcxproj +++ b/build_msvc/test_bitcoin/test_bitcoin.vcxproj @@ -23,6 +23,12 @@ + + F:\programming\VeriBlock\alt-integration-cpp\include;%(AdditionalIncludeDirectories) + + + F:\programming\VeriBlock\alt-integration-cpp\build\lib\Debug\altintegration.lib;%(AdditionalDependencies) + diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 55a5bcecd4a52..412e19325384a 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include class CAddrManTest : public CAddrMan { @@ -86,6 +89,11 @@ static CService ResolveService(std::string ip, int port = 0) BOOST_FIXTURE_TEST_SUITE(addrman_tests, BasicTestingSetup) +static auto defaultPrivateKeyVbk = + "303e020100301006072a8648ce3d020106052b8104000a0427302502010104203abf83fa470423d4788a760ef6b7aae1dacf98784b0646057a0adca24e522acb"; + +static std::string defaultMsg = "Hello world"; + BOOST_AUTO_TEST_CASE(addrman_simple) { CAddrManTest addrman; @@ -95,6 +103,18 @@ BOOST_AUTO_TEST_CASE(addrman_simple) altintegration::ArithUint256 abc = altintegration::ArithUint256(100); BOOST_CHECK_EQUAL(abc.getLow64(), 100); + uint256 hash{}; + std::vector sig{}; + CKey mykey{}; + bool ret = mykey.Sign(hash, sig, false, 0); + (void)ret; + + auto decodedKey = ParseHex(defaultPrivateKeyVbk); + auto privateKey = altintegration::privateKeyFromVbk(decodedKey); + auto signature = altintegration::veriBlockSign(defaultMsg, privateKey); + auto signatureEncodedHex = altintegration::HexStr(signature); + BOOST_CHECK(signatureEncodedHex.size() > 0); + // Test: Does Addrman respond correctly when empty. BOOST_CHECK_EQUAL(addrman.size(), 0U); CAddrInfo addr_null = addrman.Select(); diff --git a/src/test/cuckoocache_tests.cpp b/src/test/cuckoocache_tests.cpp index 119d4b3295331..a3ad40ad7c934 100644 --- a/src/test/cuckoocache_tests.cpp +++ b/src/test/cuckoocache_tests.cpp @@ -1,6 +1,8 @@ // Copyright (c) 2012-2019 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include + #include #include #include