Esempio n. 1
0
def test_restore(mocked_g_config):
    pathlib.Path(SKALE_DIR).mkdir(parents=True, exist_ok=True)
    result = run_command(backup_node, ['/tmp'])
    backup_path = result.output.replace(
        'Backup archive successfully created: ', '').replace('\n', '')
    with mock.patch('subprocess.run', new=subprocess_run_mock), \
            mock.patch('node_cli.core.node.restore_op'), \
            mock.patch('node_cli.core.resources.get_disk_size', return_value=BIG_DISK_SIZE), \
            mock.patch('node_cli.utils.decorators.is_node_inited', return_value=False):
        result = run_command(restore_node, [backup_path, './tests/test-env'])
        assert result.exit_code == 0
        assert 'Node is restored from backup\n' in result.output  # noqa
Esempio n. 2
0
def test_set_wallet():
    with mock.patch('skale.utils.web3_utils.private_key_to_address',
                    MagicMock(return_value='0xaddress')):
        with mock.patch('core.wallet.write_json'):
            result = run_command(set_wallet,
                                 input=('0xabcdeabcdeabcdeabcdeabc'
                                        'deabcdeabcdeabcd'
                                        'eeabcdeabcdeabcdeabcdeabc'))
            assert result.exit_code == 0
            assert result.output == (
                'Enter private key: \n'
                'Local wallet updated: '
                '0xECaf17d13C3c995284FCDBCc0f2f123eB92f60C6\n'
            )
Esempio n. 3
0
def test_dump(config):
    archive_filename = 'skale-logs-dump-2019-10-08-17:40:00.tar.gz'
    resp_mock = response_mock(requests.codes.ok,
                              headers={
                                  'Content-Disposition':
                                  f'attachment; filename="{archive_filename}"'
                              },
                              raw=BytesIO())
    with mock.patch('requests.get') as req_get_mock:
        req_get_mock.return_value.__enter__.return_value = resp_mock
        result = run_command(dump, ['.'])
        assert result.exit_code == 0
        assert result.output == f'File {archive_filename} downloaded\n'

    if os.path.exists(archive_filename):
        os.remove(archive_filename)
Esempio n. 4
0
def test_dump(backup_func, removed_containers_folder):  # noqa
    result = run_command(dump, [G_CONF_HOME])
    assert result.exit_code == 0
    assert result.output == f'Logs dump created: {TEST_ARCHIVE_PATH}\n'
Esempio n. 5
0
def test_backup():
    pathlib.Path(SKALE_DIR).mkdir(parents=True, exist_ok=True)
    result = run_command(backup_node, ['/tmp'])
    assert result.exit_code == 0
    print(result.output)
    assert 'Backup archive succesfully created ' in result.output
Esempio n. 6
0
def test_version():
    result = run_command(version, [])
    expected = f'SKALE Node CLI version: {info.VERSION}\n'
    assert result.output == expected
    result = run_command(version, ['--short'])
    assert result.output == f'{info.VERSION}\n'
Esempio n. 7
0
def test_validate_abi_empty_file(contract_abi_file_empty):
    result = run_command(abi)
    assert 'Some files do not exist or are incorrect' in result.output
    assert f'{G_CONF_HOME}.skale/contracts_info/manager.json   error    No such file' in result.output # noqa
    assert f'{G_CONF_HOME}.skale/contracts_info/ima.json       ok' in result.output
    assert result.exit_code == 0
Esempio n. 8
0
def test_validate_abi_invalid_file(contract_abi_file_invalid):
    result = run_command(abi)
    assert 'Some files do not exist or are incorrect' in result.output
    assert f'{G_CONF_HOME}.skale/contracts_info/manager.json   error    Failed to load abi file as json' in result.output # noqa
    assert f'{G_CONF_HOME}.skale/contracts_info/ima.json       ok' in result.output
    assert result.exit_code == 0
Esempio n. 9
0
def test_validate_abi(contract_valid_abi_files):
    result = run_command(abi)
    assert result.output == 'All abi files are correct json files!\n'
    assert result.exit_code == 0