Esempio n. 1
0
def test_get_rpc_creds():
    dash_config = dash_conf()
    creds = DashConfig.get_rpc_creds(dash_config, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'rpc_ruxcrypto'
    assert creds.get('password') == 'kuw05sqio7bcm8z96o7redv17xws1lw6xpd1qf33'
    assert creds.get('port') == 23505

    dash_config = dash_conf(
        rpcpassword='******', rpcport=23505)
    creds = DashConfig.get_rpc_creds(dash_config, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'rpc_ruxcrypto'
    assert creds.get('password') == 'kuw05sqio7bcm8z96o7redv17xws1lw6xpd1qf33'
    assert creds.get('port') == 23505

    no_port_specified = re.sub('\nrpcport=.*?\n', '\n', dash_conf(), re.M)
    creds = DashConfig.get_rpc_creds(no_port_specified, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'rpc_ruxcrypto'
    assert creds.get('password') == 'kuw05sqio7bcm8z96o7redv17xws1lw6xpd1qf33'
    assert creds.get('port') == 33505
Esempio n. 2
0
def test_get_rpc_creds():
    dash_config = dash_conf()
    creds = DashConfig.get_rpc_creds(dash_config, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'dashrpc'
    assert creds.get(
        'password') == 'EwJeV3fZTyTVozdECF627BkBMnNDwQaVLakG3A4wXYyk'
    assert creds.get('port') == 29241

    dash_config = dash_conf(rpcpassword='******', rpcport=8000)
    creds = DashConfig.get_rpc_creds(dash_config, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'dashrpc'
    assert creds.get('password') == 's00pers33kr1t'
    assert creds.get('port') == 8000

    no_port_specified = re.sub('\nrpcport=.*?\n', '\n', dash_conf(), re.M)
    creds = DashConfig.get_rpc_creds(no_port_specified, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'dashrpc'
    assert creds.get(
        'password') == 'EwJeV3fZTyTVozdECF627BkBMnNDwQaVLakG3A4wXYyk'
    assert creds.get('port') == 18801
Esempio n. 3
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    creds = DashConfig.get_rpc_creds(config_text, 'testnet')

    dashd = DashDaemon(
        user     = creds.get('user'),
        password = creds.get('password'),
        port     = creds.get('port')
    )
    assert dashd.rpc_command != None

    assert hasattr(dashd, 'rpc_connection') == True

    # Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info  = dashd.rpc_command('getinfo')

    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] == True

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0)   == u'00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c'
Esempio n. 4
0
    def from_dash_conf(self, dash_dot_conf):
        from dash_config import DashConfig
        config_text = DashConfig.slurp_config_file(dash_dot_conf)
        creds = DashConfig.get_rpc_creds(config_text, config.network)

        creds[u'host'] = config.rpc_host

        return self(**creds)
Esempio n. 5
0
    def from_dash_conf(self, dash_dot_conf):
        from dash_config import DashConfig
        config_text = DashConfig.slurp_config_file(dash_dot_conf)
        creds = DashConfig.get_rpc_creds(config_text, config.network)

        return self(user=creds.get('user'),
                    password=creds.get('password'),
                    port=creds.get('port'))
def main():
    # Get dash.conf location and load key values
    config_text = DashConfig.slurp_config_file(config.dash_conf)

    # Get valid addresses and determine networks used (Main and/or Test)
    addresses = load_address_file(config.address_file)
    networks = get_used_networks(addresses)
    print('Addresses found on {} network(s)'.format(networks))

    # Establish connections to used network(s)
    rpc_connections = {}
    for network in networks:
        rpc_params = DashConfig.get_rpc_creds(config_text, network)
        rpc_connections[network] = RPCHost(rpc_params['user'],
                                           rpc_params['password'],
                                           rpc_params['port'])

    print(rpc_connections)

    poll_addresses(rpc_connections, addresses)
Esempio n. 7
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c'

    creds = DashConfig.get_rpc_creds(config_text, network)
    dashd = DashDaemon(**creds)
    assert dashd.rpc_command is not None

    assert hasattr(dashd, 'rpc_connection')

    # Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = dashd.rpc_command('getinfo')
    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] is is_testnet

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0) == genesis_hash
Esempio n. 8
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'000001f47616c621df9a832559b9e562176656bc5d7e753018983ad8c0b2d284'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'0000095981c16c629ffafa06d096d686486a7698d9ba14db7dfa72fd4a6a36de'

    creds = DashConfig.get_rpc_creds(config_text, network)
    dashd = DashDaemon(**creds)
    assert dashd.rpc_command is not None

    assert hasattr(dashd, 'rpc_connection')

    # Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = dashd.rpc_command('getinfo')
    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] is is_testnet

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0) == genesis_hash
Esempio n. 9
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'00000ee6635b617e6b850ba638411c956bc5e0b977c2aa466a2116b4b767599c'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'000004d72c95dada076575d05dddfb8be794c5ff8e6fa983e18b509995a03740'

    creds = DashConfig.get_rpc_creds(config_text, network)
    dashd = DashDaemon(**creds)
    assert dashd.rpc_command is not None

    assert hasattr(dashd, 'rpc_connection')

    # LUSO testnet block 0 hash == 000004d72c95dada076575d05dddfb8be794c5ff8e6fa983e18b509995a03740
    # test commands without arguments
    info = dashd.rpc_command('getinfo')
    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] is is_testnet

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0) == genesis_hash
Esempio n. 10
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'00000c63f5826a523923939a5adf28657c2a6b76764f1af99bb39437006489d3'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'00000341adf1dd4375bef8ff8059b4268fe0282d8a66f8cf5419bd6b13fbb77b'

    creds = DashConfig.get_rpc_creds(config_text, network)
    dashd = DashDaemon(**creds)
    assert dashd.rpc_command is not None

    assert hasattr(dashd, 'rpc_connection')

    # Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = dashd.rpc_command('getinfo')
    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] is is_testnet

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0) == genesis_hash
Esempio n. 11
0
 def from_dash_conf(self, dash_dot_conf):
     from dash_config import DashConfig
     config = DashConfig(DashConfig.get_default_dash_conf())
     creds = config.get_rpc_creds()
     return self(**creds)