def test_get_batch_status_with_invalid_node_url(): """ Case: get a batch status by its identifier by passing an invalid node URL. Expect: the following node URL is invalid error message. """ invalid_node_url = 'domainwithoutextention' runner = CliRunner() result = runner.invoke(cli, [ 'batch', 'get-status', '--id', BATCH_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE, '--node-url', invalid_node_url, ]) expected_error = { 'errors': { 'node_url': [ f'The following node URL `{invalid_node_url}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_batches_node_url_with_protocol(node_url_with_protocol): """ Case: get a list of batches by passing node URL with an explicit protocol. Expect: the following node URL contains the protocol error message. """ runner = CliRunner() result = runner.invoke(cli, [ 'batch', 'get-list', '--ids', COMMITTED_BATCH_IDENTIFIER, '--node-url', node_url_with_protocol, ]) expected_error = { 'errors': { 'node_url': [ f'Pass the following node URL `{node_url_with_protocol}` without protocol (http, https, etc.).', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_public_keys_node_url_with_protocol(node_url_with_protocol): """ Case: get a list of the addresses of the public keys by passing node URL with an explicit protocol. Expect: the following node URL contains a protocol error message. """ runner = CliRunner() result = runner.invoke(cli, [ 'public-key', 'get-list', '--address', DEV_CONSENSUS_GENESIS_ACCOUNT_ADDRESS, '--node-url', node_url_with_protocol, ]) expected_error = { 'errors': { 'node_url': [ f'Pass the following node URL `{node_url_with_protocol}` without protocol (http, https, etc.).', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_batches_with_invalid_ids(): """ Case: get a list of batches by invalid identifiers. Expect: the following identifier is invalid error message. """ invalid_id = '6f200' batch_ids = '6f200995e766da7218ec2a3d0aeabbe1151128063cdf4e954cd08390a879b28e' \ '085a06f8708d2e6bb34f6501e8ddc981f0353627c1d4f90c80a656a8090c8751, ' \ f'{invalid_id}' runner = CliRunner() result = runner.invoke(cli, [ 'batch', 'get-list', '--ids', batch_ids, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { 'ids': [ f'The following identifier `{invalid_id}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output
def test_get_batches_with_negative_limit(): """ Case: get a list of batches limiting by a negative number. Expect: limit must be greater than 0 error message. """ invalid_limit = -33 runner = CliRunner() result = runner.invoke(cli, [ 'batch', 'get-list', '--limit', invalid_limit, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { 'limit': [ 'Limit must be greater than 0.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output
def test_get_blocks_invalid_head(): """ Case: get a list of blocks by invalid head identifier. Expect: the following identifiers are not a valid error message. """ invalid_head = 'fe56a16dab009cc96e7125c647b6c71eb1063818cf8dece283b125423ecb184f' runner = CliRunner() result = runner.invoke(cli, [ 'block', 'get-list', '--head', invalid_head, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { 'head': [ f'The following block identifier `{invalid_head}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output
def test_get_public_key_info_node_url_with_protocol(node_url_with_protocol): """ Case: get information about public key by passing node URL with an explicit protocol. Expect: the following node URL contains a protocol error message. """ runner = CliRunner() result = runner.invoke(cli, [ 'public-key', 'get-list', '--address', PUBLIC_KEY_ADDRESS_PRESENTED_ON_THE_TEST_NODE, '--node-url', node_url_with_protocol, ]) expected_error = { 'errors': { 'node_url': [ f'Pass the following node URL `{node_url_with_protocol}` without protocol (http, https, etc.).', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_batch_with_invalid_id(): """ Case: get a batch by its invalid identifier. Expect: the following identifier is invalid error message. """ invalid_batch_id = 'abcefg' runner = CliRunner() result = runner.invoke(cli, [ 'batch', 'get', '--id', invalid_batch_id, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { 'id': [ f'The following identifier `{invalid_batch_id}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output
def test_get_states_with_invalid_limit(): """ Case: get a list of states by its invalid limit. Expect: the following limit is invalid error message. """ invalid_limit = '-3' runner = CliRunner() result = runner.invoke(cli, [ 'state', 'get-list', '--limit', invalid_limit, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { 'limit': [ 'Limit must be greater than 0.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output
def test_generate_names_list_with_invalid_numbers_probabilities(): """ Case: generate random eos list of names with invalid `numbers probabilities`. Expect: eos names are returned. """ invalid_numbers_probabilities = [-1, 2] runner = CliRunner() for invalid_numbers_probability in invalid_numbers_probabilities: result = runner.invoke(cli, [ 'generate', 'names_list', '--num', NUMBER_OF_GENERATED_NAMES, '--numbers-probabilities', invalid_numbers_probability, ]) expected_error = { "numbers_probabilities": [ "Numbers probabilities must be between 0 and 1.", ], } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_batch_node_url_with_protocol(node_url_with_protocol): """ Case: get a batch by its identifier by passing node URL with an explicit protocol. Expect: the following node URL contains a protocol error message. """ runner = CliRunner() result = runner.invoke(cli, [ 'batch', 'get', '--id', BATCH_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE, '--node-url', node_url_with_protocol, ]) expected_error = { 'errors': { 'node_url': [ f'Pass the following node URL `{node_url_with_protocol}` without protocol (http, https, etc.).', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_information_invalid_address(): """ Case: get information about the node account by invalid address. Expect: the following address is not valid error message. """ invalid_address = '1168290a2cbbce30382d9420fd5f8b0ec75e953e5c695365b1c22862dce713fa1e48zz' runner = CliRunner() result = runner.invoke(cli, [ 'node-account', 'get', '--address', invalid_address, '--node-url', DEV_CONSENSUS_GENESIS_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error = { 'errors': { 'address': [ f'The following address `{invalid_address}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_information_node_url_with_protocol(node_url_with_protocol): """ Case: get information about the node account by passing the node URL with an explicit protocol. Expect: the following node URL contains the protocol error message. """ runner = CliRunner() result = runner.invoke(cli, [ 'node-account', 'get', '--address', DEV_CONSENSUS_GENESIS_NODE_ACCOUNT_ADDRESS, '--node-url', node_url_with_protocol, ]) expected_error = { 'errors': { 'node_url': [ f'Pass the following node URL `{node_url_with_protocol}` without protocol (http, https, etc.).', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_node_peers_invalid_node_url(): """ Case: get the node's peers by passing an invalid node URL. Expect: the following node URL is invalid error message. """ invalid_node_url = 'domainwithoutextention' runner = CliRunner() result = runner.invoke(cli, [ 'node', 'get-peers', '--node-url', invalid_node_url, ]) expected_error = { 'errors': { 'node_url': [ f'The following node URL `{invalid_node_url}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_transfer_tokens_invalid_address_to(): """ Case: transfer tokens to an invalid address. Expect: the following address to is invalid error message. """ invalid_address_to = '1120076ecf036e857f42129b5830' runner = CliRunner() result = runner.invoke(cli, [ 'account', 'transfer-tokens', '--private-key', DEV_BRANCH_NODE_PRIVATE_KEY_WITH_MONEY, '--address-to', invalid_address_to, '--amount', '1000', '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error = { 'errors': { 'address_to': [ f'The following address `{invalid_address_to}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_states_with_invalid_head(): """ Case: get a list of states by its invalid head. Expect: the following block identifier is invalid error message. """ invalid_head = '8d8cb28c58f7785621b51d220b6a1d39fe5829266495d28eaf0362dc85d7e91c' runner = CliRunner() result = runner.invoke(cli, [ 'state', 'get-list', '--head', invalid_head, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { 'head': [ f'The following block identifier `{invalid_head}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output
def test_get_blocks_with_non_existing_ids(): """ Case: get a list of blocks by non-existing identifiers. Expect: resource not found error message. """ non_existing_blocks_ids = 'fe56a16dab009cc96e7125c647b6c71eb1063818cf8dece283b125423ecb184f' \ '7f1e61802bf66382da904698413f80831031f8a1b29150260c3fa4db537fdfcc, ' \ '56100bf24eed12d2f72fe3c3ccf75fe2f53d87c224d9dda6fb98a1411070b06a' \ '40fcf97fccc61cb9c88442953af6ae50344ad7773f1becc6bae108443c18c5c1' runner = CliRunner() result = runner.invoke(cli, [ 'block', 'get-list', '--ids', non_existing_blocks_ids, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error = { 'errors': 'List of blocks not found.', } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_states_with_invalid_address_start(flag): """ Case: get a list of states by its invalid address and account address starting from. Expect: the following address is invalid error message. """ invalid_address = '044c7db163cf2' runner = CliRunner() result = runner.invoke(cli, [ 'state', 'get-list', '--' + flag, invalid_address, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { flag: [ f'The following address `{invalid_address}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output
def test_get_public_key_info_invalid_node_url(): """ Case: get information about public key by passing an invalid node URL. Expect: the following node URL is invalid error message. """ invalid_node_url = 'domainwithoutextention' runner = CliRunner() result = runner.invoke(cli, [ 'public-key', 'get-info', '--address', PUBLIC_KEY_ADDRESS_PRESENTED_ON_THE_TEST_NODE, '--node-url', invalid_node_url, ]) expected_error = { 'errors': { 'node_url': [ f'The following node URL `{invalid_node_url}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_transfer_tokens_with_insufficient_amount(insufficient_amount): """ Case: transfer tokens to address with the insufficient amount. Expect: amount must be greater than 0 error message. """ runner = CliRunner() result = runner.invoke(cli, [ 'account', 'transfer-tokens', '--private-key', DEV_BRANCH_NODE_PRIVATE_KEY_WITH_MONEY, '--address-to', ADDRESS_PRESENTED_ON_THE_TEST_NODE, '--amount', insufficient_amount, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error = { 'errors': { 'amount': [ f'Amount must be greater than 0.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_public_key_info_invalid_address(): """ Case: get information about public key by invalid address. Expect: the following public key address is not valid error message. """ invalid_address = 'a23be14785e7b073b50e24f72e086675289795b969a895a7f02202404086946e8ddczz' runner = CliRunner() result = runner.invoke(cli, [ 'public-key', 'get-info', '--address', invalid_address, '--node-url', DEV_CONSENSUS_GENESIS_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error = { 'errors': { 'address': [ f'The following public key address `{invalid_address}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_transfer_tokens_invalid_node_url(): """ Case: transfer tokens to address by passing an invalid node URL. Expect: the following node URL is invalid error message. """ invalid_node_url = 'domainwithoutextention' runner = CliRunner() result = runner.invoke(cli, [ 'account', 'transfer-tokens', '--private-key', DEV_BRANCH_NODE_PRIVATE_KEY_WITH_MONEY, '--address-to', ADDRESS_PRESENTED_ON_THE_TEST_NODE, '--amount', '1000', '--node-url', invalid_node_url, ]) expected_error = { 'errors': { 'node_url': [ f'The following node URL `{invalid_node_url}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_batches_with_invalid_start_head_ids(command_flag): """ Case: get a list of batches by invalid batch identifier, block identifier and batch identifier starting from. Expect: the following identifier is invalid error message. """ invalid_id = '044c7db163cf21ab9eafc9b267693e2d732411056c7530e54282946ec47cc180' runner = CliRunner() result = runner.invoke(cli, [ 'batch', 'get-list', command_flag, invalid_id, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { f'{command_flag[2:]}': [ f'The following identifier `{invalid_id}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output
def test_transfer_tokens_node_url_with_protocol(node_url_with_protocol): """ Case: transfer tokens to address by passing node URL with an explicit protocol. Expect: the following node URL contains a protocol error message. """ runner = CliRunner() result = runner.invoke(cli, [ 'account', 'transfer-tokens', '--private-key', DEV_BRANCH_NODE_PRIVATE_KEY_WITH_MONEY, '--address-to', ADDRESS_PRESENTED_ON_THE_TEST_NODE, '--amount', '1000', '--node-url', node_url_with_protocol, ]) expected_error = { 'errors': { 'node_url': [ f'Pass the following node URL `{node_url_with_protocol}` without protocol (http, https, etc.).', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_batches_with_invalid_node_url(): """ Case: get a list of batches by passing an invalid node URL. Expect: the following node URL is invalid error message. """ invalid_node_url = 'domainwithoutextention' runner = CliRunner() result = runner.invoke(cli, [ 'batch', 'get-list', '--ids', COMMITTED_BATCH_IDENTIFIER, '--node-url', invalid_node_url, ]) expected_error = { 'errors': { 'node_url': [ f'The following node URL `{invalid_node_url}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_transfer_tokens_non_existing_node_url(): """ Case: transfer tokens to address by passing the non-existing node URL. Expect: check if node running at the URL error message. """ non_existing_node_url = 'non-existing-node.com' runner = CliRunner() result = runner.invoke(cli, [ 'account', 'transfer-tokens', '--private-key', DEV_BRANCH_NODE_PRIVATE_KEY_WITH_MONEY, '--address-to', ADDRESS_PRESENTED_ON_THE_TEST_NODE, '--amount', '1000', '--node-url', non_existing_node_url, ]) expected_error = { 'errors': f'Please check if your node running at http://{non_existing_node_url}:8080.', } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_public_keys_invalid_node_url(): """ Case: get a list of the addresses of the public keys by passing an invalid node URL. Expect: the following node URL is invalid error message. """ invalid_node_url = 'domainwithoutextention' runner = CliRunner() result = runner.invoke(cli, [ 'public-key', 'get-list', '--address', DEV_CONSENSUS_GENESIS_ACCOUNT_ADDRESS, '--node-url', invalid_node_url, ]) expected_error = { 'errors': { 'node_url': [ f'The following node URL `{invalid_node_url}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_transfer_tokens_invalid_private_key(): """ Case: transfer tokens to address with an invalid private key. Expect: the following private key is invalid error message. """ invalid_private_key = 'b03e31d2f310305eab249133b53b5fb327' runner = CliRunner() result = runner.invoke(cli, [ 'account', 'transfer-tokens', '--private-key', invalid_private_key, '--address-to', ADDRESS_PRESENTED_ON_THE_TEST_NODE, '--amount', '1000', '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error = { 'errors': { 'private_key': [ f'The following private key `{invalid_private_key}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_public_keys_invalid_address(): """ Case: get a list of the addresses of the public keys by invalid address. Expect: the following address is not valid error message. """ invalid_address = '1120076ecf036e857f42129b58303bcf1e03723764a1702cbe98529802aad8514ee3zz' runner = CliRunner() result = runner.invoke(cli, [ 'public-key', 'get-list', '--address', invalid_address, '--node-url', DEV_CONSENSUS_GENESIS_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error = { 'errors': { 'address': [ f'The following address `{invalid_address}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error) in result.output
def test_get_transaction_with_invalid_id(): """ Case: get a transaction by its invalid identifier. Expect: the following identifier is invalid error message. """ invalid_transaction_id = '044c7db163cf21ab9eafc9b267693e2d732411056c7530e54282946ec47cc180dd' \ '201e7be5612a671a7028474ad18e3738e676c17a86b7180fc1aad4c97e38b85bdd' runner = CliRunner() result = runner.invoke(cli, [ 'transaction', 'get', '--id', invalid_transaction_id, '--node-url', DEV_BRANCH_NODE_IP_ADDRESS_FOR_TESTING, ]) expected_error_message = { 'errors': { 'id': [ f'The following identifier `{invalid_transaction_id}` is invalid.', ], }, } assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code assert dict_to_pretty_json(expected_error_message) in result.output