Skip to content

Commit 6313c9b

Browse files
committed
test init mapping and add product
1 parent 5756598 commit 6313c9b

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

pyth/tests/conftest.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ def solana_airdrop(solana_test_validator, solana_keygen):
157157

158158

159159
@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+
):
161163

162164
cmd = [
163165
'solana', 'program', 'deploy',
@@ -174,3 +176,55 @@ def solana_program_deploy(solana_test_validator, solana_keygen, solana_airdrop):
174176
output = [line for line in output if 'Program Id' in line][0]
175177
output = output.split('Program Id: ')[1]
176178
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]

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_deploy(solana_program_deploy):
1+
def test_setup(pyth_add_product):
22

33
assert(True)

0 commit comments

Comments
 (0)