Exemplo n.º 1
0
def bitcoin_regtest(docker, request):
    # logging.getLogger().setLevel(logging.DEBUG)
    requested_version = request.config.getoption("--bitcoind-version")
    if docker:
        bitcoind_controller = BitcoindDockerController(
            rpcport=18543, docker_tag=requested_version
        )
    else:
        if os.path.isfile("tests/bitcoin/src/bitcoind"):
            bitcoind_controller = BitcoindPlainController(
                bitcoind_path="tests/bitcoin/src/bitcoind"
            )  # always prefer the self-compiled bitcoind if existing
        else:
            bitcoind_controller = (
                BitcoindPlainController()
            )  # Alternatively take the one on the path for now
    bitcoind_controller.start_bitcoind(cleanup_at_exit=True)
    running_version = bitcoind_controller.version()
    requested_version = request.config.getoption("--bitcoind-version")
    assert (
        running_version != requested_version,
        "Please make sure that the Bitcoind-version (%s) matches with the version in pytest.ini (%s)"
        % (running_version, requested_version),
    )
    return bitcoind_controller
Exemplo n.º 2
0
def bitcoin_regtest(docker):
    #logging.getLogger().setLevel(logging.DEBUG)
    if docker:
        bitcoind_controller = BitcoindDockerController(rpcport=18543)
    else:
        if os.path.isfile('tests/bitcoin/src/bitcoind'):
            bitcoind_controller = BitcoindPlainController(
                bitcoind_path='tests/bitcoin/src/bitcoind'
            )  # always prefer the self-compiled bitcoind if existing
        else:
            bitcoind_controller = BitcoindPlainController(
            )  # Alternatively take the one on the path for now

    bitcoind_controller.start_bitcoind(cleanup_at_exit=True)
    return bitcoind_controller
Exemplo n.º 3
0
def test_bitcoinddocker_running(caplog, docker, request):
    caplog.set_level(logging.INFO)
    caplog.set_level(logging.DEBUG, logger="cryptoadvance.specter")
    requested_version = request.config.getoption("--bitcoind-version")
    if docker:
        my_bitcoind = BitcoindDockerController(
            rpcport=18999, docker_tag=requested_version
        )  # completly different port to not interfere
    else:
        try:
            which("bitcoind")
        except:
            # Skip this test as bitcoind is not available
            # Doesn't make sense to print anything as this won't be shown
            # for passing tests
            return
        if os.path.isfile('tests/bitcoin/src/bitcoind'):
            # copied from conftest.py
            # always prefer the self-compiled bitcoind if existing
            my_bitcoind = BitcoindPlainController(
                bitcoind_path='tests/bitcoin/src/bitcoind')
        else:
            my_bitcoind = BitcoindPlainController(
            )  # Alternatively take the one on the path for now

    rpcconn = my_bitcoind.start_bitcoind(cleanup_at_exit=True)
    requested_version = request.config.getoption("--bitcoind-version")
    assert my_bitcoind.version() == requested_version
    assert rpcconn.get_rpc() != None
    assert rpcconn.get_rpc().ipaddress != None
    rpcconn.get_rpc().getblockchaininfo()
    # you can use the testcoin_faucet:
    random_address = "mruae2834buqxk77oaVpephnA5ZAxNNJ1r"
    my_bitcoind.testcoin_faucet(random_address, amount=25, mine_tx=True)
    my_bitcoind.stop_bitcoind()
Exemplo n.º 4
0
def test_bitcoinddocker_running(caplog, docker, request):
    caplog.set_level(logging.INFO)
    caplog.set_level(logging.DEBUG, logger="cryptoadvance.specter")
    requested_version = request.config.getoption("--bitcoind-version")
    if docker:
        from cryptoadvance.specter.bitcoind import BitcoindDockerController
        my_bitcoind = BitcoindDockerController(
            rpcport=18999, docker_tag=requested_version
        )  # completly different port to not interfere
    else:
        try:
            which("bitcoind")
        except:
            # Skip this test as bitcoind is not available
            # Doesn't make sense to print anything as this won't be shown
            # for passing tests
            return
        from cryptoadvance.specter.bitcoind import BitcoindPlainController
        # This doesn't work if you don't have a bitcoind on the path
        my_bitcoind = BitcoindPlainController(
        )  # completly different port to not interfere
    #assert my_bitcoind.detect_bitcoind_container() == True
    rpcconn = my_bitcoind.start_bitcoind(cleanup_at_exit=True)
    requested_version = request.config.getoption("--bitcoind-version")
    assert my_bitcoind.version() == requested_version
    assert rpcconn.get_cli() != None
    assert rpcconn.get_cli().ipaddress != None
    rpcconn.get_cli().getblockchaininfo()
    # you can use the testcoin_faucet:
    random_address = "mruae2834buqxk77oaVpephnA5ZAxNNJ1r"
    my_bitcoind.testcoin_faucet(random_address, amount=25, mine_tx=True)
    my_bitcoind.stop_bitcoind()