示例#1
0
def federated_ursulas(ursula_federated_test_config):
    if MOCK_KNOWN_URSULAS_CACHE:
        # raise RuntimeError("Ursulas cache was unclear at fixture loading time.  Did you use one of the ursula maker functions without cleaning up?")
        MOCK_KNOWN_URSULAS_CACHE.clear()

    _ursulas = make_federated_ursulas(
        ursula_config=ursula_federated_test_config,
        quantity=NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK)

    # Since we mutate this list in some tests, it's not enough to remember and remove the Ursulas; we have to remember them by port.
    # The same is true of blockchain_ursulas below.
    _ports_to_remove = [ursula.rest_interface.port for ursula in _ursulas]
    yield _ursulas

    for port in _ports_to_remove:
        if port in MOCK_KNOWN_URSULAS_CACHE:
            test_logger.debug(
                f"Removing {port} ({MOCK_KNOWN_URSULAS_CACHE[port]}).")
            del MOCK_KNOWN_URSULAS_CACHE[port]

    for u in _ursulas:
        u.stop()
        u._finalize()

    # Pytest will hold on to this object, need to clear it manually.
    # See https://github.com/pytest-dev/pytest/issues/5642
    _ursulas.clear()
示例#2
0
def blockchain_ursulas(testerchain, stakers, ursula_decentralized_test_config):
    if MOCK_KNOWN_URSULAS_CACHE:
        # TODO: Is this a safe assumption / test behaviour?
        # raise RuntimeError("Ursulas cache was unclear at fixture loading time.  Did you use one of the ursula maker functions without cleaning up?")
        MOCK_KNOWN_URSULAS_CACHE.clear()

    _ursulas = make_decentralized_ursulas(
        ursula_config=ursula_decentralized_test_config,
        stakers_addresses=testerchain.stakers_accounts,
        workers_addresses=testerchain.ursulas_accounts)
    for u in _ursulas:
        u.synchronous_query_timeout = .01  # We expect to never have to wait for content that is actually on-chain during tests.
    testerchain.time_travel(periods=1)

    # Bootstrap the network
    for ursula_to_teach in _ursulas:
        for ursula_to_learn_about in _ursulas:
            # FIXME #2588: FleetSensor should not own fully-functional Ursulas.
            # It only needs to see whatever public info we can normally get via REST.
            # Also sharing mutable Ursulas like that can lead to unpredictable results.
            ursula_to_teach.remember_node(ursula_to_learn_about)

    _ports_to_remove = [ursula.rest_interface.port for ursula in _ursulas]
    yield _ursulas

    for port in _ports_to_remove:
        del MOCK_KNOWN_URSULAS_CACHE[port]

    for u in _ursulas:
        u.stop()
        u._finalize()

    # Pytest will hold on to this object, need to clear it manually.
    # See https://github.com/pytest-dev/pytest/issues/5642
    _ursulas.clear()
示例#3
0
def blockchain_ursulas(testerchain, stakers, ursula_decentralized_test_config):
    if MOCK_KNOWN_URSULAS_CACHE:
        # TODO: Is this a safe assumption / test behaviour?
        # raise RuntimeError("Ursulas cache was unclear at fixture loading time.  Did you use one of the ursula maker functions without cleaning up?")
        MOCK_KNOWN_URSULAS_CACHE.clear()

    _ursulas = make_decentralized_ursulas(
        ursula_config=ursula_decentralized_test_config,
        stakers_addresses=testerchain.stakers_accounts,
        workers_addresses=testerchain.ursulas_accounts,
        commit_now=True)
    for u in _ursulas:
        u.synchronous_query_timeout = .01  # We expect to never have to wait for content that is actually on-chain during tests.
    testerchain.time_travel(periods=1)

    # Bootstrap the network
    for ursula_to_teach in _ursulas:
        for ursula_to_learn_about in _ursulas:
            ursula_to_teach.remember_node(ursula_to_learn_about)

    _ports_to_remove = [ursula.rest_interface.port for ursula in _ursulas]
    yield _ursulas

    for port in _ports_to_remove:
        del MOCK_KNOWN_URSULAS_CACHE[port]

    for u in _ursulas:
        u.stop()
        u._finalize()

    # Pytest will hold on to this object, need to clear it manually.
    # See https://github.com/pytest-dev/pytest/issues/5642
    _ursulas.clear()