Skip to content

refactor: wallet_importdescriptors to separate run_test() contents into specific functions - #36402

Open
nebula-21 wants to merge 1 commit into
bitcoin:masterfrom
nebula-21:refactor-wallet-importdescriptors-test
Open

nebula-21 wants to merge 1 commit into
bitcoin:masterfrom
nebula-21:refactor-wallet-importdescriptors-test

Conversation

@nebula-21

Copy link
Copy Markdown
Contributor

The motivation behind this PR came when reviewing a PR related with wallet_importdescriptors and I noticed that the run_test() function was more than 800 lines of code long, and looked messy and confusing, specially for someone not familiar with that test suite.
I believe refactoring the contents inside run_test() and separating it into specific functions would make the test easier to understand and to add new future test cases.

To review this PR, I recommend using the following command to easily see that the changes are only code movement and function organization:

git show --color-moved=dimmed-zebra

Suggestions about the new functions, organization, or their order are more than welcome. The approach I took is the one I felt would provide a good balance between keeping the code clean and making the changes as easy as possible to review.

If reviewers would prefer to split this into multiple commits, I'm also happy to do so.

@DrahtBot

DrahtBot commented Oct 1, 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 polespinasa
Concept ACK achow101

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:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #36648 (descriptor, rpc, wallet: do not echo key material in error messages by fametrano)
  • #36257 (qa: assert_equal -> assert_true/assert_false by hodlinator)
  • #36005 (rpc, descriptor: warn when multipath expansion clones single-path key expressions by pythcoiner)
  • #31668 (Added rescan option for import descriptors by saikiran57)

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.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • test/functional/wallet_importdescriptors.py: we can use import and use multisig → we can import and use multisig [the original phrasing is grammatically broken]

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • test/functional/wallet_importdescriptors.py: multi_priv_big.sendtoaddress(w0.getnewaddress(), 10, "", "", True)

2026-11-06 20:28:24

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

Approach aCK

@polespinasa

Copy link
Copy Markdown
Member

Concept ACK

There are some unnecessary new lines added and removed that add noise to the color-dimmed filter :)

@nebula-21

Copy link
Copy Markdown
Contributor Author

Concept ACK

There are some unnecessary new lines added and removed that add noise to the color-dimmed filter :)

I've tried to avoid them as much as possible, but some of them are necessary to re-arrange into new functions keeping the separations of the original tests intact.

@nebula-21
nebula-21 force-pushed the refactor-wallet-importdescriptors-test branch from 03d3853 to e465928 Compare October 9, 2026 12:19
@nebula-21

Copy link
Copy Markdown
Contributor Author

Rebased on master

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

I think this looks pretty good

@nebula-21
nebula-21 force-pushed the refactor-wallet-importdescriptors-test branch 2 times, most recently from 956ea6d to f614cc3 Compare November 3, 2026 12:28
@achow101

achow101 commented Nov 4, 2026

Copy link
Copy Markdown
Member

Concept ACK

@nebula-21
nebula-21 force-pushed the refactor-wallet-importdescriptors-test branch from f614cc3 to 1dbe686 Compare November 6, 2026 20:27
@nebula-21

Copy link
Copy Markdown
Contributor Author

1dbe686 addressed ralph's suggestion for test_next_index (line 938) to issue indices 0-4 from a different origin descriptor over the same xpub, to still test returning already handed-out scripts as it did before the refactor

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

ACK 1dbe686

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants