> is there already a test which checks that the datadir is created when necessary?
I don’t think so. See `initialize_datadir()` in util.py and the places it’s called. There are various places where the files in the datadir or the datadir itself is removed. See here for example: https://github.com/bitcoin/bitcoin/blob/55c18a45305f9e89a726f8cf82a7b16a2ab7f955/test/functional/feature_blocksdir.py#L22