From 016a2f5afe43d085f82911c986c09e84d8f4e1c4 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Mon, 25 Sep 2023 22:42:00 -0400 Subject: [PATCH] Fix some test stuff (#372) * fix(test): import error on chains without snx * fix(test): event on wrong loop --- tests/prices/test_synthetix.py | 2 +- y/prices/chainlink.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/prices/test_synthetix.py b/tests/prices/test_synthetix.py index 2ac8e6ebd..db322fbb6 100644 --- a/tests/prices/test_synthetix.py +++ b/tests/prices/test_synthetix.py @@ -10,7 +10,7 @@ async_synthetix = Synthetix(asynchronous=True) SYNTHS = sync_synthetix.synths except UnsupportedNetwork: - pass + SYNTHS = [] @mainnet_only def test_get_synths(): diff --git a/y/prices/chainlink.py b/y/prices/chainlink.py index ce47df5ca..2cef3adfb 100644 --- a/y/prices/chainlink.py +++ b/y/prices/chainlink.py @@ -1,5 +1,6 @@ import asyncio import logging +from functools import cached_property from typing import Dict, NoReturn, Optional, Union import a_sync @@ -177,9 +178,13 @@ def __init__(self, asynchronous: bool = False) -> None: elif len(FEEDS) == 0: raise UnsupportedNetwork('chainlink is not supported on this network') self._cached_feeds = {ERC20(token, asynchronous=self.asynchronous): feed for token, feed in FEEDS.items()} - self._feeds_loaded = a_sync.Event() self._loading = False + @cached_property + def _feeds_loaded(self) -> a_sync.Event: + """A helper function to ensure the Event is attached to the correct loop.""" + return a_sync.Event() + async def _start_feed_loop(self) -> Union[None, NoReturn]: if self._loading: return