Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Nov 16, 2023
1 parent d125784 commit 1da7e9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/driftpy/accounts/cache/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit 1da7e9a

Please sign in to comment.