mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Add changes to test.py
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
|
|
||||||
NUM_VALIDATORS=3
|
NUM_VALIDATORS=3
|
||||||
TEST_MNEMONIC = "test test test test test test test test test test test waste"
|
TEST_MNEMONIC = "test test test test test test test test test test test waste"
|
||||||
@@ -12,12 +14,18 @@ lh_dir = os.path.join(tmp_dir, "lh")
|
|||||||
lh_json_path = os.path.join(lh_dir, "deposit-data.json")
|
lh_json_path = os.path.join(lh_dir, "deposit-data.json")
|
||||||
lh_wallet_password_path = os.path.join(lh_dir, "wallet.pass")
|
lh_wallet_password_path = os.path.join(lh_dir, "wallet.pass")
|
||||||
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")
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
if os.path.exists(tmp_dir):
|
if os.path.exists(tmp_dir):
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
||||||
os.mkdir(tmp_dir)
|
os.mkdir(tmp_dir)
|
||||||
|
os.mkdir(lh_dir)
|
||||||
|
os.mkdir(sdc_dir)
|
||||||
|
|
||||||
|
setup_sdc()
|
||||||
with open(mnemonic_path, "x") as file:
|
with open(mnemonic_path, "x") as file:
|
||||||
file.write(TEST_MNEMONIC)
|
file.write(TEST_MNEMONIC)
|
||||||
|
|
||||||
@@ -26,6 +34,38 @@ def cleanup():
|
|||||||
shutil.rmtree(tmp_dir)
|
shutil.rmtree(tmp_dir)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_sdc():
|
||||||
|
result = subprocess.run([
|
||||||
|
"git",
|
||||||
|
"clone",
|
||||||
|
"--single-branch",
|
||||||
|
"https://github.com/ethereum/staking-deposit-cli.git",
|
||||||
|
str(sdc_git_dir)
|
||||||
|
])
|
||||||
|
assert(result.returncode == 0)
|
||||||
|
result = subprocess.run([
|
||||||
|
"pip",
|
||||||
|
"install",
|
||||||
|
"-r",
|
||||||
|
"requirements.txt",
|
||||||
|
], cwd=sdc_git_dir)
|
||||||
|
assert(result.returncode == 0)
|
||||||
|
result = subprocess.run([
|
||||||
|
"python",
|
||||||
|
"setup.py",
|
||||||
|
"install",
|
||||||
|
], cwd=sdc_git_dir)
|
||||||
|
assert(result.returncode == 0)
|
||||||
|
|
||||||
|
|
||||||
|
def sdc_generate(network):
|
||||||
|
p = Popen([
|
||||||
|
'/bin/sh',
|
||||||
|
'deposit.sh',
|
||||||
|
], stdin=PIPE, cwd=sdc_git_dir)
|
||||||
|
p.communicate(input=TEST_MNEMONIC.encode('utf-8'))[0]
|
||||||
|
|
||||||
|
|
||||||
def lighthouse_generate(network):
|
def lighthouse_generate(network):
|
||||||
result = subprocess.run([
|
result = subprocess.run([
|
||||||
"lighthouse",
|
"lighthouse",
|
||||||
@@ -68,7 +108,8 @@ def lighthouse_generate(network):
|
|||||||
|
|
||||||
def test(network):
|
def test(network):
|
||||||
setup()
|
setup()
|
||||||
lighthouse_generate(network)
|
sdc_generate(network)
|
||||||
|
#lighthouse_generate(network)
|
||||||
# cleanup()
|
# cleanup()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user