test: add reason checks for non-standard txs in test_IsStandard #17299

pull theStack wants to merge 1 commits into bitcoin:master from theStack:20191029-test-also_check_reason_for_nonstd_txs changing 1 files +16 −0
  1. theStack commented at 2:10 PM on October 29, 2019: member

    While taking a look at #17272 I noticed that for some reason the unit test test_IsStandard (which was not adapted to the policy change in the referenced PR commits) didn't fail as expected: https://github.com/bitcoin/bitcoin/blob/6a97e8a060f7632bbaee27d3de8035dc6ebe3895/src/test/transaction_tests.cpp#L758-L762 It turned out that IsStandardTx() returned "dust" as rejection reason (instead of the expected "multi-op-return"), leading to the conclusion that https://github.com/bitcoin/bitcoin/pull/17272/commits/5fe6f052bd37a16b2849e05f5cf18d7e194bc705 erroneously performs the IsDust() check also for TX_NULL_DATA transactions. To avoid cases like this in the future, this PR makes the unit test test_IsStandard more strict by also checking for the concrete reason after each occurence of IsStandardTx() returning false.

  2. fanquake added the label Tests on Oct 29, 2019
  3. instagibbs commented at 2:19 PM on October 29, 2019: member

    Concept ACK, but the reason string isn't wiped on success or between checks. It slightly increases review burden, but having IsStandardTx wipe the reason string immediately on entrance is a small reasoning improvement to make sure the string isn't accidentally being kept between calls.

    AFAIK the only "real" usage of it is in src_validation.cpp mempool checks, so should be easy to verify correctness of change.

  4. theStack commented at 2:51 PM on October 29, 2019: member

    @instagibbs: Thanks for the feedback, solid point. I think the easiest way would just be to add a reason.clear() before any occurence of BOOST_CHECK(!IsStandardTx(...));? I don't see that the reason string is wiped out on entrance of IsStandardTx, and I'm hesitating changing policy.cpp for a PR that should merely extend a unit test.

  5. instagibbs commented at 2:59 PM on October 29, 2019: member

    that works too :+1:

  6. test: add reason checks for non-standard txs in test_IsStandard c1c6c410a6
  7. theStack force-pushed on Oct 29, 2019
  8. instagibbs commented at 4:10 PM on October 29, 2019: member

    unrelated appveyor failure

  9. DrahtBot commented at 8:12 PM on October 29, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #17272 ([POLICY] Make multiple OP_RETURNS in a single TX standard by Bushstar)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  10. MarcoFalke referenced this in commit ecad0a8019 on Oct 29, 2019
  11. MarcoFalke merged this on Oct 29, 2019
  12. MarcoFalke closed this on Oct 29, 2019

  13. jasonbcox referenced this in commit 7e2e184aed on Nov 1, 2020
  14. theStack deleted the branch on Dec 1, 2020
  15. 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: 2026-04-14 21:14 UTC

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