Beispiel #1
0
def test_top_calls_correct_url_with_default_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/accounts/top',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.accounts.top()
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/accounts/top?limit=20'
Beispiel #2
0
def test_get_correct_url_with_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/accounts',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.accounts.get(address='spongebob')
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/accounts?address=spongebob'
Beispiel #3
0
def test_delegates_fee_calls_correct_url():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/accounts/delegates/fee',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.accounts.delegates_fee()
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/accounts/delegates/fee'
Beispiel #4
0
def test_all_unconfirmed_calls_correct_url_with_default_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions/unconfirmed',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.transactions.all_unconfirmed()
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == (
        'http://127.0.0.1:4002/transactions/unconfirmed?limit=20')
Beispiel #5
0
def test_all_calls_correct_url_with_default_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/votes',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.votes.all()
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/votes?limit=20'
Beispiel #6
0
def test_status_calls_correct_url():
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/node/status',
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.node.status()
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == 'http://127.0.0.1:4002/node/status'
Beispiel #7
0
def test_autoconfigure_calls_correct_url():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/loader/autoconfigure',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.loader.autoconfigure()

    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/loader/autoconfigure'
Beispiel #8
0
def test_fee_calls_correct_url():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/blocks/getFee',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.blocks.fee()

    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/blocks/getFee'
Beispiel #9
0
def test_get_calls_correct_url_with_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/blocks/get',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.blocks.get('spongebob')

    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == (
        'http://127.0.0.1:4002/blocks/get?id=spongebob')
Beispiel #10
0
def test_all_unconfirmed_calls_correct_url_with_passed_in_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions/unconfirmed',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.transactions.all_unconfirmed(offset=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/transactions/unconfirmed?')
    assert 'offset=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
Beispiel #11
0
def test_get_calls_correct_url_with_ip():
    ip = '123.4.5.67'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/peers/{}'.format(ip),
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.peers.get(ip)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == 'http://127.0.0.1:4002/peers/123.4.5.67'
Beispiel #12
0
def test_all_calls_correct_url_with_passed_in_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/votes',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.votes.all(page=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/votes?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
Beispiel #13
0
def test_get_calls_correct_url():
    vote_id = '12345'
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/votes/{}'.format(vote_id),
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.votes.get(vote_id)

    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/votes/12345'
Beispiel #14
0
def test_search_calls_correct_url_with_default_params():
    responses.add(
        responses.POST,
        'http://127.0.0.1:4002/wallets/search',
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.wallets.search({'address': 'my-address'})
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == 'http://127.0.0.1:4002/wallets/search?limit=20'
    assert json.loads(responses.calls[0].request.body.decode()) == {'address': 'my-address'}
Beispiel #15
0
def test_all_calls_correct_url_with_passed_in_params():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/blocks',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.blocks.all(limit=69, offset=123)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/blocks?')
    assert 'limit=69' in responses.calls[0].request.url
    assert 'offset=123' in responses.calls[0].request.url
Beispiel #16
0
def test_version_calls_correct_url():
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/peers/version',
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.peers.version()

    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == 'http://127.0.0.1:4002/peers/version'
Beispiel #17
0
def test_blocks_calls_correct_url_with_default_params():
    delegate_id = '12345'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/delegates/{}/blocks'.format(delegate_id),
        json={'success': True},
        status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.delegates.blocks(delegate_id)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == (
        'http://127.0.0.1:4002/delegates/12345/blocks?limit=20')
Beispiel #18
0
def main():

    passphrase = sys.argv[1:0]
    vote = sys.argv[1:1]

    from crypto.transactions.builder.transfer import Transfer
    from crypto.identity.address import address_from_private_key
    from crypto.identity.private_key import PrivateKey
    from crypto.identity.public_key import PublicKey
    from crypto.identity.address import address_from_private_key
    import time
    from crypto.configuration.network import set_custom_network
    from crypto.transactions.builder.transfer import Transfer

    # from tbw import parse_config
    # from util.sql import SnekDB
    # from util.dynamic import Dynamic
    from ark import ArkClient

    client = ArkClient('http://localhost:4003/api')

    from datetime import datetime

    epoch = datetime(2017, 1, 1, 13, 00, 00)
    version = 23
    wif = 130

    work = set_custom_network(epoch, version, wif)

    # userInput

    # passPhrase = "clay harbor enemy utility margin pretty hub comic piece aerobic umbrella acquire"
    phrase = "outside tilt cluster film husband truck install fringe purse door build wire"

    candidate = "ANBkoGqWeTSiaEVgVzSKZd3jS7UWzv9PSo"
    # chooseVoter("Donald Trump")
    print(candidate)

    # priv = PrivateKey.from_passphrase(candidate).to_hex()

    tx = Transfer(recipientId=candidate, amount=50000)
    tx.sign(phrase)

    # print(tx.verify())

    ok = client.transactions.create([tx.transaction.to_dict()])

    pprint(ok)

    print(passphrase)
    print(vote)
