@@ -157,7 +157,9 @@ def solana_airdrop(solana_test_validator, solana_keygen):
157
157
158
158
159
159
@pytest .fixture (scope = 'session' )
160
- def solana_program_deploy (solana_test_validator , solana_keygen , solana_airdrop ):
160
+ def solana_program_deploy (
161
+ solana_test_validator , solana_keygen , solana_airdrop
162
+ ):
161
163
162
164
cmd = [
163
165
'solana' , 'program' , 'deploy' ,
@@ -174,3 +176,55 @@ def solana_program_deploy(solana_test_validator, solana_keygen, solana_airdrop):
174
176
output = [line for line in output if 'Program Id' in line ][0 ]
175
177
output = output .split ('Program Id: ' )[1 ]
176
178
return output
179
+
180
+
181
+ @pytest .fixture (scope = 'session' )
182
+ def pyth_dir ():
183
+
184
+ path = mkdtemp (prefix = 'pythd_' )
185
+ yield path
186
+ rmtree (path )
187
+
188
+
189
+ @pytest .fixture (scope = 'session' )
190
+ def pyth_publish_key (solana_keygen , pyth_dir ):
191
+
192
+ path = os .path .join (pyth_dir , 'publish_key_pair.json' )
193
+ os .symlink (solana_keygen [1 ], path )
194
+
195
+
196
+ @pytest .fixture (scope = 'session' )
197
+ def pyth_program_key (solana_program_deploy , pyth_dir ):
198
+
199
+ pyth_path = os .path .join (pyth_dir , 'program_key.json' )
200
+ with open (pyth_path , 'w' ) as f :
201
+ f .write (solana_program_deploy )
202
+
203
+
204
+ @pytest .fixture (scope = 'session' )
205
+ def pyth_init_mapping (
206
+ solana_test_validator , pyth_dir , pyth_publish_key , pyth_program_key
207
+ ):
208
+
209
+ cmd = [
210
+ 'pyth_admin' , 'init_mapping' ,
211
+ '-r' , 'localhost' ,
212
+ '-k' , pyth_dir ,
213
+ '-c' , 'finalized' ,
214
+ ]
215
+ check_call (cmd )
216
+
217
+
218
+ @pytest .fixture (scope = 'session' )
219
+ def pyth_add_product (solana_test_validator , pyth_dir , pyth_init_mapping ):
220
+
221
+ cmd = [
222
+ 'pyth_admin' , 'add_product' ,
223
+ '-r' , 'localhost' ,
224
+ '-k' , pyth_dir ,
225
+ '-c' , 'finalized' ,
226
+ ]
227
+ output = check_output (cmd )
228
+ output = output .decode ('ascii' )
229
+ output = output .splitlines ()
230
+ return output [0 ]
0 commit comments