[tests] mining functional tests (including regression test for submitblock) #10190

pull jnewbery wants to merge 9 commits into bitcoin:master from jnewbery:mining_functional_test changing 3 files +125 −158
  1. jnewbery commented at 8:52 pm on April 11, 2017: member

    This PR refactors the getblocktemplate_proposals.py functional test into a more general mining test, which covers the submitblock RPC as well as the getblocktemplate propose mode.

    Motivation was to add a regression test for #10146

    This test removes all the manual block/transaction construction from the test case and uses the mininode classes to achieve the same tests. Result is less lines of code, and hopefully clearer and easier for people to extend/maintain since we’re no longer hacking bits in a serialised block. @gmaxwell since he wrote the fix for #10146

    EDIT: there are lots of commits in this PR to aid reviewers. They can be squashed down into larger commits before merging.

  2. fanquake added the label Mining on Apr 12, 2017
  3. fanquake added the label Tests on Apr 12, 2017
  4. in test/functional/mining.py:5 in df93f6cc8d outdated
    0@@ -0,0 +1,125 @@
    1+#!/usr/bin/env python3
    2+# Copyright (c) 2014-2016 The Bitcoin Core developers
    3+# Distributed under the MIT software license, see the accompanying
    4+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
    5+"""Test block proposals with getblocktemplate."""
    


    jimmysong commented at 8:10 pm on April 17, 2017:
    Guessing you’ll want to change this comment.

    jnewbery commented at 8:22 pm on April 18, 2017:
    Yes, thanks.
  5. in test/functional/getblocktemplate_proposals.py:92 in 4687fe6a22 outdated
    94+
    95+        coinbase_tx = create_coinbase(height=int(tmpl["height"]) + 1)
    96+        # sequence numbers must not be max for nLockTime to have effect
    97+        coinbase_tx.vin[0].nSequence = 2 ** 32 - 2
    98+        tmpl['coinbasetxn'] = {'data': coinbase_tx.serialize()}
    99+        txlist = [bytearray(coinbase_tx.serialize())]
    


    jimmysong commented at 6:17 pm on April 18, 2017:
    is tmpl['transactions'] expected to be empty?

    jnewbery commented at 8:25 pm on April 18, 2017:
    yes, I believe so
  6. in test/functional/mining.py:24 in df93f6cc8d outdated
    19+    if rehash:
    20+        block.hashMerkleRoot = block.calc_merkle_root()
    21+    rsp = node.getblocktemplate({'data': b2x(block.serialize()), 'mode': 'proposal'})
    22+    assert_equal(rsp, expect)
    23+
    24+class GetBlockTemplateProposalTest(BitcoinTestFramework):
    


    jimmysong commented at 6:24 pm on April 18, 2017:
    rename the test to MiningTest?

    jnewbery commented at 8:22 pm on April 18, 2017:
    agreed
  7. in test/functional/mining.py:125 in df93f6cc8d outdated
    120+        bad_block = copy.deepcopy(block)
    121+        bad_block.hashPrevBlock = 123
    122+        assert_template(node, bad_block, 'inconclusive-not-best-prevblk')
    123+
    124+if __name__ == '__main__':
    125+    GetBlockTemplateProposalTest().main()
    


    jimmysong commented at 6:25 pm on April 18, 2017:
    MiningTest?

    jnewbery commented at 8:23 pm on April 18, 2017:
    yep
  8. jimmysong commented at 6:33 pm on April 18, 2017: contributor

    utACK df93f6cc8d80e78eb8758a7d6b5148df9bc3afa9

    Gets rid of a lot of duplicate logic. A few nits.

  9. jimmysong approved
  10. jimmysong commented at 8:43 pm on April 18, 2017: contributor
    ACK 8d80db230b3a07680cec1c227ff84dbe0678cf45
  11. jnewbery force-pushed on May 3, 2017
  12. jnewbery commented at 8:30 pm on May 9, 2017: member
    @gmaxwell can I convince you to take a look at this? It adds a regression test for your fix in #10146
  13. gmaxwell commented at 1:10 am on May 26, 2017: contributor
    Concept ACK. I am testing the test.
  14. jnewbery commented at 4:12 pm on June 18, 2017: member

    No great rush for this but it’d be good to get it in soonish. It includes a regression test for #10146, which was backported to 0.14.1. Other benefits:

    • tidies up test code
    • increases coverage of mining RPCs
  15. MarcoFalke added this to the milestone 0.15.0 on Jun 18, 2017
  16. laanwj assigned MarcoFalke on Jun 26, 2017
  17. [tests] Fix import order in getblocktemplate test 32cffe6bef
  18. [tests] Fix flake8 warnings in getblocktemplate tests 0a3a5ff454
  19. [tests] getblocktemplate_proposals.py: add logging 38b38cd2d1
  20. [tests] Don't build the coinbase manually in getblocktemplate test 66c570a38e
  21. [tests] clarify assertions in getblocktemplate test f82c709fbe
  22. [tests] don't build blocks manually in getblocktemplate test 82dc59706e
  23. [tests] run successful test in getblocktemplate first 9bf0d80ab0
  24. [tests] add test for submit block b29dd41f0f
  25. [tests] rename getblocktemplate_proposals.py to mining.py 11ba8e9cdd
  26. jnewbery force-pushed on Jun 27, 2017
  27. jnewbery commented at 3:04 pm on June 27, 2017: member
    rebased
  28. jnewbery renamed this:
    Mining functional tests (including regression test for submitblock)
    [tests] mining functional tests (including regression test for submitblock)
    on Jun 30, 2017
  29. laanwj commented at 1:21 pm on July 11, 2017: member
    utACK 11ba8e9
  30. laanwj merged this on Jul 11, 2017
  31. laanwj closed this on Jul 11, 2017

  32. laanwj referenced this in commit e4f226a133 on Jul 11, 2017
  33. PastaPastaPasta referenced this in commit 37e85d578b on Jul 6, 2019
  34. PastaPastaPasta referenced this in commit daed1764df on Jul 8, 2019
  35. PastaPastaPasta referenced this in commit e9fb5466e3 on Jul 9, 2019
  36. PastaPastaPasta referenced this in commit ac81026d89 on Jul 11, 2019
  37. PastaPastaPasta referenced this in commit 3b71baf7b6 on Jul 13, 2019
  38. PastaPastaPasta referenced this in commit c873c52801 on Jul 17, 2019
  39. PastaPastaPasta referenced this in commit a9f523b059 on Jul 17, 2019
  40. PastaPastaPasta referenced this in commit f1c9b7a893 on Jul 18, 2019
  41. barrystyle referenced this in commit e1a840eca0 on Jan 22, 2020
  42. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me