test: run mempool_spend_coinbase.py even with wallet disabled #20385

pull mjdietzx wants to merge 1 commits into bitcoin:master from mjdietzx:mempool-tests-to-miniwallet changing 2 files +30 −15
  1. mjdietzx commented at 10:57 pm on November 13, 2020: contributor
    Run the mempool spend coinbase test even when the wallet was not compiled, as proposed in #20078.
  2. fanquake added the label Tests on Nov 13, 2020
  3. in test/functional/mempool_spend_coinbase.py:38 in ca75db9c66 outdated
    40+        # too immature to spend.
    41         b = [self.nodes[0].getblockhash(n) for n in range(101, 103)]
    42         coinbase_txids = [self.nodes[0].getblock(h)['tx'][0] for h in b]
    43-        spends_raw = [create_raw_transaction(self.nodes[0], txid, node0_address, amount=49.99) for txid in coinbase_txids]
    44+        utxo_101 = next(filter(lambda utxo: coinbase_txids[0] == utxo['txid'], wallet._utxos))
    45+        utxo_102 = next(filter(lambda utxo: coinbase_txids[1] == utxo['txid'], wallet._utxos))
    


    MarcoFalke commented at 8:47 am on November 14, 2020:
    _utxos is a private member, so you can’t read it directly. It needs to be accessed via a getter method that also marks the utxo as spent (pops it)

    mjdietzx commented at 3:41 pm on November 14, 2020:
  4. in test/functional/mempool_spend_coinbase.py:45 in ca75db9c66 outdated
    49 
    50         # coinbase at height 102 should be too immature to spend
    51-        assert_raises_rpc_error(-26,"bad-txns-premature-spend-of-coinbase", self.nodes[0].sendrawtransaction, spends_raw[1])
    52+        assert_raises_rpc_error(-26,
    53+                                "bad-txns-premature-spend-of-coinbase",
    54+                                lambda utxo: wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo),
    


    MarcoFalke commented at 8:48 am on November 14, 2020:
    0                                lambda: wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo_102),
    
  5. MarcoFalke approved
  6. MarcoFalke commented at 8:48 am on November 14, 2020: member
    Approach ACK
  7. promag commented at 11:08 am on November 14, 2020: member
    Concept ACK.
  8. in test/functional/test_framework/wallet.py:43 in 650ba88013 outdated
    39@@ -40,9 +40,20 @@ def generate(self, num_blocks):
    40             self._utxos.append({'txid': cb_tx['txid'], 'vout': 0, 'value': cb_tx['vout'][0]['value']})
    41         return blocks
    42 
    43-    def get_utxo(self):
    44-        """Return the last utxo. Can be used to get the change output immediately after a send_self_transfer"""
    45-        return self._utxos.pop()
    46+    def get_utxo(self, txid=''):
    


    MarcoFalke commented at 5:55 pm on November 15, 2020:
    0    def get_utxo(self, *, txid=''):
    

    please force named arguments for this


    mjdietzx commented at 6:22 pm on November 15, 2020:
    done
  9. MarcoFalke approved
  10. MarcoFalke commented at 5:55 pm on November 15, 2020: member
    ACK. Could squash and rebase
  11. mjdietzx force-pushed on Nov 15, 2020
  12. MarcoFalke commented at 7:18 am on November 16, 2020: member
  13. test: run mempool_spend_coinbase.py even with wallet disabled 21f2433601
  14. mjdietzx force-pushed on Nov 16, 2020
  15. mjdietzx commented at 3:58 pm on November 16, 2020: contributor
    I squashed the commits as requested. Going forward with these MiniWallet test “refactors”, should I continue to make one PR per test file rewrite, or should I batch multiple test file rewrites in each PR?
  16. laanwj commented at 3:39 pm on November 19, 2020: member
    ACK 21f24336019d438e225c7bd6653871119883a4ee
  17. laanwj merged this on Nov 19, 2020
  18. laanwj closed this on Nov 19, 2020

  19. MarcoFalke commented at 3:47 pm on November 19, 2020: member

    should I continue to make one PR per test file rewrite, or should I batch multiple test file rewrites in each PR?

    Whatever makes more sense to you

  20. sidhujag referenced this in commit a705f27e5e on Nov 19, 2020
  21. mjdietzx deleted the branch on Nov 19, 2020
  22. deadalnix referenced this in commit 452c543ebc on Jan 11, 2022
  23. 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-17 09:12 UTC

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