Ejemplo n.º 1
0
def test_get_rpc_creds():
    # dash_config = dash_conf()
    anon_config = anon_conf()
    # creds = DashConfig.get_rpc_creds(dash_config, 'testnet')
    creds = AnonConfig.get_rpc_creds(anon_config, 'testnet')

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

    # dash_config = dash_conf(rpcpassword='******', rpcport=8000)
    anon_config = anon_conf(rpcpassword='******', rpcport=12345)
    # creds = DashConfig.get_rpc_creds(dash_config, 'testnet')
    creds = AnonConfig.get_rpc_creds(anon_config, 'testnet')

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

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

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'anonrpc'
    assert creds.get('password') == 'EwJeV3fZTyTVozdECF627BkBMnNDwQaVLakG3A4wXYyk'
    assert creds.get('port') == 33129
Ejemplo n.º 2
0
    def from_anon_conf(self, anon_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)
        from anon_config import AnonConfig
        config_text = AnonConfig.slurp_config_file(anon_dot_conf)
        creds = AnonConfig.get_rpc_creds(config_text, config.network)

        return self(**creds)
Ejemplo n.º 3
0
def test_anond():
    # config_text = DashConfig.slurp_config_file(config.dash_conf)
    config_text = AnonConfig.slurp_config_file(config.anon_conf)
    print(config_text)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'0642bbe1cadd962f090093b14cd5cc6c4d7e4c1efcce82bf3c0ac7f2fce12806'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'01064a94d893deab5198592c9a950be8fdbb9ca7e9d512803a4872e176e116fb'
            # 0x0575f78ee8dc057deee78ef691876e3be29833aaee5e189bb0459c087451305a
    # creds = DashConfig.get_rpc_creds(config_text, network)
    # dashd = DashDaemon(**creds)
    # assert dashd.rpc_command is not None
    creds = AnonConfig.get_rpc_creds(config_text, network)
    anond = AnonDaemon(**creds)
    assert anond.rpc_command is not None

    assert hasattr(anond, 'rpc_connection')

    # Anon testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    # info = dashd.rpc_command('getinfo')
    info = anond.rpc_command('getinfo')
    info_keys = [
        'version',
        'protocolversion',
        'walletversion',
        'balance',
        'blocks',
        'timeoffset',
        'connections',
        'proxy',
        'difficulty',
        'testnet',
        'keypoololdest',
        'keypoolsize',
        'paytxfee',
        'relayfee',
        'errors',
    ]
    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
    assert anond.rpc_command('getblockhash', 0) == genesis_hash
Ejemplo n.º 4
0
def test_anond():
    # config_text = DashConfig.slurp_config_file(config.dash_conf)
    config_text = AnonConfig.slurp_config_file(config.anon_conf)
    print(config_text)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'053a237d7ad7106e341a403286604df55bfe6f301fc9fff03a06f81c8c565b34'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'07d2dd91f13803386aa0c05afd2adfcc6f911c5571a330a1118f6a0b3e0b2073'
            # 0x0575f78ee8dc057deee78ef691876e3be29833aaee5e189bb0459c087451305a
    # creds = DashConfig.get_rpc_creds(config_text, network)
    # dashd = DashDaemon(**creds)
    # assert dashd.rpc_command is not None
    creds = AnonConfig.get_rpc_creds(config_text, network)
    anond = AnonDaemon(**creds)
    assert anond.rpc_command is not None

    assert hasattr(anond, 'rpc_connection')

    # Anon testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    # info = dashd.rpc_command('getinfo')
    info = anond.rpc_command('getinfo')
    info_keys = [
        'version',
        'protocolversion',
        'walletversion',
        'balance',
        'blocks',
        'timeoffset',
        'connections',
        'proxy',
        'difficulty',
        'testnet',
        'keypoololdest',
        'keypoolsize',
        'paytxfee',
        'relayfee',
        'errors',
    ]
    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
    assert anond.rpc_command('getblockhash', 0) == genesis_hash
Ejemplo n.º 5
0
"""
    Set up defaults and read sentinel.conf
"""
import sys
import os
# from dash_config import DashConfig
from anon_config import AnonConfig

default_sentinel_config = os.path.normpath(
    os.path.join(os.path.dirname(__file__), '../sentinel.conf'))
sentinel_config_file = os.environ.get('SENTINEL_CONFIG',
                                      default_sentinel_config)
# sentinel_cfg = DashConfig.tokenize(sentinel_config_file)
sentinel_cfg = AnonConfig.tokenize(sentinel_config_file)
sentinel_version = "1.1.0"
# min_dashd_proto_version_with_sentinel_ping = 70207
min_anond_proto_version_with_sentinel_ping = 200000


# def get_dash_conf():
def get_anon_conf():
    home = os.environ.get('HOME')

    # dash_conf = os.path.join(home, ".dashcore/dash.conf")
    # TEMPORARY UNTIL WE SWITCH OVER TO ANON PATHS
    anon_conf = os.path.join(home, ".anon/anon.conf")
    if sys.platform == 'darwin':
        # dash_conf = os.path.join(home, "Library/Application Support/DashCore/dash.conf")
        anon_conf = os.path.join(home,
                                 "Library/Application Support/Anon/anon.conf")
Ejemplo n.º 6
0
    def from_anon_conf(self, anon_dot_conf):
        from anon_config import AnonConfig
        config_text = AnonConfig.slurp_config_file(anon_dot_conf)
        creds = AnonConfig.get_rpc_creds(config_text, config.network)

        return self(**creds)