mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 09:16:00 +00:00
Add working test vector generator
This commit is contained in:
@@ -12,14 +12,18 @@ tmp_dir = os.path.join(".", "tmp")
|
|||||||
mnemonic_path = os.path.join(tmp_dir, "mnemonic.txt")
|
mnemonic_path = os.path.join(tmp_dir, "mnemonic.txt")
|
||||||
sdc_dir = os.path.join(tmp_dir, "sdc")
|
sdc_dir = os.path.join(tmp_dir, "sdc")
|
||||||
sdc_git_dir = os.path.join(sdc_dir, "staking-deposit-cli")
|
sdc_git_dir = os.path.join(sdc_dir, "staking-deposit-cli")
|
||||||
|
vectors_dir = os.path.join(".", "vectors")
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
if os.path.exists(tmp_dir):
|
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
||||||
|
if os.path.exists(vectors_dir):
|
||||||
|
shutil.rmtree(vectors_dir)
|
||||||
|
|
||||||
os.mkdir(tmp_dir)
|
os.mkdir(tmp_dir)
|
||||||
os.mkdir(sdc_dir)
|
os.mkdir(sdc_dir)
|
||||||
|
os.mkdir(vectors_dir)
|
||||||
|
|
||||||
setup_sdc()
|
setup_sdc()
|
||||||
with open(mnemonic_path, "x") as file:
|
with open(mnemonic_path, "x") as file:
|
||||||
@@ -27,6 +31,7 @@ def setup():
|
|||||||
|
|
||||||
|
|
||||||
def cleanup():
|
def cleanup():
|
||||||
|
if os.path.exists(tmp_dir):
|
||||||
shutil.rmtree(tmp_dir)
|
shutil.rmtree(tmp_dir)
|
||||||
|
|
||||||
|
|
||||||
@@ -53,34 +58,39 @@ def setup_sdc():
|
|||||||
], cwd=sdc_git_dir)
|
], cwd=sdc_git_dir)
|
||||||
assert(result.returncode == 0)
|
assert(result.returncode == 0)
|
||||||
|
|
||||||
|
|
||||||
def sdc_generate(network, first_index, count):
|
def sdc_generate(network, first_index, count):
|
||||||
|
test_name = "{}_first_{}_count_{}".format(network, first_index, count)
|
||||||
|
output_dir = os.path.join(vectors_dir, test_name)
|
||||||
|
os.mkdir(output_dir)
|
||||||
|
|
||||||
|
print("Running " + test_name)
|
||||||
process = Popen([
|
process = Popen([
|
||||||
'/bin/sh',
|
'/bin/sh',
|
||||||
'deposit.sh',
|
'deposit.sh',
|
||||||
|
'--language', 'english',
|
||||||
|
'--non_interactive',
|
||||||
'existing-mnemonic',
|
'existing-mnemonic',
|
||||||
], stdout=PIPE, stdin=PIPE, stderr=STDOUT, cwd=sdc_git_dir, text=True)
|
'--validator_start_index', str(first_index),
|
||||||
process.stdin.write('3\n') # Select "3. English" as the mnemonic language.
|
'--num_validators', str(count),
|
||||||
process.stdin.write(TEST_MNEMONIC + '\n')
|
'--mnemonic', TEST_MNEMONIC,
|
||||||
process.stdin.write(str(first_index) + '\n')
|
'--chain', 'mainnet',
|
||||||
process.stdin.write(str(first_index) + '\n')
|
'--keystore_password', 'MyPassword',
|
||||||
process.stdin.write(str(count) + '\n')
|
'--folder', os.path.abspath(output_dir),
|
||||||
process.stdin.write(network + '\n')
|
], cwd=sdc_git_dir, text=True, stdin = PIPE)
|
||||||
process.stdin.write('junk_password\n')
|
|
||||||
process.stdin.write('junk_password\n')
|
|
||||||
process.wait()
|
process.wait()
|
||||||
# process.wait()
|
|
||||||
# Select "3. English" as the mnemonic language.
|
|
||||||
# p.communicate(input='3'.encode('utf-8'))
|
|
||||||
# Input the mnemonic.
|
|
||||||
# p.communicate(input=TEST_MNEMONIC.encode('utf-8'))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test(network):
|
def test_network(network):
|
||||||
|
sdc_generate(network, first_index=0, count=1)
|
||||||
|
sdc_generate(network, first_index=0, count=2)
|
||||||
|
sdc_generate(network, first_index=0, count=3)
|
||||||
|
sdc_generate(network, first_index=12, count=1)
|
||||||
|
sdc_generate(network, first_index=99, count=2)
|
||||||
|
sdc_generate(network, first_index=1024, count=3)
|
||||||
|
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
sdc_generate(network, 0, 2)
|
test_network("mainnet")
|
||||||
# cleanup()
|
test_network("prater")
|
||||||
|
cleanup()
|
||||||
|
|
||||||
test("mainnet")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user