EspressoSystems / seahorse

Ledger-agnostic wallet toolkit for the CAP protocol
https://seahorse.docs.espressosys.com
GNU General Public License v3.0
6 stars 1 forks source link

Bfish persistence tests #265

Closed bfish713 closed 2 years ago

bfish713 commented 2 years ago

Started by adding some proptests for the Persitable types then ended up refactoring the persistable types to share more common code.

I didn't want to add specific test implementation which inserts and removes from the persitable type and from the "control" map for al 4 for the Persitable types we had so I implemented a trait for Index type. This let me write just one test and invoke it for all the types I wanted to test. The tests actually found errors in every type for some combinations of input (which proptest reduced perfectly!).

Then I realized that the fixes I was making were duplicated across all the Persitable types (or many of them) and that the trait I used to simplify the test writing could be used to simplify PeristableMap. This led me to using the Index trait to define the behavior of the in memory index and then implement one generic version of PersistableMap. Still each type needs some special handling because they all do insertion and deletion slightly differently.

I think this is a bit better because the special logic to handle the underlying data structure is the only piece that is different for all the persistable types. But I am happy to reconsider if anyone feels this confuses things

Closes: https://github.com/EspressoSystems/seahorse/issues/258