Beispiel #19
0
def test_blocks_calls_correct_url_with_passed_in_params():
    delegate_id = '12345'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/delegates/{}/blocks'.format(delegate_id),
        json={'success': True},
        status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.delegates.blocks(delegate_id, page=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/delegates/12345/blocks?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
Beispiel #20
0
def test_transactions_sent_calls_correct_url_with_default_params():
    wallet_id = '12345'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/wallets/{}/transactions/sent'.format(wallet_id),
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.wallets.transactions_sent(wallet_id)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == (
        'http://127.0.0.1:4002/wallets/12345/transactions/sent?limit=20'
    )
Beispiel #21
0
def test_get_calls_correct_url_with_passed_in_params():
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/peers/get',
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v1')
    client.peers.get('127.0.0.1', 1234)

    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/peers/get?')
    assert 'ip=127.0.0.1' in responses.calls[0].request.url
    assert 'port=1234' in responses.calls[0].request.url
Beispiel #22
0
def test_search_calls_correct_url_with_passed_in_params():
    responses.add(
        responses.POST,
        'http://127.0.0.1:4002/wallets/search',
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.wallets.search({'address': 'my-address'}, page=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/wallets/search?')
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
    assert json.loads(responses.calls[0].request.body.decode()) == {'address': 'my-address'}
Beispiel #23
0
def test_create_calls_correct_url_with_data():
    responses.add(responses.POST,
                  'http://127.0.0.1:4002/transactions',
                  json={'success': True},
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.transactions.create([{'random': 'data'}])
    assert len(responses.calls) == 1
    assert responses.calls[
        0].request.url == 'http://127.0.0.1:4002/transactions'
    assert json.loads(responses.calls[0].request.body.decode()) == {
        'transactions': [{
            'random': 'data'
        }]
    }
Beispiel #24
0
def test_transactions_calls_correct_url_with_passed_in_params():
    wallet_id = '12345'
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/wallets/{}/transactions'.format(wallet_id),
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.wallets.transactions(wallet_id, page=5, limit=69)
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/wallets/12345/transactions?'
    )
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
Beispiel #25
0
def test_all_calls_correct_url_with_passed_in_params():
    responses.add(
        responses.GET,
        'http://127.0.0.1:4002/peers',
        json={'success': True},
        status=200
    )

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.peers.all(
        os='a', status='live', port=1337, version='2.0.0', order_by='ip', page=5, limit=69
    )
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/peers?')
    assert 'os=a' in responses.calls[0].request.url
    assert 'status=live' in responses.calls[0].request.url
    assert 'port=1337' in responses.calls[0].request.url
    assert 'version=2.0.0' in responses.calls[0].request.url
    assert 'orderBy=ip' in responses.calls[0].request.url
    assert 'page=5' in responses.calls[0].request.url
    assert 'limit=69' in responses.calls[0].request.url
Beispiel #26
0
def test_transaction_types():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions/types',
                  json={
                      'data': {
                          'TRANSFER': 0,
                          'SECOND_SIGNATURE': 1,
                          'DELEGATE_REGISTRATION': 2,
                          'VOTE': 3,
                          'MULTI_SIGNATURE': 4,
                          'IPFS': 5,
                          'TIMELOCK_TRANSFER': 6,
                          'MULTI_PAYMENT': 7,
                          'DELEGATE_RESIGNATION': 8
                      }
                  },
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.transactions.types()
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/transactions/types')
Beispiel #27
0
def test_transaction_fees():
    responses.add(responses.GET,
                  'http://127.0.0.1:4002/transactions/fees',
                  json={
                      'data': {
                          'dynamic': False,
                          'transfer': 10000000,
                          'secondSignature': 500000000,
                          'delegateRegistration': 2500000000,
                          'vote': 100000000,
                          'multiSignature': 500000000,
                          'ipfs': 0,
                          'timelockTransfer': 0,
                          'multiPayment': 0,
                          'delegateResignation': 0
                      }
                  },
                  status=200)

    client = ArkClient('http://127.0.0.1:4002', api_version='v2')
    client.transactions.fees()
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url.startswith(
        'http://127.0.0.1:4002/transactions/fees')
Beispiel #28
0
def get_client(ip="localhost", api_version='v2'):
    port = network[data['network']]['port']
    return ArkClient('http://{0}:{1}/api/'.format(ip, port), api_version=api_version)