Skip to content

Commit 50ff8d8

Browse files
committed
use temp folder for keygen
1 parent 65d709c commit 50ff8d8

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

pyth/tests/conftest.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def run_test(self, input_path: str, output_path: str, *, inplace: bool):
108108
assert actual == expected
109109

110110

111-
@pytest.fixture
111+
@pytest.fixture(scope='session')
112112
def solana_test_validator():
113113

114114
ledger_dir = mkdtemp(prefix='stv_')
@@ -129,31 +129,35 @@ def solana_test_validator():
129129
rmtree(ledger_dir)
130130

131131

132-
@pytest.fixture
132+
@pytest.fixture(scope='session')
133133
def solana_keygen():
134134

135-
cmd = ['solana-keygen', 'new', '--no-passphrase']
135+
cfg_dir = mkdtemp(prefix='cfg_')
136+
path = os.path.join(cfg_dir, 'id.json')
137+
cmd = ['solana-keygen', 'new', '--no-passphrase', '--outfile', path]
136138
output = check_output(cmd)
137139
output = output.decode('ascii')
138140
output = output.splitlines()
139141
output = [line for line in output if 'pubkey' in line][0]
140142
output = output.split('pubkey: ')[1]
141-
return output
143+
yield (output, path)
144+
rmtree(cfg_dir)
142145

143146

144-
@pytest.fixture
147+
@pytest.fixture(scope='session')
145148
def solana_airdrop(solana_test_validator, solana_keygen):
146149

147150
cmd = [
148-
'solana', 'airdrop', '100', solana_keygen,
151+
'solana', 'airdrop', '100', solana_keygen[0],
149152
'--commitment', 'finalized',
150153
'--url', 'localhost',
154+
'--keypair', solana_keygen[1],
151155
]
152156
check_call(cmd)
153157

154158

155-
@pytest.fixture
156-
def solana_program_deploy(solana_test_validator, solana_airdrop):
159+
@pytest.fixture(scope='session')
160+
def solana_program_deploy(solana_test_validator, solana_keygen, solana_airdrop):
157161

158162
cmd = [
159163
'solana', 'program', 'deploy',
@@ -162,6 +166,7 @@ def solana_program_deploy(solana_test_validator, solana_airdrop):
162166
),
163167
'--commitment', 'finalized',
164168
'--url', 'localhost',
169+
'--keypair', solana_keygen[1],
165170
]
166171
output = check_output(cmd)
167172
output = output.decode('ascii')

0 commit comments

Comments
 (0)