Beispiel #1
0
def test_get_rpc_creds():
    vivo_config = vivo_conf()
    creds = VivoConfig.get_rpc_creds(vivo_config, 'testnet')

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

    vivo_config = vivo_conf(rpcpassword='******', rpcport=8000)
    creds = VivoConfig.get_rpc_creds(vivo_config, 'testnet')

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

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

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'vivorpc'
    assert creds.get(
        'password') == 'EwJeV3fZTyTVozdECF627BkBMnNDwQaVLakG3A4wXYyk'
    assert creds.get('port') == 19998
Beispiel #2
0
def test_vivod():
    config_text = VivoConfig.slurp_config_file(config.vivo_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 = VivoConfig.get_rpc_creds(config_text, network)
    vivod = VivoDaemon(**creds)
    assert vivod.rpc_command is not None

    assert hasattr(vivod, 'rpc_connection')

    # Vivo testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = vivod.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 vivod.rpc_command('getblockhash', 0) == genesis_hash
Beispiel #3
0
"""
    Set up defaults and read sentinel.conf
"""
import sys
import os
from vivo_config import VivoConfig

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 = VivoConfig.tokenize(sentinel_config_file)
sentinel_version = "1.1.0"
min_vivod_proto_version_with_sentinel_ping = 70207

def get_vivo_conf():
    home = os.environ.get('HOME')

    if sys.platform == 'darwin':
        vivo_conf = os.path.join(home, "Library/Application Support/VivoCore/vivo.conf")
    elif sys.platform == 'win32':
        vivo_conf = os.path.join(os.environ['APPDATA'], "VivoCore/Vivo.conf")
    else:
        vivo_conf = os.path.join(home, ".vivocore/vivo.conf")
        vivo_conf = sentinel_cfg.get('vivo_conf', vivo_conf)

    return vivo_conf

def get_network():
    return sentinel_cfg.get('network', 'mainnet')
Beispiel #4
0
    def from_vivo_conf(self, vivo_dot_conf):
        from vivo_config import VivoConfig
        config_text = VivoConfig.slurp_config_file(vivo_dot_conf)
        creds = VivoConfig.get_rpc_creds(config_text, config.network)

        return self(**creds)