I would like to use pdb to debug these tests. Can you provide some guidance on how to do this?
The Bitcoin Core test documentation provides some guidance on attaching a debugger. The functional tests are in Python so you are correctly choosing pdb (rather than gdb, lldb etc) for the job.
A python debugger can be attached to tests at any point. Just add the line:
import pdb; pdb.set_trace()
anywhere in the test. You will then be able to inspect variables, as well as call methods that interact with the bitcoind nodes-under-test.
If you're unsure where is a good point to attach the debugger one good place is after the
random_checksig_style(pubkey) helper is defined in feature_taproot.py. This creates a random CHECKSIG Tapscript that requires only a valid signature on the witness stack.
There is a good video tutorial here from Simeon Franklin on pdb here. There are a large number of pdb commands but the key ones you are most likely to use are:
l(ist) n(ext) c(ontinue) s(tep) r(eturn) b(reak)
As Franklin states:
lshows you where you are in your code.
nsteps to the next line of execution.
cleaves debugger control and executes your code normally.
ssteps into the next line of execution including into function calls if they exist.
rsteps to the end of the currently executing function and
bsets breakpoints. It is important to realize when you are debugging that from the pdb console you can type in any valid Python, changing variables or execution flow of your program and inspecting their values.
p expression for printing an expression value or
pp expression for pretty printing an expression value. And
whatis expression for printing the type of that expression).
More detailed guidance on using pdb is on python.org but the above should be a good introduction.
Remember that you are making edits to Pieter Wuille's
taproot branch locally and will not ever push them to GitHub so you can make whatever changes you want. If you want to revert back to Pieter Wuille's code before you started making edits (and discard all of your edits) you can run
git reset --hard HEAD
and then you should be back to the state before you started experimenting.