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, )
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
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
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
def test_get_pfs_info_success(): json_data = { "price_info": 0, "network_info": { "chain_id": 1, "registry_address": "0xB9633dd9a9a71F22C933bF121d7a22008f66B908", }, "message": "This is your favorite pathfinding service", "operator": "John Doe", "version": "0.0.1", } response = Mock() response.configure_mock(status_code=200) response.json = Mock(return_value=json_data) with patched_get_for_succesful_pfs_info(): pathfinding_service_info = get_pfs_info("url") req_registry_address = "0xB9633dd9a9a71F22C933bF121d7a22008f66B908" assert pathfinding_service_info["price_info"] == 0 assert pathfinding_service_info["network_info"]["chain_id"] == 1 assert pathfinding_service_info["network_info"][ "registry_address"] == req_registry_address assert pathfinding_service_info[ "message"] == "This is your favorite pathfinding service" assert pathfinding_service_info["operator"] == "John Doe" assert pathfinding_service_info["version"] == "0.0.1"
def test_get_pfs_info_success(): json_data = { 'price_info': 0, 'network_info': { 'chain_id': 1, 'registry_address': '0xB9633dd9a9a71F22C933bF121d7a22008f66B908', }, 'message': 'This is your favorite pathfinding service', 'operator': 'John Doe', 'version': '0.0.1', } response = Mock() response.configure_mock(status_code=200) response.json = Mock(return_value=json_data) with patched_get_for_succesful_pfs_info(): pathfinding_service_info = get_pfs_info('url') req_registry_address = '0xB9633dd9a9a71F22C933bF121d7a22008f66B908' assert pathfinding_service_info['price_info'] == 0 assert pathfinding_service_info['network_info']['chain_id'] == 1 assert pathfinding_service_info['network_info'][ 'registry_address'] == req_registry_address assert pathfinding_service_info[ 'message'] == 'This is your favorite pathfinding service' assert pathfinding_service_info['operator'] == 'John Doe' assert pathfinding_service_info['version'] == '0.0.1'