@@ -110,6 +110,31 @@ def run_test(self, input_path: str, output_path: str, *, inplace: bool):
110110 assert actual == expected
111111
112112
113+ PRODUCTS = {
114+ 'BTC' : {
115+ 'symbol' : 'BTC/USD' ,
116+ 'asset_type' : 'Crypto' ,
117+ 'country' : 'US' ,
118+ 'quote_currency' : 'USD' ,
119+ 'tenor' : 'Spot' ,
120+ },
121+ 'ETH' : {
122+ 'symbol' : 'ETH/USD' ,
123+ 'asset_type' : 'Crypto' ,
124+ 'country' : 'US' ,
125+ 'quote_currency' : 'USD' ,
126+ 'tenor' : 'Spot' ,
127+ },
128+ 'LTC' : {
129+ 'symbol' : 'LTC/USD' ,
130+ 'asset_type' : 'Crypto' ,
131+ 'country' : 'US' ,
132+ 'quote_currency' : 'USD' ,
133+ 'tenor' : 'Spot' ,
134+ },
135+ }
136+
137+
113138@pytest .fixture (scope = 'session' )
114139def solana_test_validator ():
115140
@@ -220,35 +245,33 @@ def pyth_init_mapping(
220245@pytest .fixture (scope = 'session' )
221246def pyth_add_product (solana_test_validator , pyth_dir , pyth_init_mapping ):
222247
223- cmd = [
224- 'pyth_admin' , 'add_product' ,
225- '-r' , 'localhost' ,
226- '-k' , pyth_dir ,
227- '-c' , 'finalized' ,
228- ]
229- output = check_output (cmd )
230- output = output .decode ('ascii' )
231- output = output .splitlines ()
232- return output [0 ]
248+ result = {}
249+ for product in PRODUCTS .keys ():
250+ cmd = [
251+ 'pyth_admin' , 'add_product' ,
252+ '-r' , 'localhost' ,
253+ '-k' , pyth_dir ,
254+ '-c' , 'finalized' ,
255+ ]
256+ output = check_output (cmd )
257+ output = output .decode ('ascii' )
258+ output = output .splitlines ()
259+ result [product ] = output [0 ]
260+ return result
233261
234262
235263@pytest .fixture (scope = 'session' )
236264def pyth_init_product (solana_test_validator , pyth_dir , pyth_add_product ):
237265
238- ltc = {
239- 'account' : pyth_add_product ,
240- 'attr_dict' : {
241- 'symbol' : 'LTC/USD' ,
242- 'asset_type' : 'Crypto' ,
243- 'country' : 'US' ,
244- 'quote_currency' : 'USD' ,
245- 'tenor' : 'Spot' ,
246- 'jlqd_symbol' : 'LTCUSD' ,
247- },
248- }
249- fd , path = mkstemp (suffix = '.json' , prefix = 'ltc_' )
266+ products = []
267+ for product in pyth_add_product .keys ():
268+ products .append ({
269+ 'account' : pyth_add_product [product ],
270+ 'attr_dict' : PRODUCTS [product ],
271+ })
272+ fd , path = mkstemp (suffix = '.json' , prefix = 'products_' )
250273 with fdopen (fd , 'w' ) as f :
251- json .dump ([ ltc ] , f )
274+ json .dump (products , f )
252275 cmd = [
253276 'pyth_admin' , 'upd_product' , path ,
254277 '-r' , 'localhost' ,
@@ -263,32 +286,36 @@ def pyth_init_product(solana_test_validator, pyth_dir, pyth_add_product):
263286@pytest .fixture (scope = 'session' )
264287def pyth_add_price (solana_test_validator , pyth_dir , pyth_init_product ):
265288
266- cmd = [
267- 'pyth_admin' , 'add_price' ,
268- pyth_init_product , 'price' , '-e' , '-5' ,
269- '-r' , 'localhost' ,
270- '-k' , pyth_dir ,
271- '-c' , 'finalized' ,
272- '-n' ,
273- ]
274- output = check_output (cmd )
275- output = output .decode ('ascii' )
276- output = output .splitlines ()
277- return output [0 ]
278-
279-
280- @pytest .fixture (scope = 'session' )
289+ result = {}
290+ for product , key in pyth_init_product .items ():
291+ cmd = [
292+ 'pyth_admin' , 'add_price' ,
293+ key , 'price' , '-e' , '-5' ,
294+ '-r' , 'localhost' ,
295+ '-k' , pyth_dir ,
296+ '-c' , 'finalized' ,
297+ '-n' ,
298+ ]
299+ output = check_output (cmd )
300+ output = output .decode ('ascii' )
301+ output = output .splitlines ()
302+ result [product ] = output [0 ]
303+ return result
304+
305+
306+ @pytest .fixture (scope = 'function' )
281307def pyth_init_price (solana_test_validator , pyth_dir , pyth_add_price ):
282308
283- cmd = [
284- 'pyth_admin' , 'init_price' ,
285- pyth_add_price , '-e' , '-5' ,
286- '-r' , 'localhost' ,
287- '-k' , pyth_dir ,
288- '-c' , 'finalized' ,
289- '-n' ,
290- ]
291- check_call (cmd )
309+ for product , key in pyth_add_price .items ():
310+ cmd = [
311+ 'pyth_admin' , 'init_price' ,
312+ key , '-e' , '-5' ,
313+ '-r' , 'localhost' ,
314+ '-k' , pyth_dir ,
315+ '-c' , 'finalized' ,
316+ '-n' ,
317+ ]
318+ check_call (cmd )
292319 return pyth_add_price
293320
294321
0 commit comments