Ejemplo n.º 1
0
def test_setup_proxies_no_service_registry_and_no_pfs_address_but_requesting_pfs(
):
    """
    Test that if pfs routing mode is requested and no address or service registry is given
    then the client exits with an error message
    """

    network_id = 42
    config = {
        "environment_type": Environment.DEVELOPMENT,
        "chain_id": network_id,
        "services": {}
    }
    contracts = {}
    blockchain_service = MockChain(network_id=network_id,
                                   node_address=make_address())

    with pytest.raises(SystemExit):
        with patched_get_for_succesful_pfs_info():
            setup_proxies_or_exit(
                config=config,
                tokennetwork_registry_contract_address=make_address(),
                secret_registry_contract_address=make_address(),
                endpoint_registry_contract_address=make_address(),
                user_deposit_contract_address=make_address(),
                service_registry_contract_address=None,
                blockchain_service=blockchain_service,
                contracts=contracts,
                routing_mode=RoutingMode.PFS,
                pathfinding_service_address=None,
            )
Ejemplo n.º 2
0
def test_setup_proxies_no_service_registry_but_pfs():
    """
    Test that if no service registry is provided but a manual pfs address is given then startup
    still works

    Regression test for https://github.com/raiden-network/raiden/issues/3740
    """

    network_id = 42
    config = {
        "environment_type": Environment.DEVELOPMENT,
        "chain_id": network_id,
        "services": {}
    }
    contracts = {}
    blockchain_service = MockChain(network_id=network_id,
                                   node_address=make_address())

    with patched_get_for_succesful_pfs_info():
        proxies = setup_proxies_or_exit(
            config=config,
            tokennetwork_registry_contract_address=make_address(),
            secret_registry_contract_address=make_address(),
            endpoint_registry_contract_address=make_address(),
            user_deposit_contract_address=make_address(),
            service_registry_contract_address=None,
            blockchain_service=blockchain_service,
            contracts=contracts,
            routing_mode=RoutingMode.PFS,
            pathfinding_service_address="my-pfs",
        )
    assert proxies
Ejemplo n.º 3
0
def test_setup_proxies_all_addresses_are_known(routing_mode):
    """
    Test that startup for proxies works fine if all addresses are given and routing is basic
    """

    network_id = 42
    config = {
        "environment_type": Environment.DEVELOPMENT,
        "chain_id": network_id,
        "services": {}
    }
    contracts = setup_contracts_or_exit(config, network_id)
    blockchain_service = MockChain(network_id=network_id,
                                   node_address=make_address())

    with patched_get_for_succesful_pfs_info():
        proxies = setup_proxies_or_exit(
            config=config,
            tokennetwork_registry_contract_address=None,
            secret_registry_contract_address=None,
            endpoint_registry_contract_address=None,
            user_deposit_contract_address=None,
            service_registry_contract_address=None,
            blockchain_service=blockchain_service,
            contracts=contracts,
            routing_mode=routing_mode,
            pathfinding_service_address="my-pfs",
        )
    assert proxies
    assert proxies.token_network_registry
    assert proxies.secret_registry
    assert proxies.user_deposit
    assert proxies.service_registry
Ejemplo n.º 4
0
def test_setup_proxies_raiden_addresses_are_given():
    """
    Test that startup for proxies works fine if only raiden addresses only are given
    """

    network_id = 42
    config = {
        "environment_type": Environment.DEVELOPMENT,
        "chain_id": network_id,
        "services": {}
    }
    contracts = {}
    blockchain_service = MockChain(network_id=network_id,
                                   node_address=make_address())

    proxies = setup_proxies_or_exit(
        config=config,
        tokennetwork_registry_contract_address=make_address(),
        secret_registry_contract_address=make_address(),
        endpoint_registry_contract_address=make_address(),
        user_deposit_contract_address=None,
        service_registry_contract_address=None,
        blockchain_service=blockchain_service,
        contracts=contracts,
        routing_mode=RoutingMode.BASIC,
        pathfinding_service_address=None,
    )
    assert proxies
    assert proxies.token_network_registry
    assert proxies.secret_registry
    assert not proxies.user_deposit
    assert not proxies.service_registry
Ejemplo n.º 5
0
def test_setup_proxies_all_addresses_are_given(routing_mode):
    """
    Test that startup for proxies works fine if all addresses are given and routing is basic
    """

    network_id = 42
    config = {
        'environment_type': Environment.DEVELOPMENT,
        'chain_id': network_id,
        'services': {},
    }
    contracts = {}
    blockchain_service = MockChain(network_id=network_id,
                                   node_address=make_address())

    with patched_get_for_succesful_pfs_info():
        proxies = setup_proxies_or_exit(
            config=config,
            tokennetwork_registry_contract_address=make_address(),
            secret_registry_contract_address=make_address(),
            endpoint_registry_contract_address=make_address(),
            user_deposit_contract_address=make_address(),
            service_registry_contract_address=make_address(),
            contract_addresses_known=False,
            blockchain_service=blockchain_service,
            contracts=contracts,
            routing_mode=routing_mode,
            pathfinding_service_address='my-pfs',
            pathfinding_eth_address=make_checksum_address(),
        )
    assert proxies
    assert proxies.token_network_registry
    assert proxies.secret_registry
    assert proxies.user_deposit
    assert proxies.service_registry
Ejemplo n.º 6
0
def test_setup_udp_or_exit_insufficient_balance():
    network_id = 42
    config = deepcopy(App.DEFAULT_CONFIG)
    config["network_id"] = network_id
    config["environment_type"] = Environment.DEVELOPMENT
    contracts = {}
    our_address = make_address()
    blockchain_service = MockChain(network_id=network_id,
                                   node_address=make_address())
    # we don't have sufficient balance, so client should exit with a message
    blockchain_service.client.balances_mapping[our_address] = 1
    with pytest.raises(SystemExit):
        setup_udp_or_exit(
            config=config,
            blockchain_service=blockchain_service,
            address=our_address,
            contracts=contracts,
            endpoint_registry_contract_address=make_address(),
        )
Ejemplo n.º 7
0
def test_setup_udp_or_exit(raiden_udp_ports):
    network_id = 42
    config = deepcopy(App.DEFAULT_CONFIG)
    config["network_id"] = network_id
    config["environment_type"] = Environment.DEVELOPMENT
    host = "127.0.0.1"
    port = raiden_udp_ports[0]
    config["socket"] = server._udp_socket((host, port))  # pylint: disable=protected-access
    contracts = {}
    our_address = make_address()
    blockchain_service = MockChain(network_id=network_id,
                                   node_address=make_address())
    # set a big fake balance for us, to pass the test of sufficient gas for discovery transaction
    blockchain_service.client.balances_mapping[our_address] = 99999999999999999
    transport, discovery = setup_udp_or_exit(
        config=config,
        blockchain_service=blockchain_service,
        address=our_address,
        contracts=contracts,
        endpoint_registry_contract_address=make_address(),
    )
    assert isinstance(transport, UDPTransport)
    assert discovery