Skip to content

Initial start of unit tests for pyth-client-py #3

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

Merged
merged 16 commits into from
Nov 16, 2021
Merged

Initial start of unit tests for pyth-client-py #3

merged 16 commits into from
Nov 16, 2021

Conversation

SEJeff
Copy link
Contributor

@SEJeff SEJeff commented Nov 8, 2021

It is time to start writing some tests for the client. This is a start which will add tests mostly for the deserialise/update_from() methods for each major class in pythclient/pythaccounts.py one at a time. The goal is 100% test coverage of the binary parsing.

  • PythPriceInfo
  • PythPriceComponent
  • Parsing of the header
  • PythPriceAccount.update_from() - version 2 only, version 1 is a less important TODO.
  • PythProductAccount.update_from()
  • PythMappingAccount

Also added PythPriceAccount.min_publishers since that is now in the most recent oracle.

@SEJeff SEJeff requested a review from cctdaniel November 8, 2021 16:01
Copy link
Contributor

@cctdaniel cctdaniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a couple of comments regarding standardization

Jeff Schroeder added 15 commits November 15, 2021 12:18
Make the output a bit nicer
The rest will come once I've mocked out more of the SolanaClient bits.
This prevents SolanaClient from actually reaching out to any solana rpc
nodes to keep things nice and hermetic for unit testing.
So multiple test files can use it.
The V1 parsing isn't as important and we might remove it in the future.
* Make a `price_account` fixture
* Rename test_price_account() --> test_price_account_update_from()
* Split out tests for aggregate confidence_interval and aggregate price
* Move an assertion for the min_publishers to the end

Thanks @cctdaniel
This makes the code easier to read and makes the comparison less janky.

* Updating PythPriceInfo to use datclass and flake8 updates
* Updating PythPriceComponent to use a datclass
* Updating PythPriceAccount tests to use dataclass
* Update the binary bits to use base64 encoded bytes for brevity

Nice review suggestion from @tony-ricciardi. Not yet using dataclass
with PythProductAccount as there is some magic with the _prices attribute
and the properties without full coverage yet. The tests were janky and I'll
figure it out later when adding coverage for the various update bits.
@SEJeff SEJeff merged commit 6ae1eff into pyth-network:main Nov 16, 2021
@SEJeff SEJeff deleted the start-of-unit-tests branch November 16, 2021 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants