tests: Use std::vector API for construction of test data #15099

pull domob1812 wants to merge 1 commits into bitcoin:master from domob1812:p2sh-test-refactor changing 1 files +16 −8
  1. domob1812 commented at 9:06 AM on January 4, 2019: contributor

    For constructing test scripts, use std::vector and, in particular, std::vector::insert to insert 20 zero bytes rather than listing the full array of bytes explicitly. This makes the code easier to read and makes it immediately obvious what the structure of the data is, without having to count the zeros to understand it.

    Of course, that is a matter of taste - so if you disagree that the change makes the code easier to read, let me know.

    This has been split out of #14752.

  2. Use std::vector API for construction of test data.
    For constructing test scripts, use std::vector and, in particular,
    std::vector::insert to insert 20 zero bytes rather than listing the full
    array of bytes explicitly.  This makes the code easier to read and makes
    it immediately obvious what the structure of the data is, without having
    to count the zeros to understand it.
    6b25f29a91
  3. domob1812 cross-referenced this on Jan 4, 2019 from issue tests: Unit tests for IsPayToWitnessScriptHash and IsWitnessProgram by domob1812
  4. fanquake added the label Tests on Jan 4, 2019
  5. fanquake added the label Refactoring on Jan 4, 2019
  6. laanwj commented at 9:40 AM on January 4, 2019: member

    utACK

    I don't think this is a very pressing change but OTOH I think it's marginally easier to read, and harder to make mistakes with—e.g. with a span of 0, it's easy to accidentally insert one too many or too few.

  7. MarcoFalke commented at 10:47 AM on January 4, 2019: member

    utACK 6b25f29a91867e1cd081777bc9fb6338f0c0e739

  8. promag commented at 11:24 PM on January 4, 2019: member

    utACK 6b25f29. Does it make sense to add the following?

    CScript(const std::vector<unsigned char>& v) : CScript(v.begin(), v.end()) {}
    

    which would simplify this change (and maybe in other places).

  9. MarcoFalke referenced this in commit fe5a70b9fe on Jan 4, 2019
  10. MarcoFalke merged this on Jan 4, 2019
  11. MarcoFalke closed this on Jan 4, 2019

  12. domob1812 deleted the branch on Jan 5, 2019
  13. deadalnix referenced this in commit 6e8a49671a on Nov 2, 2020
  14. PastaPastaPasta referenced this in commit 330f293e96 on Jun 26, 2021
  15. PastaPastaPasta referenced this in commit 5d36cdfb5a on Jun 28, 2021
  16. barton2526 cross-referenced this on Oct 8, 2021 from issue test: Update script_p2sh_tests from upstream by barton2526
  17. bitcoin locked this on Dec 16, 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: 2026-05-20 06:54 UTC