test: refactor: introduce `script_util` helper for creating P2PK scripts #23118

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202109-test-add_helper_for_creating_p2pk_scripts changing 7 files +26 −17
  1. theStack commented at 11:55 AM on September 28, 2021: member

    This PR is a follow-up to #22363, which took use of already existing script_util helpers to get rid of manual CScript for the P2{PKH,SH,WPKH,WSH} output types, in order to increase readability and maintainability of the test code. Here the same is done for P2PK scripts by introducing a helper key_to_p2pk_script and using it. Note that the helper only accepts ECDSA pubkeys (i.e. ones with a size of 33 or 65 bytes), hence it can't be used for scripts in the form of [x-only-pubkey, OP_CHECKSIG].

  2. fanquake added the label Tests on Sep 28, 2021
  3. in test/functional/test_framework/script_util.py:38 in b62da41633 outdated
      34 | @@ -25,6 +35,10 @@
      35 |  DUMMY_P2WPKH_SCRIPT = CScript([b'a' * 21])
      36 |  DUMMY_2_P2WPKH_SCRIPT = CScript([b'b' * 21])
      37 |  
      38 | +def key_to_p2pk_script(key, main = False):
    


    MarcoFalke commented at 12:27 PM on September 28, 2021:

    what is main?


    theStack commented at 12:51 PM on September 28, 2021:

    It seems that the main parameter for the script_util helpers is only used in test_framework/address.py where the mainnet boolean parameters is passed-through (for whatever reason...). Since P2PK addresses don't exist, it can be removed. Done.

  4. theStack force-pushed on Sep 28, 2021
  5. DrahtBot commented at 6:13 PM on September 28, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  6. DrahtBot added the label Needs rebase on Sep 29, 2021
  7. test: introduce script_util helper for creating P2PK scripts 429b49378e
  8. theStack force-pushed on Sep 29, 2021
  9. theStack commented at 12:29 PM on September 29, 2021: member

    Rebased on master.

  10. DrahtBot removed the label Needs rebase on Sep 29, 2021
  11. in test/functional/test_framework/script_util.py:15 in 429b49378e
      14 | +    OP_DUP,
      15 |      OP_EQUAL,
      16 |      OP_EQUALVERIFY,
      17 | +    OP_HASH160,
      18 | +    hash160,
      19 | +    sha256,
    


    rajarshimaitra commented at 5:28 PM on October 2, 2021:

    Any specific reason for this refactoring?


    theStack commented at 6:07 PM on October 2, 2021:

    AFAIK, we follow the common practice of keeping the Python imports sorted in lexicographical order. I don't know though if we have written that down anywhere in our docs as guidelines.

  12. brunoerg commented at 8:02 PM on October 4, 2021: member

    Code review ACK 429b49378ee3a3d73abe276cfd176c1ca08bf9b9

  13. laanwj commented at 1:41 PM on October 7, 2021: member

    Code review ACK 429b49378ee3a3d73abe276cfd176c1ca08bf9b9

  14. laanwj merged this on Oct 7, 2021
  15. laanwj closed this on Oct 7, 2021

  16. sidhujag referenced this in commit 29ee69d024 on Oct 7, 2021
  17. MarcoFalke referenced this in commit ab25ef8c7f on Oct 27, 2021
  18. sidhujag referenced this in commit a6072b3e2d on Oct 27, 2021
  19. DrahtBot locked this on Oct 30, 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: 2026-04-14 21:13 UTC

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