apibara / dna

Apibara is the fastest platform to build production-grade indexers that connect onchain data to web2 services.
https://www.apibara.com/
Apache License 2.0
166 stars 26 forks source link

cli: control fp precision in tests #366

Closed fracek closed 1 month ago

fracek commented 1 month ago

Summary

One obstacle to the adoption of the apibara test command was that floating point numbers were compared using strict equality. This resulted in a lot of false positives.

We add a new option to snapshots to control the floating point precision (specifying the number of decimals to compare) used for equality comparison.

After generating the snapshot, users can edit it to change the testOptions.floatingPointDecimals option to the required precision.

Testing strategy

You can test by running the apibara test command on one of the example indexers: