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:
0FILES = [
1 "src/wallet/coinselection.cpp",
2 # "src/wallet/spend.cpp",
3 # "src/net.cpp",
4 # "src/wallet/feebumper.cpp",
5 # "src/script/interpreter.cpp"
6]
This script mutates some consts by incresing/decreasing their value, e.g:
0from:
1const CAmount fee = 100;
2
3
4to:
5const CAmount fee = 75;
6or
7const 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.