1919from mock import AsyncMock
2020
2121
22- BCH_PRODUCT_ACCOUNT_KEY_DEVNET = '89GseEmvNkzAMMEXcW9oTYzqRPXTsJ3BmNerXmgA1osV'
23- BCH_PRICE_ACCOUNT_KEY_DEVNET = '4EQrNZYk5KR1RnjyzbaaRbHsv8VqZWzSUtvx58wLsZbj'
22+ # Using constants instead of fixtures because:
23+ # 1) these values are not expected to be mutated
24+ # 2) these values are used in get_account_info_resp() and get_program_accounts_resp()
25+ # and so if they are passed in as fixtures, the functions will complain for the args
26+ # while mocking the respective functions
27+ BCH_PRODUCT_ACCOUNT_KEY = '89GseEmvNkzAMMEXcW9oTYzqRPXTsJ3BmNerXmgA1osV'
28+ BCH_PRICE_ACCOUNT_KEY = '4EQrNZYk5KR1RnjyzbaaRbHsv8VqZWzSUtvx58wLsZbj'
2429
2530MAPPING_ACCOUNT_B64_DATA = ('1MOyoQIAAAABAAAAWAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABqIGcc'
2631 'Dj+MshnOP0blrglqTy/fk20r1NqJJfcAh9Ud2A==' )
8590 'AAAAAAAAAAAAAAAA' )
8691
8792
88- def get_account_info_resp (key : Union [SolanaPublicKeyOrStr , Sequence [SolanaPublicKeyOrStr ]]):
93+ def get_account_info_resp (key : Union [SolanaPublicKeyOrStr , Sequence [SolanaPublicKeyOrStr ]]) -> Dict [ str , Any ] :
8994 b64_data = ''
9095 # mapping account
9196 if key == SolanaPublicKey (V2_FIRST_MAPPING_ACCOUNT_KEY ):
9297 b64_data = MAPPING_ACCOUNT_B64_DATA
9398 # product account
94- elif key == [SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY_DEVNET )]:
99+ elif key == [SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY )]:
95100 b64_data = PRODUCT_ACCOUNT_B64_DATA
96101 # price account
97- elif key == SolanaPublicKey (BCH_PRICE_ACCOUNT_KEY_DEVNET ):
102+ elif key == SolanaPublicKey (BCH_PRICE_ACCOUNT_KEY ):
98103 b64_data = PRICE_ACCOUNT_B64_DATA
99104 return {
100105 'context' : {
@@ -141,7 +146,7 @@ def get_program_accounts_resp(key: SolanaPublicKeyOrStr,
141146 'owner' : V2_PROGRAM_KEY ,
142147 'rentEpoch' : 224
143148 },
144- 'pubkey' : BCH_PRODUCT_ACCOUNT_KEY_DEVNET
149+ 'pubkey' : BCH_PRODUCT_ACCOUNT_KEY
145150 },
146151 {
147152 'account' : {
@@ -154,7 +159,7 @@ def get_program_accounts_resp(key: SolanaPublicKeyOrStr,
154159 'owner' : V2_PROGRAM_KEY ,
155160 'rentEpoch' : 224
156161 },
157- 'pubkey' : BCH_PRICE_ACCOUNT_KEY_DEVNET
162+ 'pubkey' : BCH_PRICE_ACCOUNT_KEY
158163 }
159164 ]
160165
@@ -199,14 +204,14 @@ def mapping_account(solana_client: SolanaClient) -> PythMappingAccount:
199204@ pytest .fixture
200205def mapping_account_entries () -> List [SolanaPublicKey ]:
201206 return [
202- SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY_DEVNET )
207+ SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY )
203208 ]
204209
205210
206211@ pytest .fixture
207212def product_account (solana_client : SolanaClient ) -> PythProductAccount :
208213 product_account = PythProductAccount (
209- key = SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY_DEVNET ),
214+ key = SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY ),
210215 solana = solana_client ,
211216 )
212217 product_account .slot = 96866599
@@ -219,7 +224,7 @@ def product_account(solana_client: SolanaClient) -> PythProductAccount:
219224 'base' : 'BCH'
220225 }
221226 product_account .first_price_account_key = SolanaPublicKey (
222- BCH_PRICE_ACCOUNT_KEY_DEVNET ,
227+ BCH_PRICE_ACCOUNT_KEY ,
223228 )
224229 return product_account
225230
@@ -232,7 +237,7 @@ def product_account_bytes() -> bytes:
232237@ pytest .fixture
233238def price_account (solana_client : SolanaClient ) -> PythPriceAccount :
234239 return PythPriceAccount (
235- key = SolanaPublicKey (BCH_PRICE_ACCOUNT_KEY_DEVNET ),
240+ key = SolanaPublicKey (BCH_PRICE_ACCOUNT_KEY ),
236241 solana = solana_client ,
237242 )
238243
@@ -374,4 +379,4 @@ def test_create_watch_session(
374379 watch_session : WatchSession
375380) -> None :
376381 ws = pyth_client .create_watch_session ()
377- assert ws . _next_subid () == watch_session . _next_subid ( )
382+ assert isinstance ( ws , WatchSession )
0 commit comments