optakt / flow-dps

Flow Data Provisioning Service
Apache License 2.0
29 stars 13 forks source link

Add tests for the index-based trie loader #490

Closed Maelkum closed 2 years ago

Maelkum commented 2 years ago

Goal of this PR

This PR adds tests for the updated IterateLedger function - testing exclusion of payloads below a certain height.

Checklist

Maelkum commented 2 years ago

@awfm9 I was considering adding tests for service/loader/config similar to service/mapper/config, but since it deals with functions I wasn't sure if I should. Mapper has somewhat nicer config in that it's mainly boolean config options.

Maelkum commented 2 years ago

@awfm9 I was considering adding tests for service/loader/config similar to service/mapper/config, but since it deals with functions I wasn't sure if I should. Mapper has somewhat nicer config in that it's mainly boolean config options.

I started experimenting with this, and it looks like it's officially not supported:

Slice, map, and function values are not comparable.

https://golang.org/ref/spec#Comparison_operators

Interfaces are comparable, so TrieInitializer could be covered, but the ExcludeHeight is implemented by functions, so assert library will not compare them.

Maelkum commented 2 years ago

Since this PR will include also other tests for the loader package, I'll convert it into a draft until they're all complete.

Maelkum commented 2 years ago

I added some more tests for the loader package, both reading from the index and creating/reading from a checkpoint.

With this, test coverage for the loader package is now at ~91%.