19
19
from mock import AsyncMock
20
20
21
21
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'
24
29
25
30
MAPPING_ACCOUNT_B64_DATA = ('1MOyoQIAAAABAAAAWAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABqIGcc'
26
31
'Dj+MshnOP0blrglqTy/fk20r1NqJJfcAh9Ud2A==' )
85
90
'AAAAAAAAAAAAAAAA' )
86
91
87
92
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 ] :
89
94
b64_data = ''
90
95
# mapping account
91
96
if key == SolanaPublicKey (V2_FIRST_MAPPING_ACCOUNT_KEY ):
92
97
b64_data = MAPPING_ACCOUNT_B64_DATA
93
98
# product account
94
- elif key == [SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY_DEVNET )]:
99
+ elif key == [SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY )]:
95
100
b64_data = PRODUCT_ACCOUNT_B64_DATA
96
101
# price account
97
- elif key == SolanaPublicKey (BCH_PRICE_ACCOUNT_KEY_DEVNET ):
102
+ elif key == SolanaPublicKey (BCH_PRICE_ACCOUNT_KEY ):
98
103
b64_data = PRICE_ACCOUNT_B64_DATA
99
104
return {
100
105
'context' : {
@@ -141,7 +146,7 @@ def get_program_accounts_resp(key: SolanaPublicKeyOrStr,
141
146
'owner' : V2_PROGRAM_KEY ,
142
147
'rentEpoch' : 224
143
148
},
144
- 'pubkey' : BCH_PRODUCT_ACCOUNT_KEY_DEVNET
149
+ 'pubkey' : BCH_PRODUCT_ACCOUNT_KEY
145
150
},
146
151
{
147
152
'account' : {
@@ -154,7 +159,7 @@ def get_program_accounts_resp(key: SolanaPublicKeyOrStr,
154
159
'owner' : V2_PROGRAM_KEY ,
155
160
'rentEpoch' : 224
156
161
},
157
- 'pubkey' : BCH_PRICE_ACCOUNT_KEY_DEVNET
162
+ 'pubkey' : BCH_PRICE_ACCOUNT_KEY
158
163
}
159
164
]
160
165
@@ -199,14 +204,14 @@ def mapping_account(solana_client: SolanaClient) -> PythMappingAccount:
199
204
@ pytest .fixture
200
205
def mapping_account_entries () -> List [SolanaPublicKey ]:
201
206
return [
202
- SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY_DEVNET )
207
+ SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY )
203
208
]
204
209
205
210
206
211
@ pytest .fixture
207
212
def product_account (solana_client : SolanaClient ) -> PythProductAccount :
208
213
product_account = PythProductAccount (
209
- key = SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY_DEVNET ),
214
+ key = SolanaPublicKey (BCH_PRODUCT_ACCOUNT_KEY ),
210
215
solana = solana_client ,
211
216
)
212
217
product_account .slot = 96866599
@@ -219,7 +224,7 @@ def product_account(solana_client: SolanaClient) -> PythProductAccount:
219
224
'base' : 'BCH'
220
225
}
221
226
product_account .first_price_account_key = SolanaPublicKey (
222
- BCH_PRICE_ACCOUNT_KEY_DEVNET ,
227
+ BCH_PRICE_ACCOUNT_KEY ,
223
228
)
224
229
return product_account
225
230
@@ -232,7 +237,7 @@ def product_account_bytes() -> bytes:
232
237
@ pytest .fixture
233
238
def price_account (solana_client : SolanaClient ) -> PythPriceAccount :
234
239
return PythPriceAccount (
235
- key = SolanaPublicKey (BCH_PRICE_ACCOUNT_KEY_DEVNET ),
240
+ key = SolanaPublicKey (BCH_PRICE_ACCOUNT_KEY ),
236
241
solana = solana_client ,
237
242
)
238
243
@@ -374,4 +379,4 @@ def test_create_watch_session(
374
379
watch_session : WatchSession
375
380
) -> None :
376
381
ws = pyth_client .create_watch_session ()
377
- assert ws . _next_subid () == watch_session . _next_subid ( )
382
+ assert isinstance ( ws , WatchSession )
0 commit comments