diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2020-11-20 01:01:35 +0100 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-01-31 17:07:46 +0100 |
commit | 63d4ee1968144cc3d115f92baef95785abf813ac (patch) | |
tree | 8a06b6882e8e57e1978b521158c288ff6c8f2dd9 /src/test | |
parent | 4c55f92c7644c267997c7ddab37d195216d6cf39 (diff) |
refactor: iterate arrays via C++11 range-based for loops if idx is not needed
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/miner_tests.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index e967273636..3e90bb054b 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -219,8 +219,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) static_assert(sizeof(blockinfo) / sizeof(*blockinfo) == 110, "Should have 110 blocks to import"); int baseheight = 0; std::vector<CTransactionRef> txFirst; - for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i) - { + for (const auto& bi : blockinfo) { CBlock *pblock = &pblocktemplate->block; // pointer for convenience { LOCK(cs_main); @@ -229,7 +228,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) CMutableTransaction txCoinbase(*pblock->vtx[0]); txCoinbase.nVersion = 1; txCoinbase.vin[0].scriptSig = CScript(); - txCoinbase.vin[0].scriptSig.push_back(blockinfo[i].extranonce); + txCoinbase.vin[0].scriptSig.push_back(bi.extranonce); txCoinbase.vin[0].scriptSig.push_back(::ChainActive().Height()); txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this) txCoinbase.vout[0].scriptPubKey = CScript(); @@ -239,7 +238,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) if (txFirst.size() < 4) txFirst.push_back(pblock->vtx[0]); pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); - pblock->nNonce = blockinfo[i].nonce; + pblock->nNonce = bi.nonce; } std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock); BOOST_CHECK(Assert(m_node.chainman)->ProcessNewBlock(chainparams, shared_pblock, true, nullptr)); |