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

Fix tests for 4.0.3 for build on Linux #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

younicoin
Copy link

Hello! On version 4.0.3 you changed headers of some functions, but left old calls in tests. New headers are:

##in GetBlockSubsidy param Bits was removed :
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams, bool fSuperblockPartOnly = false);

##in CheckProofOfWork new param was added: CBlockHeader
bool CheckProofOfWork(const CBlockHeader& b_h, uint256 hash, unsigned int nBits, const Consensus::Params& params)

#also DEPLOYMENT_DIP0020 changed to DEPLOYMENT_DIP0024

So here it is complete build process with my corrections, where
mk is alias of make
v is alias of vim.

  ##2024-12-17 17:28 there is another release, so install BLOCX again
  #https://github.com/BLOCXTECH/BLOCX/releases
wget https://github.com/BLOCXTECH/BLOCX/archive/refs/tags/v4.0.3.zip
unzip v4.0.3.zip
cd BLOCX-4.0.3
chmod +x autogen.sh
./autogen.sh
./configure --with-incompatible-bdb --with-gui
mk
    CXX      libbitcoin_util_a-chainparamsbase.o
  /bin/bash: line 1: ../share/genbuild.sh: Permission denied
  make[2]: *** [Makefile:19620: obj/build.h] Error 126
  make[2]: Leaving directory '/mnt/blockchains/crypto/networks/blocx/BLOCX-4.0.3/src'
  make[1]: *** [Makefile:17613: all-recursive] Error 1
  make[1]: Leaving directory '/mnt/blockchains/crypto/networks/blocx/BLOCX-4.0.3/src'
  make: *** [Makefile:801: all-recursive] Error 1
  Tue Dec 17 05:39:27 PM MSK 2024
  start date was Tue Dec 17 05:32:48 PM MSK 2024
chmod +x share/genbuild.sh
mk
  In file included from test/block_reward_reallocation_tests.cpp:29:
  ./util/irange.h:43:9: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
     43 |         const pointer operator->() { return &value_; }
        |         ^~~~~
  test/block_reward_reallocation_tests.cpp: In member function ‘void block_reward_reallocation_tests::block_reward_reallocation::test_method()’:
  test/block_reward_reallocation_tests.cpp:288:150: error: invalid initialization of reference of type ‘const Consensus::Params&’ from expression of type ‘int’
    288 |         auto masternode_payment = GetMasternodePayment(::ChainActive().Height(), GetBlockSubsidy(::ChainActive().Tip()->nBits, ::ChainActive().Height(), consensus_params), 2500);
        |                                                                                                                                ~~~~~~~~~~~~~~~~~~~~~~^~
  In file included from ./miner.h:11,
                   from test/block_reward_reallocation_tests.cpp:11:
  ./validation.h:214:63: note: in passing argument 2 of ‘CAmount GetBlockSubsidy(int, const Consensus::Params&, bool)’
    214 | CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams, bool fSuperblockPartOnly = false);
        |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  test/block_reward_reallocation_tests.cpp:299:150: error: invalid initialization of reference of type ‘const Consensus::Params&’ from expression of type ‘int’
    299 |         auto masternode_payment = GetMasternodePayment(::ChainActive().Height(), GetBlockSubsidy(::ChainActive().Tip()->nBits, ::ChainActive().Height(), consensus_params), 2500);
        |                                                                                                                                ~~~~~~~~~~~~~~~~~~~~~~^~
  ./validation.h:214:63: note: in passing argument 2 of ‘CAmount GetBlockSubsidy(int, const Consensus::Params&, bool)’
    214 | CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams, bool fSuperblockPartOnly = false);
        |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  test/block_reward_reallocation_tests.cpp:314:154: error: invalid initialization of reference of type ‘const Consensus::Params&’ from expression of type ‘int’
    314 |             auto masternode_payment = GetMasternodePayment(::ChainActive().Height(), GetBlockSubsidy(::ChainActive().Tip()->nBits, ::ChainActive().Height(), consensus_params), 2500);
        |                                                                                                                                    ~~~~~~~~~~~~~~~~~~~~~~^~

v src/test/block_reward_reallocation_tests.cpp
  GetBlockSubsidy(::ChainActive().Tip()->nBits, ::ChainActive().Height(), consensus_params)

v validation.h
  CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams, bool fSuperblockPartOnly = false);
  CAmount GetMasternodePayment(int nHeight, CAmount blockValue, int nReallocActivationHeight = std::numeric_limits<int>::max() /* not activated */);

  #so, as i see, too many params
