dtr-org / unit-e

A digital currency for a new era of decentralized trust
https://unit-e.io
MIT License
45 stars 15 forks source link

Use fixture templates to allow running same tests on different implementations #1080

Closed scravy closed 5 years ago

scravy commented 5 years ago

Currently we are using the "old" bitcoin validation functions, wrapped in the LegacyValidationInterface, as introduced when finally removing Proof-of-Work in https://github.com/dtr-org/unit-e/pull/929. In that pull request we hid the existing validation functions behind an interface so we could swap out the legacy function against the new ones from staking::BlockValidator - featuring the same interface.

Ultimately we want to use the new staking::BlockValidator which is not in use currently. In order to verify that a second implementation of the LegacyValidationInterface which will delegate to staking::BlockValidator does the same validations as the existing functions it would be nice to have a way of running the same unit test suite against different instances of it.

This pull request uses BOOST_AUTO_TEST_CASE_TEMPLATE to achieve exactly that. It is extracted from https://github.com/dtr-org/unit-e/pull/939.

BOOST_AUTO_TEST_CASE_TEMPLATE will allow to check both implementations of LegacyValidationInterface (introduced in #929) to do the right thing. This way the same test tests the two, since they are providing the same interface.

The new implementation of LegacyValidationInterface will land in a separate pull request. Thus the tests currently only operate on one fixture. One can add arbitrary number of Fixtures to the TestFixtures type which is a boost mpl list.

Signed-off-by: Julian Fleischer julian@thirdhash.com