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: threads in ping tests would hang indefinitely. #207

Merged
merged 8 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ jobs:
# ----------------------------------------------
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Python 3.7
- name: Set up Python (3.8)
id: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.7.15
# 3.7.15 is the highest version available for this GitHub action.
# See https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
# to see the full list of supported Python versions.
# 3.7.16 is the highest 3.7 version available on pyenv
# See `grep '3.7' <<< $(pyenv install -l)` to view the available list.
python-version: 3.8.16
# 3.8.16 is the highest version available for this GitHub action.
# For the full list of supported Python versions, see:
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
# 3.8.16 is the highest 3.8 version available on pyenv
# See `grep '3.8' <<< $(pyenv install -l)` to view the available list.

- name: Run python
run: python --version && python -c "print('hello')"
Expand Down
53 changes: 29 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- id: end-of-file-fixer
exclude: nibiru/proto/.+

- id: trailing-whitespace
exclude: nibiru/proto/.+

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
files: \.py$
- repo: https://github.com/floatingpurr/sync_with_poetry
rev: "0.4.0" # the revision or tag to clone at
hooks:
- id: sync_with_poetry
args: [] # optional args
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
exclude: nibiru/proto/.+

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
files: \.py$
- id: trailing-whitespace
exclude: nibiru/proto/.+
args: ["--profile", "black"]

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
files: \.py$
exclude: nibiru/proto/.+

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
files: \.py$
exclude: nibiru/proto/.+
args: [ "--profile", "black" ]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.16
3.8.16
12 changes: 10 additions & 2 deletions nibiru/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@
import nibiru.pytypes # noqa
from nibiru.grpc_client import GrpcClient # noqa
from nibiru.msg import Msg # noqa
from nibiru.pytypes import Network # noqa
from nibiru.pytypes import Coin, Direction, PoolAsset, Side, TxConfig, TxType # noqa
from nibiru.pytypes import ( # noqa
Coin,
Direction,
Network,
NetworkType,
PoolAsset,
Side,
TxConfig,
TxType,
)
from nibiru.sdk import Sdk # noqa
from nibiru.tx import Transaction # noqa
from nibiru.wallet import Address, PrivateKey, PublicKey # noqa
2 changes: 1 addition & 1 deletion nibiru/pytypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
TxType,
)
from nibiru.pytypes.event import Event, RawEvent, TxLogEvents # noqa
from nibiru.pytypes.network import Network # noqa
from nibiru.pytypes.network import Network, NetworkType # noqa
from nibiru.pytypes.tx_resp import RawTxResp, TxResp # noqa
36 changes: 36 additions & 0 deletions nibiru/pytypes/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

"""
import dataclasses
import enum
import os
from typing import Dict, Optional

Expand Down Expand Up @@ -178,3 +179,38 @@ def devnet(cls, chain_num: int = 2) -> "Network":
fee_denom='unibi',
env='devnet',
)

@classmethod
def from_chain_id(cls, chain_id: str) -> "Network":
"""
Soon!
"""

chain_id_elements: List[str] = chain_id.split("-")
if len(chain_id_elements) != 3:
raise ValueError(
f"invalid chain_id format: {chain_id}. Expected one like nibiru-testnet-2"
)

prefix, chain_type, chain_number = chain_id_elements
chain_number = int(chain_number)

if chain_type == NetworkType.DEVNET.value:
return Network.devnet(chain_number)
elif chain_type == NetworkType.TESTNET.value:
return Network.testnet(chain_number)
elif chain_type == NetworkType.LOCALNET.value:
return Network.localnet()
else:
network_types: List[str] = [member.value for member in NetworkType]
raise ValueError(
f"invalid chain type: {chain_type}. Available options: {network_types}"
)


class NetworkType(enum.Enum):
"""Enum class for the available network types. E.g. 'testnet' and 'devnet'."""

DEVNET = "devnet"
TESTNET = "testnet"
LOCALNET = "localnet"
3 changes: 2 additions & 1 deletion nibiru/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
def execute_msgs(
self,
msgs: Union[pt.PythonMsg, List[pt.PythonMsg]],
get_sequence_from_node: bool = False,
get_sequence_from_node: bool = True,
**kwargs,
) -> pt.RawTxResp:
"""
Expand Down Expand Up @@ -100,6 +100,7 @@ def execute_msgs(
):
if not isinstance(msgs, list):
msgs = [msgs]
self.client.wait_for_next_block()
return self.execute_msgs(*msgs, get_sequence_from_node=True, **kwargs)

if address:
Expand Down
Loading