From 1da7e9acf708e1217ee3c593c63c5a905a4b19a5 Mon Sep 17 00:00:00 2001 From: Chris Heaney Date: Thu, 16 Nov 2023 15:13:59 -0500 Subject: [PATCH] fix test --- src/driftpy/accounts/cache/user.py | 3 ++- tests/test.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/driftpy/accounts/cache/user.py b/src/driftpy/accounts/cache/user.py index ffcd1b4f..dd92a93a 100644 --- a/src/driftpy/accounts/cache/user.py +++ b/src/driftpy/accounts/cache/user.py @@ -17,10 +17,11 @@ def __init__(self, user_pubkey: PublicKey, program: Program, commitment: Commitm self.user_and_slot = None async def update_cache(self): - user_and_slot = await get_user_account_and_slot(self.program) + user_and_slot = await get_user_account_and_slot(self.program, self.user_pubkey) self.user_and_slot = user_and_slot async def get_user_account_and_slot(self) -> Optional[DataAndSlot[User]]: + await self.cache_if_needed() return self.user_and_slot async def cache_if_needed(self): diff --git a/tests/test.py b/tests/test.py index cd43e9ab..83de6449 100644 --- a/tests/test.py +++ b/tests/test.py @@ -210,9 +210,7 @@ async def test_open_orders( ): drift_user = DriftUser(drift_client) - user_account = await get_user_account( - drift_client.program, drift_client.authority - ) + user_account = await drift_client.get_user(0) assert(len(user_account.orders)==32) assert(user_account.orders[0].market_index == 0) @@ -227,12 +225,14 @@ async def test_open_orders( order_params.user_order_id = 169 ixs = await drift_client.get_place_perp_orders_ix([order_params]) await drift_client.send_ixs(ixs) + await drift_user.account_subscriber.update_cache() open_orders_after = await drift_user.get_open_orders() assert(open_orders_after[0].base_asset_amount == BASE_PRECISION) assert(open_orders_after[0].order_id == 1) assert(open_orders_after[0].user_order_id == 169) await drift_client.cancel_order(1, 0) + await drift_user.account_subscriber.update_cache() open_orders_after2 = await drift_user.get_open_orders() assert(open_orders_after2[0].base_asset_amount == 0)