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.