test: mining_getblocktemplate_longpoll.py improvements (use MiniWallet, add logging) #20159

pull theStack wants to merge 3 commits into bitcoin:master from theStack:20201015-test-improve-mining_getblocktemplate_longpoll changing 2 files +19 −71
  1. theStack commented at 9:59 pm on October 15, 2020: member

    This PR enables one more of the non-wallet functional tests (mining_getblocktemplate_longpoll.py) to be run even with the Bitcoin Core wallet disabled by using the new MiniWallet instead, as proposed in #20078. Also adds missing log messages for the subtests.

    This was the only functional test that used the random_transaction helper in test_framework/util.py, hence it is removed, together with other helpers (make_change and gather_inputs) that were again only used by random_transaction.

  2. fanquake added the label Tests on Oct 15, 2020
  3. in test/functional/mining_getblocktemplate_longpoll.py:35 in c63e7c23f5 outdated
    35-        self.skip_if_no_wallet()
    36-
    37     def run_test(self):
    38-        self.log.info("Warning: this test will take about 70 seconds in the best case. Be patient.")
    39-        self.nodes[0].generate(10)
    40+        self.log.info("Warning: this test will take about 70 seconds in the worst case. Be patient.")
    


    MarcoFalke commented at 8:20 am on October 16, 2020:
    why this change?

    theStack commented at 1:23 pm on October 16, 2020:
    Hm, I had a few test runs that finished in ~6 seconds (i.e. introduction of a new transaction would terminate the longpoll immediately, not only in +1minute), but can’t reproduce it anymore. Changed the message back to original.
  4. in test/functional/mining_getblocktemplate_longpoll.py:73 in c63e7c23f5 outdated
    81         thr.start()
    82         # generate a random transaction and submit it
    83         min_relay_fee = self.nodes[0].getnetworkinfo()["relayfee"]
    84-        # min_relay_fee is fee per 1000 bytes, which should be more than enough.
    85-        (txid, txhex, fee) = random_transaction(self.nodes, Decimal("1.1"), min_relay_fee, Decimal("0.001"), 20)
    86+        fee_rate = min_relay_fee + Decimal('0.00000010') * random.randint(0,20)
    


    MarcoFalke commented at 8:23 am on October 16, 2020:
    Can remove unused random_transaction?

    theStack commented at 1:23 pm on October 16, 2020:
    Nice catch, thanks. Added a commit that removes the helpers random_transaction as well as make_change and gather_inputs. The latter two were only used by random_transaction.
  5. in test/functional/mining_getblocktemplate_longpoll.py:66 in c63e7c23f5 outdated
    72         assert not thr.is_alive()
    73 
    74-        # Test 4: test that introducing a new transaction into the mempool will terminate the longpoll
    75+        # Add enough mature utxos to the wallets, so that all txs spend confirmed coins
    76+        self.nodes[0].generate(100)
    77+        self.nodes[1].generate(100)
    


    MarcoFalke commented at 8:23 am on October 16, 2020:
    Why are 100 not enough?

    theStack commented at 1:23 pm on October 16, 2020:
    The intention was to ensure that both nodes have matured utxos, not only the one where we generate the blocks. However, only generating on one node and simply adding a self.sync_blocks() is the better solution. Fixed.
  6. test: use MiniWallet for mining_getblocktemplate_longpoll.py
    This test can now be run even with the Bitcoin Core wallet disabled.
    fddce7e199
  7. theStack force-pushed on Oct 16, 2020
  8. theStack commented at 1:30 pm on October 16, 2020: member
    Updated PR description and force-pushed with the feedback from MarcoFalke taken into account.
  9. test: remove unused helpers random_transaction(), make_change() and gather_inputs() 8ee3536b2b
  10. test: add logging for mining_getblocktemplate_longpoll.py b128b56672
  11. theStack force-pushed on Oct 16, 2020
  12. in test/functional/mining_getblocktemplate_longpoll.py:73 in b128b56672
    80         thr.start()
    81         # generate a random transaction and submit it
    82         min_relay_fee = self.nodes[0].getnetworkinfo()["relayfee"]
    83-        # min_relay_fee is fee per 1000 bytes, which should be more than enough.
    84-        (txid, txhex, fee) = random_transaction(self.nodes, Decimal("1.1"), min_relay_fee, Decimal("0.001"), 20)
    85+        fee_rate = min_relay_fee + Decimal('0.00000010') * random.randint(0,20)
    


    MarcoFalke commented at 3:01 pm on October 16, 2020:

    why does the fee need to be random?

    edit: I guess doesn’t matter. The random import is needed either way


    theStack commented at 6:34 am on October 17, 2020:
    My idea was to keep the test as close as possible to the original and only tackle the parts involving the wallet. Agree though that a fixed fee would work as well.
  13. MarcoFalke approved
  14. MarcoFalke commented at 3:04 pm on October 16, 2020: member
    ACK b128b566725a5037fdaea99940d1b9de5553d198
  15. MarcoFalke merged this on Oct 17, 2020
  16. MarcoFalke closed this on Oct 17, 2020

  17. sidhujag referenced this in commit 6436547758 on Oct 18, 2020
  18. theStack deleted the branch on Dec 1, 2020
  19. deadalnix referenced this in commit 20fda0b66e on Nov 25, 2021
  20. deadalnix referenced this in commit 06e63e8266 on Nov 25, 2021
  21. deadalnix referenced this in commit c78e19afd5 on Nov 25, 2021
  22. DrahtBot locked this on Feb 15, 2022

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-22 18:12 UTC

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