I've been researching mutation testing and how we could use it here since we already have other automated tests. So, I created a Python script to mutate our cpp files. I created these scripts focused on mutating Bitcoin Core, this is not a general cpp one, so it mutates specific Core stuff like CAmount{} and other ones.
In test/mutation/consts.py you can find the operators and you can set what files you'd like to mutate:
FILES = [
"src/wallet/coinselection.cpp",
# "src/wallet/spend.cpp",
# "src/net.cpp",
# "src/wallet/feebumper.cpp",
# "src/script/interpreter.cpp"
]
This script mutates some consts by incresing/decreasing their value, e.g:
from:
const CAmount fee = 100;
to:
const CAmount fee = 75;
or
const CAmount fee = 130;
All the mutators are saved in test/mutation/mutators, it generates one file per mutator.
Feel free to suggest anything, NACKs are welcome, I opened this PR because I use it a lot and I think it might be useful here.