Skip to content

Commit

Permalink
deps,test: 1. Test all successful broadcasts with query tx by hash 2.…
Browse files Browse the repository at this point in the history
… Fix websocket tests 3. Make tests directory pass mypy static type checking (#244)

* deps,test:
1. Test all successful broadcasts with query tx by hash
2. Update to latest protos
3. Fix websocket tests
4. Make tests directory pass mypy static type checking

* try incrementing to reset the poetry cache

* test,fix: improve story test robustness. Revert nibiru_proto + fix docgen.sh

* test: mypy static type checks + GH action to verify for test directory

* ci(lint.yml): use exclude for mypy to only static check the tests
  • Loading branch information
Unique-Divine authored Jul 10, 2023
1 parent 496a424 commit a742a27
Show file tree
Hide file tree
Showing 112 changed files with 1,882 additions and 1,065 deletions.
56 changes: 52 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Linting"
name: "Static"
on:
push:
branches: ["main", "release/*"]
Expand All @@ -20,7 +20,7 @@ jobs:
- name: "Setup Python"
uses: actions/setup-python@v2
with:
python-version: "3.9.13"
python-version: "3.8.16"

- name: "Load pip cache if cache exists"
uses: actions/cache@v2
Expand All @@ -31,7 +31,7 @@ jobs:
- name: "Install and run flake8"
run: |
python -m pip install flake8
flake8 nibiru
flake8 pysdk
flake8 tests
flake8 examples
Expand All @@ -43,7 +43,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-0 # increment to reset cache
key: poetry-2 # increment to reset cache

- name: "Install poetry"
uses: snok/install-poetry@v1
Expand All @@ -52,6 +52,7 @@ jobs:
virtualenvs-in-project: true
installer-parallel: true
version: latest

- name: "Load cached venv"
id: cached-poetry-dependencies
uses: actions/cache@v2
Expand All @@ -67,3 +68,50 @@ jobs:
run: |
poetry run black . --check
poetry run isort .
mypy-static:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: "Check out the repo"
uses: actions/checkout@v3

- name: "Setup Python"
uses: actions/setup-python@v2
with:
python-version: "3.8.16"
# ----------------------------------------------
# Try to load a cached poetry binary
# See https://github.com/snok/install-poetry#caching-the-poetry-installation for the source
# ----------------------------------------------
- name: "Load cached Poetry installation"
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-2 # increment to reset cache

- name: "Install poetry"
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: latest
- name: "Load cached venv"
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: "Install dependencies with poetry (using cache)"
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: "poetry run mypy [files ...] [-h] [-v]"
run: |
poetry run mypy --version
# poetry run mypy tests --exclude 'pysdk/*'
# TODO: epic(pysdk): Add static type checking for pysdk (uncomment above)
# https://github.com/NibiruChain/py-sdk/issues/245
2 changes: 1 addition & 1 deletion .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-0 # increment to reset cache
key: poetry-2 # increment to reset cache

# ----------------------------------------------
# Install & configure poetry
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-0 # increment to reset cache
key: poetry-2 # increment to reset cache

# ----------------------------------------------
# Install ping for early tests
Expand All @@ -77,6 +77,7 @@ jobs:
virtualenvs-in-project: true
installer-parallel: true
version: latest

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-0 # increment to reset cache
key: poetry-2 # increment to reset cache
# ----------------------------------------------
# Install & configure poetry
# ----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
exclude: nibiru/proto/.+

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 22.12.0
hooks:
- id: black
files: \.py$
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- Badges -->

[![Nibiru Test workflow][tests-badge]][tests-workflow]
[![Nibiru examples tests][examples-badge]][tests-example]
[![Examples tests][examples-badge]][tests-example]
[![PyPI Version][pypi-image]][pypi-url]
[![][documentation-image]][documentation-url]
[![][discord-badge]][discord-url]
Expand Down Expand Up @@ -71,7 +71,7 @@ python -m pip install --upgrade pip
### Ex: Creating a wallet and SDK client

```python
from nibiru import wallet
from pysdk import wallet

# Save the mnemonic for later
mnemonic, private_key = wallet.PrivateKey.generate()
Expand Down Expand Up @@ -123,7 +123,7 @@ print(query_resp)

```python
# version 0.16.3
from nibiru import Msg
from pysdk import Msg

tx_resp = sdk.tx.execute_msgs(
Msg.perp.open_position(
Expand Down
4 changes: 0 additions & 4 deletions docgen.sh

This file was deleted.

6 changes: 3 additions & 3 deletions docs-md/crypto/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Module nibiru.crypto
====================
Module pysdk.crypto
===================

Sub-modules
-----------
* nibiru.crypto.ripemd160
* pysdk.crypto.ripemd160
4 changes: 2 additions & 2 deletions docs-md/crypto/ripemd160.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Module nibiru.crypto.ripemd160
==============================
Module pysdk.crypto.ripemd160
=============================
Implementing SHA-256 from scratch was fun, but for RIPEMD160 I am
taking an existing implementation and made some cleanups and api changes.

Expand Down
52 changes: 41 additions & 11 deletions docs-md/event_specs.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Module nibiru.event_specs
=========================
Module pysdk.event_specs
========================

Classes
-------

`EventCaptured(event_type: nibiru.event_specs.EventType, payload: dict)`
: EventCaptured(event_type: nibiru.event_specs.EventType, payload: dict)
`EventCaptured(event_type: pysdk.event_specs.EventType, payload: dict)`
: EventCaptured(event_type: pysdk.event_specs.EventType, payload: dict)

### Class variables

`event_type: nibiru.event_specs.EventType`
`event_type: pysdk.event_specs.EventType`
:

`payload: dict`
Expand All @@ -24,19 +24,46 @@ Classes

### Class variables

`AssetsSwappedEvent`
:

`BurnNIBIEvent`
:

`BurnStableEvent`
:

`BuybackEvent`
:

`Delegate`
:

`EventAggregatePrevote`
:

`EventAggregateVote`
:

`EventDelegateFeederConsent`
:

`FundingRateChangedEvent`
:

`MarkPriceChanged`
`MintNIBIEvent`
:

`OracleUpdatePriceEvent`
`MintStableEvent`
:

`PairPriceUpdatedEvent`
`PoolCreatedEvent`
:

`PoolExitedEvent`
:

`PoolJoinedEvent`
:

`PositionChangedEvent`
Expand All @@ -48,18 +75,21 @@ Classes
`PositionSettledEvent`
:

`Redelegate`
`PriceUpdate`
:

`ReserveSnapshotSavedEvent`
`RecollateralizeEvent`
:

`SwapOnVpoolEvent`
`Redelegate`
:

`Transfer`
:

`TransferEvent`
:

`Unbond`
:

Expand Down
26 changes: 18 additions & 8 deletions docs-md/exceptions.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
Module nibiru.exceptions
========================
Module pysdk.exceptions
=======================

Classes
-------

`ErrorQueryTx(*args, **kwargs)`
: Expresses failure to to query a tx with its hash.

### Ancestors (in MRO)

* pysdk.exceptions.NibiruError
* builtins.Exception
* builtins.BaseException

`NibiruError(*args, **kwargs)`
: Common base class for all non-exit exceptions.

Expand All @@ -14,16 +23,17 @@ Classes

### Descendants

* nibiru.exceptions.QueryError
* nibiru.exceptions.SimulationError
* nibiru.exceptions.TxError
* pysdk.exceptions.ErrorQueryTx
* pysdk.exceptions.QueryError
* pysdk.exceptions.SimulationError
* pysdk.exceptions.TxError

`QueryError(*args, **kwargs)`
: Common base class for all non-exit exceptions.

### Ancestors (in MRO)

* nibiru.exceptions.NibiruError
* pysdk.exceptions.NibiruError
* builtins.Exception
* builtins.BaseException

Expand All @@ -32,7 +42,7 @@ Classes

### Ancestors (in MRO)

* nibiru.exceptions.NibiruError
* pysdk.exceptions.NibiruError
* builtins.Exception
* builtins.BaseException

Expand All @@ -41,6 +51,6 @@ Classes

### Ancestors (in MRO)

* nibiru.exceptions.NibiruError
* pysdk.exceptions.NibiruError
* builtins.Exception
* builtins.BaseException
Loading

0 comments on commit a742a27

Please sign in to comment.