Skip to content

test: split test_IsStandard into independent test cases - #36831

Open
yuvicc wants to merge 4 commits into
bitcoin:masterfrom
yuvicc:test-split-isstandard
Open

yuvicc wants to merge 4 commits into
bitcoin:masterfrom
yuvicc:test-split-isstandard

Conversation

@yuvicc

@yuvicc yuvicc commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Part of #36692: This splits it into one test case per policy rule, each building its own transaction.

The first commit replaces g_dust and g_bare_multi globals by a StandardPolicy struct, which defaults to the node defaults and is passed to each check, e.g. CheckIsStandard(t, {.max_op_return_relay = 83}), so no case changes policy for another.

Second commit splits test_IsStandard into independent test cases i.e. one test case per policy rule. Each starts from its own standard transaction built by a new MakeTx helper. Since transactions are no longer carried over between checks, some values that are irrelevant to the rule under test differ from before.

Third commit builds IsStandard test transactions declaratively. Each check constructs its transaction in one expression instead of mutating a shared one. CheckDustThreshold helper also deduplicates repeated "not dust at the threshold, dust one satoshi below" from test cases.

@DrahtBot DrahtBot added the Tests label Nov 10, 2026
@DrahtBot

DrahtBot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK maflcko, janb84
Stale ACK alexanderwiederin

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36946 (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)
  • #35733 (sign: Remove FillableSigningProvider by achow101)
  • #34520 (refactor: Add [[nodiscard]] to functions returning bool+mutable ref by maflcko)

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.

@yuvicc
yuvicc marked this pull request as ready for review November 11, 2026 04:31

@janb84 janb84 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

Looks good, in my review I ran across a few questions / NITS

Comment thread src/test/transaction_tests.cpp Resolved
Comment thread src/test/transaction_tests.cpp Resolved
Comment thread src/test/transaction_tests.cpp Resolved
@yuvicc
yuvicc force-pushed the test-split-isstandard branch 2 times, most recently from 15221ae to 20fecda Compare November 13, 2026 05:42
@yuvicc

yuvicc commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Addressed nits from @janb84:

  • Renamed nDustThreshold to dust_threshold comment
  • Renamed test_IsStandard_dust to test_IsStandard_dust_limit
  • op_return_80 → op_return_83
  • op_return_40 → op_return_42

@janb84 janb84 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 20fecda

Thanks for taking my suggestions!

I think it's ok but depending if you are nitpicking or how you are reading the commit message it can be misunderstood what is ment by "no check is added" while adding BOOST_CHECK_EQUAL(42, op_return_42.size()) and a second BOOST_CHECK_EQUAL(83, ...) .
"no policy check" would remove the possible mis-understanding. Just to highlight it but i'm fine with it.

@maflcko

maflcko commented Nov 13, 2026

Copy link
Copy Markdown
Member

How should this be reviewed? This looks like it is removing 200 lines of test code and adding 200 other lines.

I understand that #36692 can be "fixed" with LLMs and that LLMs can "review" the "fix", but if this isn't trivial for humans to review, then I don't think it is worth it.

If there are 50 pull requests (each for a file), and each takes 10 minutes to review, it will be ~10hours/person if everything goes well. Just raising this to focus on creating pulls that are trivial to review.

I haven't looked closely, but maybe the globals removal like g_dust can be split off into a commit?

@yuvicc
yuvicc force-pushed the test-split-isstandard branch from 20fecda to 4d01b07 Compare November 14, 2026 05:17
@yuvicc

yuvicc commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look.

How should this be reviewed? This looks like it is removing 200 lines of test code and adding 200 other lines.
Just raising this to focus on creating pulls that are trivial to review.

I have split the PR into three commits, which should make it easier to review. The first two commits should be easy and quick. The last one is not a mechanical change, and I am happy to drop it if reviewers feel it is better to keep the PR focused on the changes that are trivial to review.

I haven't looked closely, but maybe the globals removal like g_dust can be split off into a commit?

I've split the globals removal into its own commit. Also, I have added "no policy check" in the commit message.

@janb84 janb84 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re- ACK4d01b07cd5896283571dcc11497b62110f62ba72

changes since last ack; changes separated in several commits.

Although I found it doable to review in one commit I have to confess that the separation makes it easier.

@alexanderwiederin alexanderwiederin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 4d01b07

@maflcko maflcko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting this large 300 line test case into subtest, and also removing the globals, which I found both tedious to read and understand. Now it seems nicer.

Left some nits. Happy to re-ack if you take them.

review ACK 4d01b07 🔄

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK 4d01b07cd5896283571dcc11497b62110f62ba72 🔄
62h5ER0mEksNU/YI3xCWNK43fnKOqeVnyfnUjaswf6LaFQPguNNjP80PbTGV/oQ2Noxk1flMJuXgF/VA8yuOCg==

Comment thread src/test/transaction_tests.cpp Resolved
Comment thread src/test/transaction_tests.cpp Resolved
CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
}

BOOST_AUTO_TEST_CASE(test_IsStandard)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to move this IsStandardTx test suite into its own file, as you are touching all lines of this test anyway. Maybe transaction_standardness_tests.cpp, so that it is separate from let's say tx serialize tests or other tx tests.

The g_dust and g_bare_multi globals are replaced by a StandardPolicy
struct, which defaults to the node defaults and is passed to each
check.

The CheckIsStandard and CheckIsNotStandard lambdas become free
functions, so that they can be shared by the test cases split out in
the next commit.

No policy check is added or removed.
Split the test into one test case per policy rule.

Each case starts from its own standard transaction, built by the new
MakeTx helper, instead of from whatever the previous checks left
behind.

Values irrelevant to the rule under test may differ, since each case
now starts from a fresh transaction.

No policy check is added or removed.
Construct the transaction for each check in one expression, instead of
mutating a shared transaction between checks. The input of every check
is now visible at the call site.

The repeated "not dust at the threshold, dust one satoshi below" pairs
are folded into a CheckDustThreshold helper.

No policy check is added or removed. The size of the 42-byte OP_RETURN
script, previously only implied by the hex literal, is now asserted
alongside the 83-byte one.
Move the IsStandardTx test cases and their helpers out of
transaction_tests.cpp into their own file, so that they are separate
from the serialization and other transaction tests.
@yuvicc
yuvicc force-pushed the test-split-isstandard branch from 4d01b07 to 608b99a Compare November 23, 2026 05:06
@yuvicc

yuvicc commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Addressed the nits:

  • Switched the new doc comments to /// comment
  • Renamed script_pub_key -> output_script comment
  • Moved the IsStandardTx tests into a new transaction_standardness_tests.cpp (move-only commit, review with --color-moved=dimmed-zebra) suggestion

@maflcko

maflcko commented Nov 23, 2026

Copy link
Copy Markdown
Member

review ACK 608b99a 💽

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK 608b99a0d87ca208bd421dbb76b44966f3ea195f 💽
icdy8esC6o8i2qfxyx6PKjPbXBKWZzVRKcnkBil7mPaNj8TDszM8fL/RnHLTRvS6J9Kn2Wym7xw5DYi9/0xVBg==

@janb84 janb84 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re ACK 608b99a

changes since last ACK:

  • small nit changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants