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

test,feat!: (1) New events and tx resp abstractions. (2) Cater tests to devnet #180

Merged
merged 21 commits into from
Dec 9, 2022

Conversation

Unique-Divine
Copy link
Member

@Unique-Divine Unique-Divine commented Dec 7, 2022

Summary

  • Uses pytest-order to control the order of tests and break them into more manageable chunks
  • refactor(network.py): Changes the insecure status to be loaded dynamically with an is_insecure property
  • test: adds an env var, "USE_LOCALNET" that lets you test against custom networks. Tests default to using the "devnet".
  • test: favors using sdk_val or sdk_oracle over sdk_agent so that less transfers are required.
  • test: Implements a tests.raises function that has better UX than pytest.raises. See perp_test.py or dex_test.py for some examples.

Tests on the dex and perp module are more forgiving in that they don't depend as much on the initial state.

  1. For example, if you run perp_test.py and the position is underwater, open, add, remove, and close transactions should fail, but only in a very specific way. The query should happy path, while open, add, and remove should fail with "bad debt", and close should fail with an "underwater" error.
  2. Another example, when you run dex_test.py, create pool should only happy path the first time. After that, it should give the "same denom" error. But if you create a pool without enough NIBI in your wallet, the create pool test will pass, but all of the other dex tests will fail, and the error messages will be super informative for debugging.

Other notable changes

  • test(event): test parse attributes
  • feat(pytypes)!: TxResp for easily handling transaction responses - refactor: move types to pytypes. export all types from nibiru.ptypes module.
  • fix: Find a gas config that works better for the E2E tests.
  • test: use ueth instead of unibi for pricefeed_test.
  • dependencies: Bump package dev version

Pro-tip - Favor BaseException

It's better to use BaseException than Exception if you're looking for a generic error message type because there are several built-in errors that don't count as Exception, but everything counts as BaseException.

>>> issubclass(BaseException, BaseException)
True
>>> issubclass(BaseException, Exception)
False
>>> issubclass(KeyboardInterrupt, BaseException)
True
>>> issubclass(KeyboardInterrupt, Exception)
False
>>> issubclass(SystemExit, BaseException)
True
>>> issubclass(SystemExit, Exception)
False

matthiasmatt and others added 20 commits December 5, 2022 19:41
- refactor: move types to pytypes. export all types from nibiru.ptypes module.
- fix: Find a gas config that works better for the E2E tests.
- fix: Get most of the perp tests passing again.
… TM endpoint. Add docstring for 'Network' class.
- (2) test(dex): Remove uusdc as it does not exist on chain
@Unique-Divine Unique-Divine marked this pull request as ready for review December 9, 2022 07:42
@Unique-Divine Unique-Divine added type: enhancement New feature or request type: test Adding missing tests or improve existing tests epic Large task that is a parent to several issues/tasks labels Dec 9, 2022
@Unique-Divine Unique-Divine changed the title test,refactor!: (1) New events and tx resp abstractions. (2) Cater tests to devnet test,feat!: (1) New events and tx resp abstractions. (2) Cater tests to devnet Dec 9, 2022
Comment on lines +124 to +126
output: dict = MessageToDict(proto_output).get("pools")
if output is None:
output = {}
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes a KeyError that gets raised if no pools come back in the query

tests/perp_test.py Show resolved Hide resolved
tests/perp_test.py Outdated Show resolved Hide resolved
tests/dex_test.py Show resolved Hide resolved
@Unique-Divine Unique-Divine merged commit 27ff098 into master Dec 9, 2022
@Unique-Divine Unique-Divine deleted the realu/tx-resp-abstraction branch December 9, 2022 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Large task that is a parent to several issues/tasks type: enhancement New feature or request type: test Adding missing tests or improve existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants