def test_get_rpc_creds(): paccoin_config = paccoin_conf() creds = PaccoinConfig.get_rpc_creds(paccoin_config, 'testnet') for key in ('user', 'password', 'port'): assert key in creds assert creds.get('user') == 'paccoinrpc' assert creds.get('password') == 'EwJeV3fZTyTVozdECF627BkBMnNDwQaVLakG3A4wXYyk' assert creds.get('port') == 29241 paccoin_config = paccoin_conf(rpcpassword='******', rpcport=8000) creds = PaccoinConfig.get_rpc_creds(paccoin_config, 'testnet') for key in ('user', 'password', 'port'): assert key in creds assert creds.get('user') == 'paccoinrpc' assert creds.get('password') == 's00pers33kr1t' assert creds.get('port') == 8000 no_port_specified = re.sub('\nrpcport=.*?\n', '\n', paccoin_conf(), re.M) creds = PaccoinConfig.get_rpc_creds(no_port_specified, 'testnet') for key in ('user', 'password', 'port'): assert key in creds assert creds.get('user') == 'paccoinrpc' assert creds.get('password') == 'EwJeV3fZTyTVozdECF627BkBMnNDwQaVLakG3A4wXYyk' assert creds.get('port') == 19998
def test_paccoind(): config_text = PaccoinConfig.slurp_config_file(config.paccoin_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 = PaccoinConfig.get_rpc_creds(config_text, network) paccoind = PaccoinDaemon(**creds) assert paccoind.rpc_command is not None assert hasattr(paccoind, 'rpc_connection') # Paccoin testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c # test commands without arguments info = paccoind.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 paccoind.rpc_command('getblockhash', 0) == genesis_hash
def test_paccoind(): config_text = PaccoinConfig.slurp_config_file(config.paccoin_conf) network = 'mainnet' is_testnet = False genesis_hash = u'00000354655ff039a51273fe61d3b493bd2897fe6c16f732dbc4ae19f04b789e' for line in config_text.split("\n"): if line.startswith('testnet=1'): network = 'testnet' is_testnet = True genesis_hash = u'00000da63bd9478b655ef6bf1bf76cd9af05202ab68643f9091e049b2b5280ed' creds = PaccoinConfig.get_rpc_creds(config_text, network) paccoind = PaccoinDaemon(**creds) assert paccoind.rpc_command is not None assert hasattr(paccoind, 'rpc_connection') # Paccoin testnet block 0 hash == 00000da63bd9478b655ef6bf1bf76cd9af05202ab68643f9091e049b2b5280ed # test commands without arguments info = paccoind.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 paccoind.rpc_command('getblockhash', 0) == genesis_hash
""" Set up defaults and read sentinel.conf """ import sys import os from paccoin_config import PaccoinConfig 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 = PaccoinConfig.tokenize(sentinel_config_file) sentinel_version = "1.2.0" min_paccoind_proto_version_with_sentinel_ping = 70207 def get_paccoin_conf(): home = os.environ.get('HOME') paccoin_conf = os.path.join(home, ".paccoincore/paccoin.conf") if sys.platform == 'darwin': paccoin_conf = os.path.join( home, "Library/Application Support/PaccoinCore/paccoin.conf") paccoin_conf = sentinel_cfg.get('paccoin_conf', paccoin_conf) return paccoin_conf def get_network(): return sentinel_cfg.get('network', 'mainnet')
def from_paccoin_conf(self, paccoin_dot_conf): from paccoin_config import PaccoinConfig config_text = PaccoinConfig.slurp_config_file(paccoin_dot_conf) creds = PaccoinConfig.get_rpc_creds(config_text, config.network) return self(**creds)