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

Uniform Mocks + Blocktool for faking block index #1088

Closed scravy closed 5 years ago

scravy commented 5 years ago

This introduces a unified interface to the mocks in test_unite_mocks.h. So far the mocks were growing uncontrolled and some were more like fakes, stubs, and whatever you want to call these things. Most important however: Some of them were different in spirit from other ones.

Now every Mock (every class ending in *Mock) has a member field for every overloaded function called mock_NameOfThatFunction. That function can be stubbed (using SetStub), the result to be returned can be set (using SetResult), the invocations of a particular method can be checked (CountInnovations) and the number of times a Mock was interacted with (CountInteractions).

In order to streamline the mocks I needed to touch a few tests, most heavily I touched state_db_tests. In order to wrap my head around it I created a blocktool that allows to clearly create chains of block indexes. It is itself unit tested.

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