test: use MiniWallet for p2p_segwit.py #24896

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202204-test-run_p2p_segwit_without_wallet changing 1 files +8 −17
  1. theStack commented at 11:37 pm on April 16, 2022: member

    This PR enables one more of the non-wallet functional tests (p2p_segwit.py) to be run even with the Bitcoin Code wallet by using the MiniWallet instead, as proposed in #20078.

    This change only affects the subtest test_superfluous_witness. Note that instead of creating a raw transaction first and then signing it, we go the other direction here: MiniWallet creates a transaction spending a segwit v1 output (i.e. including a witness), then we turn it into a raw transaction by dropping the witness. Therefore, the debug log asserts are swapped.

  2. theStack force-pushed on Apr 16, 2022
  3. DrahtBot added the label Tests on Apr 17, 2022
  4. in test/functional/p2p_segwit.py:2002 in 3cd8868543 outdated
    2003-        unspent = next(u for u in self.nodes[0].listunspent() if u['spendable'] and u['address'].startswith('bcrt'))
    2004-
    2005-        raw = self.nodes[0].createrawtransaction([{"txid": unspent['txid'], "vout": unspent['vout']}], {self.nodes[0].getnewaddress(): 1})
    2006-        tx = tx_from_hex(raw)
    2007+        wallet = MiniWallet(self.nodes[0])
    2008+        self.generate(wallet, COINBASE_MATURITY + 1)
    


    MarcoFalke commented at 7:54 am on April 17, 2022:

    nit: This can be skipped if you mine the 99 first blocks with miniwallet instead.

    0        self.generate(self.nodes[0], 99)  # let the block mature
    

    theStack commented at 4:48 pm on April 17, 2022:
    Thanks, done. The MiniWallet instance is now also created in run_test before any sub-tests are executed, which makes sense. As potential follow-up idea, I guess there are also some refactoring possibilities to use MiniWallet rather than manually crafting CTransaction instances in other sub-tests accessing self.utxo (didn’t check in detail yet though).
  5. MarcoFalke approved
  6. MarcoFalke commented at 7:55 am on April 17, 2022: member
    LGTM. Let me know if you want to address the nit or not
  7. brunoerg approved
  8. brunoerg commented at 11:24 am on April 17, 2022: member
    crACK 3cd886854344726248c9a89cf18da3b2cbabdaba
  9. test: use MiniWallet for p2p_segwit.py
    This change only affects the subtest `test_superfluous_witness`.
    
    Note that instead of creating a raw transaction first and then
    signing it, we go the other direction here: MiniWallet creates a
    transaction spending a segwit v1 output (i.e. including a witness),
    then we turn it into a raw transaction by dropping the witness.
    Therefore, the debug log asserts are swapped.
    917a89a814
  10. theStack force-pushed on Apr 17, 2022
  11. MarcoFalke approved
  12. MarcoFalke merged this on Apr 19, 2022
  13. MarcoFalke closed this on Apr 19, 2022

  14. theStack deleted the branch on Apr 19, 2022
  15. sidhujag referenced this in commit fc88e43cc9 on Apr 19, 2022
  16. DrahtBot locked this on Apr 19, 2023

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-12-23 09:12 UTC

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