NibiruChain / py-sdk

Python-based client for interacting with the Nibiru blockchain
MIT License
19 stars 8 forks source link

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

Closed Unique-Divine closed 1 year ago

Unique-Divine commented 1 year ago

Summary

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

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