diff --git a/autoagora/price_save_state_db.py b/autoagora/price_save_state_db.py index a4c091b..330912c 100644 --- a/autoagora/price_save_state_db.py +++ b/autoagora/price_save_state_db.py @@ -78,9 +78,8 @@ async def load_state(self, subgraph: str) -> Optional[SaveState]: """ ).format(subgraph_hash=subgraph) ) - row = await row.fetchall() + row = await row.fetchone() if row: - row = row[0] return SaveState( last_update=row[0], # type: ignore mean=row[1], # type: ignore diff --git a/tests/test_price_save_state_db.py b/tests/test_price_save_state_db.py index cbd1cab..69e68cb 100644 --- a/tests/test_price_save_state_db.py +++ b/tests/test_price_save_state_db.py @@ -11,7 +11,7 @@ class TestPriceSaveStateDB: @pytest.fixture - async def pssdb(self, postgresql): + async def pgpool(self, postgresql): conn_string = ( f"host={postgresql.info.host} " f"dbname={postgresql.info.dbname} " @@ -25,9 +25,13 @@ async def pssdb(self, postgresql): ) await pool.open() await pool.wait() + yield pool + await pool.close() - pssdb_ = price_save_state_db.PriceSaveStateDB(pool) - return pssdb_ + @pytest.fixture + async def pssdb(self, pgpool): + pssdb_ = price_save_state_db.PriceSaveStateDB(pgpool) + yield pssdb_ async def test_create_write_read(self, pssdb): random.seed(42)