Skip to content

Commit

Permalink
Add script and test
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed May 12, 2020
1 parent ecdf73b commit f3cde09
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
27 changes: 27 additions & 0 deletions deposit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

case "$(uname -s)" in

Darwin)
echo 'Mac OS X'
python3 -m pip install -r requirements.txt
python3 setup.py install
python3 ./eth2deposit/deposit.py "$@"
;;

Linux)
echo 'Linux'
python3 -m pip install -r requirements.txt
python3 setup.py install
python3 ./eth2deposit/deposit.py "$@"
;;

CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo 'MS Windows'
;;

*)
echo 'Other OS'
;;

esac
7 changes: 5 additions & 2 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
-r requirements.txt

# Testing
pytest==5.3.5 \
--hash=sha256:ff615c761e25eb25df19edddc0b970302d2a9091fbce0e7213298d85fb61fef6
pytest==5.4.2 \
--hash=sha256:95c710d0a72d91c13fae35dce195633c929c3792f54125919847fdcdf7caa0d3 \
--hash=sha256:eb2b5e935f6a019317e455b6da83dd8650ac9ffd2ee73a7b657a30873d67a698
pytest-asyncio==0.12.0 \
--hash=sha256:475bd2f3dc0bc11d2463656b3cbaafdbec5a47b47508ea0b329ee693040eebd2
flake8==3.7.9 \
--hash=sha256:49356e766643ad15072a789a20915d3c91dc89fd313ccd71802303fd67e4deca
mypy==0.761 \
Expand Down
30 changes: 30 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import asyncio
import os

import pytest

from click.testing import CliRunner

from eth2deposit import deposit
Expand Down Expand Up @@ -36,3 +39,30 @@ def get_mnemonic(language, words_path, entropy=None):
os.remove(os.path.join(validator_keys_folder_path, key_file_name))
os.rmdir(validator_keys_folder_path)
os.rmdir(my_folder_path)


@pytest.mark.asyncio
async def test_script():
cmd = "./deposit.sh --num_validators 1 --mnemonic_language english --password MyPassword"
proc = await asyncio.create_subprocess_shell(
cmd,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
)

seed_phrase = ''
parsing = False
async for out in proc.stdout:
output = out.decode('utf-8').rstrip()
if output.startswith("This is your seed phrase."):
parsing = True
elif output.startswith("Please type your mnemonic"):
parsing = False
elif parsing:
seed_phrase += output
if len(seed_phrase) > 0:
encoded_phrase = seed_phrase.encode()
proc.stdin.write(encoded_phrase)
proc.stdin.write(b'\n')

assert len(seed_phrase) > 0

0 comments on commit f3cde09

Please sign in to comment.