Skip to content

test: make script_combineSigs and spends_witness_prog cases independent - #36794

Open
alexanderwiederin wants to merge 2 commits into
bitcoin:masterfrom
alexanderwiederin:script_test_split
Open

alexanderwiederin wants to merge 2 commits into
bitcoin:masterfrom
alexanderwiederin:script_test_split

Conversation

@alexanderwiederin

Copy link
Copy Markdown
Contributor

Part of #36692: remove test state that is shared and modified across cases.

  • script_combineSigs: The P2PKH, P2SH and multisig cases shared one funding transaction, whose scriptPubkey was modified between them, and one keystore. Each case is now its own test with its own keys, keystore and funding transaction.
  • spends_witness_prog: every output type reused the same transactions and coins view. The P2SH-wrapped cases relied on the scriptPubkey left by the previous case and had to clear the scriptSig they set. Each check now builds fresh state, and the scripts are named.

The checks are unchanged.

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

DrahtBot commented Nov 6, 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 yuvicc, janb84

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:

  • #36122 (BIP460: CISA for Taproot key path spends by fjahr)
  • #35733 (sign: Remove FillableSigningProvider by achow101)

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.

@alexanderwiederin
alexanderwiederin marked this pull request as draft November 6, 2026 19:18
@alexanderwiederin
alexanderwiederin force-pushed the script_test_split branch 2 times, most recently from 9b8e6b4 to 85497da Compare November 6, 2026 19:56
@yuvicc

yuvicc commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Concept ACK

@yuvicc yuvicc 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.

crACK 1f9802c

I went through both diffs and the checks match.

Left some non-blocking nits.

Comment thread src/test/script_tests.cpp Resolved
Comment thread src/test/script_tests.cpp Resolved
Comment thread src/test/script_tests.cpp Resolved
The P2PKH, P2SH and multisig cases shared one funding transaction, whose
scriptPubKey was modified between them, and one keystore.

Give each case its own test with its own keys, keystore and const
funding transaction. The checks are unchanged.
@yuvicc

yuvicc commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

ACK 26d2f76

@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 26d2f76

It matches the recent "declarative tests" series :)
Each new test case makes the same assertions as the old code, in the same order, with the same expected values.

Comment thread src/test/transaction_tests.cpp Resolved
Comment thread src/test/script_tests.cpp
combined = CombineSignatures(txFrom.vout[0], txTo, empty, scriptSig);
BOOST_CHECK_EQUAL(combined.scriptSig, scriptSig.scriptSig);
SignatureData scriptSigCopy = scriptSig;
// Signing again will give a different, valid signature:

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.

Note: Old problem but this comment is not correct. Easy to check;
BOOST_CHECK_EQUAL(scriptSig.scriptSig, scriptSigCopy.scriptSig);

Not something I suggest to fix in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks - good catch!

The test reused funding transaction, spending transaction and coins view
for every output type, modifying them between checks. The P2SH-wrapped
cases relied on the scriptPubkey left by the previous case, and each one
had to clear the scriptSig it set.

Give each output type its own test case with its own key and scripts,
and check each spend with a helper that builds fresh transactions and a
fresh coins view. The checks are unchanged.
@yuvicc

yuvicc commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

re-ACK 7358d35

Show signature ```bash -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512

re-ACK 7358d35
-----BEGIN PGP SIGNATURE-----

iJEEARYKADkWIQRxIqfV4fHauqeDZkLHO83HCSJ4EQUCavPzBhsUgAAAAAAEAA5t
YW51MiwyLjUrMS4xMiwwLDMACgkQxzvNxwkieBH7MAEAg/CcUjT+GTywtxOE8MZr
AdPwyBUzBEIgOPLZyTBoyQcBAOuCEIcJxmBDTJyWV4PRFnqqI4gOnipGrgT7p+qt
E8oH
=53QK
-----END PGP SIGNATURE-----

</details>

@DrahtBot
DrahtBot requested a review from janb84 November 11, 2026 04:47

@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 7358d35

Thanks for taking my suggestion. LGTM !

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.

4 participants