v src/test/block_reward_reallocation_tests.cpp
        //auto masternode_payment = GetMasternodePayment(::ChainActive().Height(), GetBlockSubsidy(::ChainActive().Tip()->nBits, ::ChainActive().Height(), consensus_params), 2500);
        auto masternode_payment = GetMasternodePayment(::ChainActive().Height(), GetBlockSubsidy(::ChainActive().Height(), consensus_params), 2500);
mk
  In file included from /usr/include/c++/12/cassert:44,
                   from ./blocxbls/include/blocxbls/hkdf.hpp:25,
                   from ./blocxbls/include/blocxbls/bls.hpp:25:
  ./blocxbls/include/blocxbls/hkdf.hpp: In static member function ‘static void bls::HKDF256::Expand(uint8_t*, size_t, const uint8_t*, const uint8_t*, size_t)’:
  ./blocxbls/include/blocxbls/hkdf.hpp:48:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
     48 |         assert(infoLen >= 0);
        |                ~~~~~~~~^~~~
  test/blockencodings_tests.cpp: In function ‘CBlock blockencodings_tests::BuildBlockTestCase()’:
  test/blockencodings_tests.cpp:47:43: error: invalid initialization of reference of type ‘const CBlockHeader&’ from expression of type ‘uint256’
     47 |     while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce;
        |                              ~~~~~~~~~~~~~^~
  In file included from test/blockencodings_tests.cpp:8:
  ./pow.h:22:43: note: in passing argument 1 of ‘bool CheckProofOfWork(const CBlockHeader&, uint256, unsigned int, const Consensus::Params&)’
     22 | bool CheckProofOfWork(const CBlockHeader& b_h, uint256 hash, unsigned int nBits, const Consensus::Params&);
        |                       ~~~~~~~~~~~~~~~~~~~~^~~

v pow.cpp
  bool CheckProofOfWork(const CBlockHeader& b_h, uint256 hash, unsigned int nBits, const Consensus::Params& params)
v src/test/blockencodings_tests.cpp
    47://while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce;
    while (!CheckProofOfWork(block.GetBlockHeader(), block.nBits, Params().GetConsensus())) ++block.nNonce;
    279: //while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce;
    while (!CheckProofOfWork(block.GetBlockHeader(), block.nBits, Params().GetConsensus())) ++block.nNonce;
mk
  In file included from /usr/include/c++/12/cassert:44,
                   from ./blocxbls/include/blocxbls/hkdf.hpp:25,
                   from ./blocxbls/include/blocxbls/bls.hpp:25:
  ./blocxbls/include/blocxbls/hkdf.hpp: In static member function ‘static void bls::HKDF256::Expand(uint8_t*, size_t, const uint8_t*, const uint8_t*, size_t)’:
  ./blocxbls/include/blocxbls/hkdf.hpp:48:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
     48 |         assert(infoLen >= 0);
        |                ~~~~~~~~^~~~
  test/blockencodings_tests.cpp: In function ‘CBlock blockencodings_tests::BuildBlockTestCase()’:
  test/blockencodings_tests.cpp:48:60: error: could not convert ‘block.CBlock::<anonymous>.CBlockHeader::nBits’ from ‘uint32_t’ {aka ‘unsigned int’} to ‘uint256’
     48 |     while (!CheckProofOfWork(block.GetBlockHeader(), block.nBits, Params().GetConsensus())) ++block.nNonce;
        |                                                      ~~~~~~^~~~~
        |                                                            |
        |                                                            uint32_t {aka unsigned int}
v pow.cpp
  bool CheckProofOfWork(const CBlockHeader& b_h, uint256 hash, unsigned int nBits, const Consensus::Params& params)
v test/blockencodings_tests.cpp
  48://while (!CheckProofOfWork(block.GetBlockHeader(), block.nBits, Params().GetConsensus())) ++block.nNonce;
  while (!CheckProofOfWork(block.GetBlockHeader(), block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce;
  279:while (!CheckProofOfWork(block.GetBlockHeader(), block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce;
mk
  In file included from /usr/include/c++/12/cassert:44,
                   from ./blocxbls/include/blocxbls/hkdf.hpp:25,
                   from ./blocxbls/include/blocxbls/bls.hpp:25:
  ./blocxbls/include/blocxbls/hkdf.hpp: In static member function ‘static void bls::HKDF256::Expand(uint8_t*, size_t, const uint8_t*, const uint8_t*, size_t)’:
  ./blocxbls/include/blocxbls/hkdf.hpp:48:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
     48 |         assert(infoLen >= 0);
        |                ~~~~~~~~^~~~
  test/blockfilter_index_tests.cpp: In member function ‘CBlock blockfilter_index_tests::BuildChainTestingSetup::CreateBlock(const CBlockIndex*, const std::vector<CMutableTransaction>&, const CScript&)’:
  test/blockfilter_index_tests.cpp:86:43: error: invalid initialization of reference of type ‘const CBlockHeader&’ from expression of type ‘uint256’
     86 |     while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
        |                              ~~~~~~~~~~~~~^~
v test/blockfilter_index_tests.cpp
  86://while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
    while (!CheckProofOfWork(block.GetBlockHeader(), block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
mk
  In file included from /usr/include/c++/12/cassert:44,
                   from ./blocxbls/include/blocxbls/hkdf.hpp:25,
                   from ./blocxbls/include/blocxbls/bls.hpp:25:
  ./blocxbls/include/blocxbls/hkdf.hpp: In static member function ‘static void bls::HKDF256::Expand(uint8_t*, size_t, const uint8_t*, const uint8_t*, size_t)’:
  ./blocxbls/include/blocxbls/hkdf.hpp:48:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
     48 |         assert(infoLen >= 0);
        |                ~~~~~~~~^~~~
  test/dynamic_activation_thresholds_tests.cpp: At global scope:
  test/dynamic_activation_thresholds_tests.cpp:22:39: error: ‘DEPLOYMENT_DIP0020’ is not a member of ‘Consensus’; did you mean ‘DEPLOYMENT_DIP0024’?
     22 | const auto deployment_id = Consensus::DEPLOYMENT_DIP0020;
        |                                       ^~~~~~~~~~~~~~~~~~
        |                                       DEPLOYMENT_DIP0024
v test/dynamic_activation_thresholds_tests.cpp
  22://const auto deployment_id = Consensus::DEPLOYMENT_DIP0020;
     const auto deployment_id = Consensus::DEPLOYMENT_DIP0024;
mk
  In file included from /usr/include/c++/12/cassert:44,
                   from ./blocxbls/include/blocxbls/hkdf.hpp:25,
                   from ./blocxbls/include/blocxbls/bls.hpp:25:
  ./blocxbls/include/blocxbls/hkdf.hpp: In static member function ‘static void bls::HKDF256::Expand(uint8_t*, size_t, const uint8_t*, const uint8_t*, size_t)’:
  ./blocxbls/include/blocxbls/hkdf.hpp:48:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
     48 |         assert(infoLen >= 0);
        |                ~~~~~~~~^~~~
  test/miner_tests.cpp: In lambda function:
  test/miner_tests.cpp:257:53: error: invalid initialization of reference of type ‘const CBlockHeader&’ from expression of type ‘uint256’
    257 |             while (!CheckProofOfWork(pblock->GetHash(), pblock->nBits, chainparams.GetConsensus())) {
        |                                      ~~~~~~~~~~~~~~~^~
  In file included from test/miner_tests.cpp:18:
  ./pow.h:22:43: note: in passing argument 1 of ‘bool CheckProofOfWork(const CBlockHeader&, uint256, unsigned int, const Consensus::Params&)’
     22 | bool CheckProofOfWork(const CBlockHeader& b_h, uint256 hash, unsigned int nBits, const Consensus::Params&);
        |                       ~~~~~~~~~~~~~~~~~~~~^~~
  ./consensus/consensus.h: At global scope:
v test/miner_tests.cpp
     257:       //while (!CheckProofOfWork(pblock->GetHash(), pblock->nBits, chainparams.GetConsensus())) {
            while (!CheckProofOfWork(pblock->GetBlockHeader() , pblock->GetHash(), pblock->nBits, chainparams.GetConsensus())) {
mk
  In file included from /usr/include/boost/test/test_tools.hpp:45,
                   from /usr/include/boost/test/unit_test.hpp:18,
                   from test/pow_tests.cpp:10:
  test/pow_tests.cpp: In member function ‘void pow_tests::CheckProofOfWork_test_negative_target::test_method()’:
  test/pow_tests.cpp:188:35: error: invalid initialization of reference of type ‘const CBlockHeader&’ from expression of type ‘uint256’
    188 |     BOOST_CHECK(!CheckProofOfWork(hash, nBits, consensus));
        |                                   ^~~~
v test/pow_tests.cpp
  188://BOOST_CHECK(!CheckProofOfWork(hash, nBits, consensus));
    CBlockHeader blockHeader;
    blockHeader.nTime = 1408732505; // Block #123457
    BOOST_CHECK(!CheckProofOfWork(blockHeader, hash, nBits, consensus));
mk
  In file included from /usr/include/boost/test/test_tools.hpp:45,
                   from /usr/include/boost/test/unit_test.hpp:18,
                   from test/pow_tests.cpp:10:
  test/pow_tests.cpp: In member function ‘void pow_tests::CheckProofOfWork_test_overflow_target::test_method()’:
  test/pow_tests.cpp:199:35: error: invalid initialization of reference of type ‘const CBlockHeader&’ from expression of type ‘uint256’
    199 |     BOOST_CHECK(!CheckProofOfWork(hash, nBits, consensus));
        |                                   ^~~~
v test/pow_tests.cpp
  199://BOOST_CHECK(!CheckProofOfWork(hash, nBits, consensus));
    CBlockHeader blockHeader;
    blockHeader.nTime = 1408732505; // Block #123457
    BOOST_CHECK(!CheckProofOfWork(blockHeader, hash, nBits, consensus));
  #same at 211, 223, 234
mk
  In file included from /usr/include/c++/12/cassert:44,
                   from ./blocxbls/include/blocxbls/hkdf.hpp:25,
                   from ./blocxbls/include/blocxbls/bls.hpp:25:
  ./blocxbls/include/blocxbls/hkdf.hpp: In static member function ‘static void bls::HKDF256::Expand(uint8_t*, size_t, const uint8_t*, const uint8_t*, size_t)’:
  ./blocxbls/include/blocxbls/hkdf.hpp:48:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
     48 |         assert(infoLen >= 0);
        |                ~~~~~~~~^~~~
  test/subsidy_tests.cpp: In member function ‘void subsidy_tests::block_subsidy_test::test_method()’:
  test/subsidy_tests.cpp:25:43: error: invalid initialization of reference of type ‘const Consensus::Params&’ from expression of type ‘int32_t’ {aka ‘int’}
     25 |     nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
        |                                           ^~~~~~~~~~~

v validation.h
  CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams, bool fSuperblockPartOnly = false);
  #so need to edit call params of this function
v test/subsidy_tests.cpp
  25://nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
    nSubsidy = GetBlockSubsidy(nPrevHeight, chainParams->GetConsensus(), false);
  ##same at 32 40 47 53 and so on
mk
  In file included from /usr/include/c++/12/cassert:44,
                   from ./blocxbls/include/blocxbls/hkdf.hpp:25,
                   from ./blocxbls/include/blocxbls/bls.hpp:25:
  ./blocxbls/include/blocxbls/hkdf.hpp: In static member function ‘static void bls::HKDF256::Expand(uint8_t*, size_t, const uint8_t*, const uint8_t*, size_t)’:
  ./blocxbls/include/blocxbls/hkdf.hpp:48:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
     48 |         assert(infoLen >= 0);
        |                ~~~~~~~~^~~~
  test/validation_block_tests.cpp: In member function ‘std::shared_ptr<CBlock> validation_block_tests::MinerTestingSetup::FinalizeBlock(std::shared_ptr<CBlock>)’:
  test/validation_block_tests.cpp:107:45: error: invalid initialization of reference of type ‘const CBlockHeader&’ from expression of type ‘uint256’
    107 |     while (!CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus())) {
        |                              ~~~~~~~~~~~~~~~^~
v test/validation_block_tests.cpp
  107://while (!CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus())) {
    while (!CheckProofOfWork(pblock->GetBlockHeader(), pblock->GetHash(), pblock->nBits, Params().GetConsensus())) {
mk
    CXX      autolykos/src/libblocxconsensus_la-mining.lo
    CXX      autolykos/src/libblocxconsensus_la-Writer.lo
    CXXLD    libblocxconsensus.la
  make[2]: Leaving directory '/mnt/blockchains/crypto/networks/blocx/BLOCX-4.0.3/src'
  make[1]: Leaving directory '/mnt/blockchains/crypto/networks/blocx/BLOCX-4.0.3/src'
  Making all in doc/man
  make[1]: Entering directory '/mnt/blockchains/crypto/networks/blocx/BLOCX-4.0.3/doc/man'
  make[1]: Nothing to be done for 'all'.
  make[1]: Leaving directory '/mnt/blockchains/crypto/networks/blocx/BLOCX-4.0.3/doc/man'
  make[1]: Entering directory '/mnt/blockchains/crypto/networks/blocx/BLOCX-4.0.3'
  make[1]: Nothing to be done for 'all-am'.
  make[1]: Leaving directory '/mnt/blockchains/crypto/networks/blocx/BLOCX-4.0.3'
  Tue Dec 17 08:26:06 PM MSK 2024
  start date was Tue Dec 17 08:20:54 PM MSK 2024
ls -l src/qt/blocx-qt 
  -rwxr-xr-x 1 y y 96414080 Dec 17 20:25 src/qt/blocx-qt

Finally built. And commit fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant