示例#1
0
def test_crowdcoind():
    config_text = CrowdcoinConfig.slurp_config_file(config.crowdcoin_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'0000006f3f7f60bf9fac87e30384c52f7cf7a65bf468f018cab8507e380af8c7'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'000000be89e7ceb515258698012f4d0ac7846980969515fdf2771cda7e0eae68'

    creds = CrowdcoinConfig.get_rpc_creds(config_text, network)
    crowdcoind = CrowdcoinDaemon(**creds)
    assert crowdcoind.rpc_command is not None

    assert hasattr(crowdcoind, 'rpc_connection')

    # Crowdcoin testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = crowdcoind.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 crowdcoind.rpc_command('getblockhash', 0) == genesis_hash
示例#2
0
def test_crowdcoind():
    config_text = CrowdcoinConfig.slurp_config_file(config.crowdcoin_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'000007db550074c6535ce41c2a6043d0afbc86f17f1762b06e2cd65d100f7b5f'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'00000a8d0db898c786060f839e63529700bd00e4708b028206a8a60f391566d8'

    creds = CrowdcoinConfig.get_rpc_creds(config_text, network)
    crowdcoind = CrowdcoinDaemon(**creds)
    assert crowdcoind.rpc_command is not None

    assert hasattr(crowdcoind, 'rpc_connection')

    # Crowdcoin testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = crowdcoind.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 crowdcoind.rpc_command('getblockhash', 0) == genesis_hash