Esempio n. 1
0
def test_account_balance_command(convex_url, test_account):
    args = Mock()

    args.url = convex_url
    args.name_address = test_account.address

    command = AccountBalanceCommand()
    output = Output()
    command.execute(args, output)
    assert (output.values['balance'])

    args.url = convex_url
    args.name_address = test_account.name

    command = AccountBalanceCommand()
    output = Output()
    command.execute(args, output)
    assert (output.values['balance'])
Esempio n. 2
0
def test_account_name_resolve_command(convex_url, test_account):
    args = Mock()

    args.url = convex_url
    args.name = test_account.name

    command = AccountNameResolveCommand()
    output = Output()
    command.execute(args, output)
    assert (output.values['address'] == test_account.address)
def test_query_command(convex_url):
    args = Mock()

    args.url = convex_url
    args.query = '(address *registry*)'
    args.name_address = None

    command = QueryCommand()
    output = Output()
    command.execute(args, output)
    assert(output.values['value'])
Esempio n. 4
0
def test_account_topup_command(convex_url, test_account):
    args = Mock()

    args.url = convex_url
    args.keywords = test_account.key_pair.export_to_mnemonic
    args.keyfile = None
    args.keytext = None
    args.password = None
    args.name_address = test_account.address

    command = AccountTopupCommand()
    output = Output()
    command.execute(args, output)
    assert (output.values['balance'])
Esempio n. 5
0
def test_account_info_command(convex_url, test_account):
    args = Mock()

    args.url = convex_url
    args.name_address = test_account.address

    command = AccountInfoCommand()
    output = Output()
    command.execute(args, output)
    assert (output.values['balance'])
    assert (output.values['memorySize'])
    assert (output.values['sequence'])
    assert (output.values['type'])

    args.url = convex_url
    args.name_address = test_account.name

    command = AccountInfoCommand()
    output = Output()
    command.execute(args, output)
    assert (output.values['balance'])
    assert (output.values['memorySize'])
    assert (output.values['sequence'])
    assert (output.values['type'])
Esempio n. 6
0
def test_submit_command(convex_url, test_account):
    args = Mock()

    args.url = convex_url
    args.keywords = test_account.key_pair.export_to_mnemonic
    args.keyfile = None
    args.keytext = None
    args.password = None

    args.submit = '(map inc [1 2 3 4 5])'
    args.name_address = test_account.address

    command = SubmitCommand()
    output = Output()
    command.execute(args, output)
    assert(output.values['value'] == [2, 3, 4, 5, 6])
Esempio n. 7
0
def test_account_create_command(convex_url):
    args = Mock()

    args.url = convex_url
    args.password = '******'
    args.keyfile = None
    args.keytext = None
    args.keywords = None
    args.name = None

    command = AccountCreateCommand()
    output = Output()
    command.execute(args, output)
    print(output.values)
    assert (output.values['keyfile'])
    assert (output.values['address'])
    assert (output.values['password'])
Esempio n. 8
0
def test_account_register_command(convex_url, test_account):
    args = Mock()

    args.url = convex_url
    args.keywords = test_account.key_pair.export_to_mnemonic
    args.keyfile = None
    args.keytext = None
    args.password = None
    args.name_address = test_account.address
    args.name = test_account.name
    args.address = test_account.address

    command = AccountNameRegisterCommand()
    output = Output()
    command.execute(args, output)
    assert (output.values['name'] == args.name)
    assert (output.values['address'] == args.address)
Esempio n. 9
0
def convex_tool():
    parser = argparse.ArgumentParser(
        description='Convex Tools',
        formatter_class=argparse.RawTextHelpFormatter
    )

    parser.add_argument(
        '-k',
        '--keyfile',
        nargs='?',
        help='account private key encrypted with password saved in a file, must include the --password parameter.'
    )

    parser.add_argument(
        '--keytext',
        nargs='?',
        help='account private key encrypted with password as a text string, must include the --password parameter.'
    )

    parser.add_argument(
        '-p',
        '--password',
        nargs='?',
        help='password to access the private key enrcypted in a --keyfile or --keytext'
    )

    parser.add_argument(
        '-w',
        '--keywords',
        nargs='?',
        help='account private key as words.'
    )

    parser.add_argument(
        '-d',
        '--debug',
        action='store_true',
        help='Debug mode on or off. Default: False',
    )

    parser.add_argument(
        '-j',
        '--json',
        action='store_true',
        help='Output data as JSON values.'
    )

    parser.add_argument(
        '-u',
        '--url',
        default=DEFAULT_CONVEX_URL,
        help=f'URL of the network node. Default: {DEFAULT_CONVEX_URL}',
    )

    command_parser = parser.add_subparsers(
        title='Convex commands',
        description='Command values',
        help='Convex commands',
        dest='command'
    )

    command_list = [
        AccountCommand(command_parser),
        PeerCommand(command_parser),
        QueryCommand(command_parser),
        SubmitCommand(command_parser)
    ]

    args = parser.parse_args()

    if args.debug:
        logging.basicConfig(level=logging.DEBUG)

    output = Output()

    is_found = False
    for command_item in command_list:
        if command_item.is_command(args.command):
            command_item.execute(args, output)
            is_found = True
            break

    if not is_found:
        parser.print_help()

    output.printout(args.json)