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:
cargo run -p apibara-cli -- test examples/postgres/starknet_to_postgres.js.
Open snapshots/starknet_to_postgres.json and check the testOptions section.
Update that value to the desired number of decimals.
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:cargo run -p apibara-cli -- test examples/postgres/starknet_to_postgres.js
.snapshots/starknet_to_postgres.json
and check thetestOptions
section.