Skip to content

Commit 8d671af

Browse files
authored
fix add_feed_ids bug (#55)
1 parent 8cd3b85 commit 8d671af

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

pythclient/hermes.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ async def get_price_feed_ids(self) -> list[str]:
4747
return data
4848

4949
def add_feed_ids(self, feed_ids: list[str]):
50-
self.feed_ids += feed_ids
51-
self.feed_ids = list(set(self.feed_ids))
52-
self.pending_feed_ids += feed_ids
50+
# convert feed_ids to a set to remove any duplicates from the input
51+
new_feed_ids_set = set(feed_ids)
52+
53+
# update self.feed_ids; convert to set for union operation, then back to list
54+
self.feed_ids = list(set(self.feed_ids).union(new_feed_ids_set))
55+
56+
# update self.pending_feed_ids with only those IDs that are truly new
57+
self.pending_feed_ids = list(set(self.pending_feed_ids).union(new_feed_ids_set))
5358

5459
@staticmethod
5560
def extract_price_feed_v1(data: dict) -> PriceFeed:

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='pythclient',
10-
version='0.1.23',
10+
version='0.1.24',
1111
packages=['pythclient'],
1212
author='Pyth Developers',
1313
author_email='[email protected]',

tests/test_hermes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async def test_hermes_add_feed_ids(hermes_client: HermesClient, mock_get_price_f
125125

126126
assert len(set(hermes_client.feed_ids)) == len(hermes_client.feed_ids)
127127
assert set(hermes_client.feed_ids) == set(feed_ids_pre + feed_ids)
128-
assert set(hermes_client.pending_feed_ids) == set(pending_feed_ids_pre + feed_ids)
128+
assert len(hermes_client.pending_feed_ids) == len(set(pending_feed_ids_pre + feed_ids))
129129

130130
def test_hermes_extract_price_feed_v1(hermes_client: HermesClient, data_v1: dict):
131131
price_feed = hermes_client.extract_price_feed_v1(data_v1)

0 commit comments

Comments
 (0)