Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system-test: Use postgres in tests instead of sqlite #836

Closed
slundqui opened this issue Aug 17, 2023 · 0 comments
Closed

system-test: Use postgres in tests instead of sqlite #836

slundqui opened this issue Aug 17, 2023 · 0 comments
Assignees
Labels
bug A bug that is preventing execution

Comments

@slundqui
Copy link
Contributor

Currently, we're using an in memory sqlite database as a dropin for postgres for tests. This works fine most of the time, but there are cases where we'd like to explicitly test postgres functionality. The most glaring issue is that sqlite doesn't have a fixed scale numeric type, and instead uses floats as a drop-in. This means we can't do any precision checks in our tests, and have to do a best effort check against values.

The easiest solution for this is to bring up a postgres container for testing. However, this has a bit of complexity, as our tests need to be able to run in CI.

@dpaiton dpaiton added the bug A bug that is preventing execution label Aug 17, 2023
@slundqui slundqui mentioned this issue Aug 17, 2023
slundqui added a commit that referenced this issue Aug 17, 2023
This PR adds the first system test for elf-simulations.

Major changes:
- It's here! Adds a system test that runs from bots to postgres db on a
local test chain.
- Adding custom bot for test fixtures that cycles through all trades
with known amounts
- Moving `acquire_data.py` to be within chainsync package, and writing
minimal entry point to call
- Breaking change: data capture script renamed from `acquire_data.py` to
`run_chainsync.py`
- Parameterizing `acquire_data.py` to allow for system tests
- Explicitly setting a precision and scale for the Numeric postgres type

Minor changes:
- Adding script for making vscode debugging pytest easier
- Moving helper function `get_web3_and_contracts` from agent0 to ethpy
- Adding `coerce_float` to all postgres getter functions
- Docstrings
- Formatting

Bug fixes:
- Fixed a bug that stores `invTimeStretch` as unscaled values
- Fixed a bug with postgres/python schema typing for `maturityTime`

TODO:
- Do more comparisons in system tests, e.g., how much base for closing
longs, pool info, etc
- Break out system_test
- There are rounding issues with using in-memory sqlite, should use
containerized postgres
   - #836
@slundqui slundqui self-assigned this Aug 21, 2023
slundqui added a commit that referenced this issue Aug 21, 2023
1. Spinning local postgres container for testing
(#836)
2. Using conftest for test fixtures to avoid importing fixture
dependencies in tests
3. Fixing rounding bugs with fixedpoint
(delvtech/fixedpointmath#21)
@dpaiton dpaiton closed this as completed Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug that is preventing execution
Projects
None yet
Development

No branches or pull requests

2 participants