Skip to content

Commit 8367b52

Browse files
committed
test price account
1 parent 46aa6a1 commit 8367b52

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

pyth/tests/conftest.py

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import argparse
22
import glob
33
import inspect
4+
import json
45
import os
56
import subprocess
67
import time
8+
from os import fdopen
79
from shutil import rmtree
810
from subprocess import DEVNULL, Popen, check_call, check_output
9-
from tempfile import mkdtemp
11+
from tempfile import mkdtemp, mkstemp
1012

1113
import pytest
1214

@@ -228,3 +230,63 @@ def pyth_add_product(solana_test_validator, pyth_dir, pyth_init_mapping):
228230
output = output.decode('ascii')
229231
output = output.splitlines()
230232
return output[0]
233+
234+
235+
@pytest.fixture(scope='session')
236+
def pyth_init_product(solana_test_validator, pyth_dir, pyth_add_product):
237+
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_')
250+
with fdopen(fd, 'w') as f:
251+
json.dump([ltc], f)
252+
cmd = [
253+
'pyth_admin', 'upd_product', path,
254+
'-r', 'localhost',
255+
'-k', pyth_dir,
256+
'-c', 'finalized',
257+
]
258+
check_call(cmd)
259+
os.remove(path)
260+
return pyth_add_product
261+
262+
263+
@pytest.fixture(scope='session')
264+
def pyth_add_price(solana_test_validator, pyth_dir, pyth_init_product):
265+
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')
281+
def pyth_init_price(solana_test_validator, pyth_dir, pyth_add_price):
282+
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)
292+
return pyth_add_price

pyth/tests/test_deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
def test_setup(pyth_add_product):
1+
def test_setup(pyth_init_price):
22

33
assert(True)

0 commit comments

Comments
 (0)