Blockchain-Technology-Lab / consensus-decentralization

Tool that analyzes blockchain decentralization on the consensus layer by looking at the block production distributions of various blockchain systems.
https://blockchain-technology-lab.github.io/consensus-decentralization
MIT License
25 stars 6 forks source link

Make tests self-contained #53

Open LadyChristina opened 1 year ago

LadyChristina commented 1 year ago

Currently some tests share the same setup, e.g. read the same input files, which can potentially cause problems and make maintenance harder. It would be good for every test to be responsible for its input and output. It's probably better to also delete all files associated with a test after it's done.

LadyChristina commented 1 year ago

One issue that arises by not deleting test output files is that in some cases (e.g. mapping) we only go ahead with the process if the output file doesn't already exist. This means that if we change the relevant code between two test runs then the updated code won't be tested because the test output file will already exist.

LadyChristina commented 1 year ago

Another issue is that in the mapping tests we also perform parsing, so the test will fail if there is something wrong with the parser, even if the mapping is fine. I think it's better for the mapping tests to receive the parser output as input directly so that they are independent of the parser's code.

LadyChristina commented 1 year ago

Some useful guidelines for writing Python tests: https://docs.python-guide.org/writing/tests/