diff --git a/cli.py b/cli.py new file mode 100755 index 0000000..8841b5b --- /dev/null +++ b/cli.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import uuid +import sys + +import click + +from jobcoin import jobcoin + + +@click.command() +def main(args=None): + print('Welcome to the Jobcoin mixer!\n') + while True: + addresses = click.prompt( + 'Please enter a comma-separated list of new, unused Jobcoin ' + 'addresses where your mixed Jobcoins will be sent.', + prompt_suffix='\n[blank to quit] > ', + default='', + show_default=False) + if addresses.strip() == '': + sys.exit(0) + deposit_address = uuid.uuid4().hex + click.echo( + '\nYou may now send Jobcoins to address {deposit_address}. They ' + 'will be mixed and sent to your destination addresses.\n' + .format(deposit_address=deposit_address)) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/jobcoin/README.md b/jobcoin/README.md new file mode 100644 index 0000000..e69de29 diff --git a/jobcoin/__init__.py b/jobcoin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jobcoin/config.py b/jobcoin/config.py new file mode 100755 index 0000000..869b1c9 --- /dev/null +++ b/jobcoin/config.py @@ -0,0 +1,4 @@ +# Replace the URL below +API_BASE_URL = 'http://jobcoin.gemini.com/undaunted-gossip/api' +API_ADDRESS_URL = '{}/addresses'.format(API_BASE_URL) +API_TRANSACTIONS_URL = '{}/transactions'.format(API_BASE_URL) \ No newline at end of file diff --git a/jobcoin/jobcoin.py b/jobcoin/jobcoin.py new file mode 100755 index 0000000..7f09d09 --- /dev/null +++ b/jobcoin/jobcoin.py @@ -0,0 +1,3 @@ +from . import config + +# Write your Jobcoin API client here. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..dd40714 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +click==7.0 +pytest==6.2.2 +requests==2.20.0 diff --git a/test_jobcoin.py b/test_jobcoin.py new file mode 100755 index 0000000..1fd1c25 --- /dev/null +++ b/test_jobcoin.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +import pytest +import re +from click.testing import CliRunner + + +from jobcoin import config +import cli + + +@pytest.fixture +def response(): + import requests + return requests.get('https://jobcoin.gemini.com/') + + +def test_content(response): + assert 'Hello!' in response.text + + +def test_cli_basic(): + runner = CliRunner() + result = runner.invoke(cli.main) + assert result.exit_code == 0 + assert 'Welcome to the Jobcoin mixer' in result.output + + +def test_cli_creates_address(): + runner = CliRunner() + address_create_output = runner.invoke(cli.main, input='1234,4321').output + output_re = re.compile( + r'You may now send Jobcoins to address [0-9a-zA-Z]{32}. ' + 'They will be mixed and sent to your destination addresses.' + ) + assert output_re.search(address_create_output) is not None