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. fanquake added the label Tests on Jan 4, 2019
  4. fanquake added the label Refactoring on Jan 4, 2019
  5. 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.

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

    utACK 6b25f29a91867e1cd081777bc9fb6338f0c0e739

  7. 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).

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

  11. domob1812 deleted the branch on Jan 5, 2019
  12. deadalnix referenced this in commit 6e8a49671a on Nov 2, 2020
  13. PastaPastaPasta referenced this in commit 330f293e96 on Jun 26, 2021
  14. PastaPastaPasta referenced this in commit 5d36cdfb5a on Jun 28, 2021
  15. DrahtBot 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-04-21 18:15 UTC

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