Skip to content

Commit

Permalink
Add ignored status and bump v (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati authored Jan 25, 2023
1 parent fd14acb commit eb71516
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions pythclient/pythaccounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class PythPriceStatus(Enum):
TRADING = 1
HALTED = 2
AUCTION = 3
IGNORED = 4


class PythPriceType(Enum):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='pythclient',
version='0.1.3',
version='0.1.4',
packages=['pythclient'],
author='Pyth Developers',
author_email='[email protected]',
Expand Down
26 changes: 25 additions & 1 deletion tests/test_price_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ def price_info_trading_bytes():
return base64.b64decode(b'EKH74A0AAABkU5ECAAAAAAEAAAAAAAAAQchHBgAAAAA=')


@pytest.fixture
def price_info_ignored():
return PythPriceInfo(
raw_price=59609162000,
raw_confidence_interval=43078500,
price_status=PythPriceStatus.IGNORED,
pub_slot=105367617,
exponent=-8,
)


@pytest.fixture
def price_info_ignored_bytes():
return base64.b64decode(b'EKH74A0AAABkU5ECAAAAAAQAAAAAAAAAQchHBgAAAAA=')

@pytest.mark.parametrize(
"raw_price,raw_confidence_interval,price_status,pub_slot,exponent,price,confidence_interval",
[
Expand Down Expand Up @@ -88,7 +103,7 @@ def test_price_info_iter(
assert actual == expected


def test_price_info_deserialise(price_info_trading, price_info_trading_bytes):
def test_price_info_deserialise_trading(price_info_trading, price_info_trading_bytes):
actual = PythPriceInfo.deserialise(
buffer=price_info_trading_bytes,
offset=0,
Expand All @@ -97,6 +112,15 @@ def test_price_info_deserialise(price_info_trading, price_info_trading_bytes):
assert asdict(actual) == asdict(price_info_trading)


def test_price_info_deserialise_ignored(price_info_ignored, price_info_ignored_bytes):
actual = PythPriceInfo.deserialise(
buffer=price_info_ignored_bytes,
offset=0,
exponent=price_info_ignored.exponent,
)
assert asdict(actual) == asdict(price_info_ignored)


def test_price_info_str(price_info_trading):
expected = "PythPriceInfo status PythPriceStatus.TRADING price 596.09162"
assert str(price_info_trading) == expected
Expand Down

0 comments on commit eb71516

Please sign in to comment.