diff --git a/nucypher/blockchain/eth/clients.py b/nucypher/blockchain/eth/clients.py index 578223592..3bc0c13b7 100644 --- a/nucypher/blockchain/eth/clients.py +++ b/nucypher/blockchain/eth/clients.py @@ -350,8 +350,8 @@ class NuCypherGethDevProcess(NuCypherGethProcess): def start(self, timeout: int = 30, extra_delay: int = 1): self.log.info("STARTING GETH DEV NOW") BaseGethProcess.start(self) # <--- START GETH + time.sleep(extra_delay) # give it a second self.wait_for_ipc(timeout=timeout) - time.sleep(extra_delay) class NuCypherGethDevnetProcess(NuCypherGethProcess): diff --git a/tests/blockchain/eth/interfaces/test_clients.py b/tests/blockchain/eth/interfaces/test_clients.py index 130fc8232..ca781965d 100644 --- a/tests/blockchain/eth/interfaces/test_clients.py +++ b/tests/blockchain/eth/interfaces/test_clients.py @@ -107,11 +107,10 @@ def test_ganache_web3_client(): assert interface.is_local -def test_geth_EIP_191_client_signature_integration(): +def test_geth_EIP_191_client_signature_integration(geth_dev_node): # Start a geth process - geth = NuCypherGethDevProcess() - blockchain = Blockchain.connect(provider_process=geth, sync=False) + blockchain = Blockchain.connect(provider_process=geth_dev_node, sync=False) # Sign a message (RPC) and verify it. etherbase = blockchain.interface.accounts[0] diff --git a/tests/fixtures.py b/tests/fixtures.py index f8886f0fb..f91c37470 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -32,6 +32,7 @@ from umbral.signing import Signer from nucypher.blockchain.economics import TokenEconomics, SlashingEconomics from nucypher.blockchain.eth.agents import NucypherTokenAgent +from nucypher.blockchain.eth.clients import NuCypherGethDevProcess from nucypher.blockchain.eth.deployers import (NucypherTokenDeployer, MinerEscrowDeployer, PolicyManagerDeployer, @@ -438,12 +439,13 @@ def blockchain_ursulas(three_agents, ursula_decentralized_test_config): for ursula_to_learn_about in _ursulas: ursula_to_teach.remember_node(ursula_to_learn_about) + # TODO: #1035 - Move non-staking Ursulas to a new fixture # This one is not going to stake _non_staking_ursula = make_decentralized_ursulas(ursula_config=ursula_decentralized_test_config, ether_addresses=[the_last_ursula], stake=False) - # _ursulas.extend(_non_staking_ursula) + _ursulas.extend(_non_staking_ursula) yield _ursulas @@ -546,3 +548,14 @@ def _mock_ursula_reencrypts(ursula, corrupt_cfrag: bool = False): @pytest.fixture(scope='session') def mock_ursula_reencrypts(): return _mock_ursula_reencrypts + + +@pytest.fixture(scope='session') +def geth_dev_node(): + geth = NuCypherGethDevProcess() + try: + yield geth + finally: + if geth.is_running: + geth.stop() + assert not geth.is_running diff --git a/tests/learning/test_fault_tolerance.py b/tests/learning/test_fault_tolerance.py index 78d8c3222..ccfd0079f 100644 --- a/tests/learning/test_fault_tolerance.py +++ b/tests/learning/test_fault_tolerance.py @@ -48,11 +48,11 @@ def test_emit_warning_upon_new_version(ursula_federated_test_config, caplog): ursula_config=ursula_federated_test_config, quantity=2, know_each_other=True) + learner = lonely_ursula_maker().pop() teacher, new_node = lonely_ursula_maker() new_node.TEACHER_VERSION = learner.LEARNER_VERSION + 1 - learner._current_teacher_node = teacher warnings = [] @@ -62,26 +62,26 @@ def test_emit_warning_upon_new_version(ursula_federated_test_config, caplog): warnings.append(event) globalLogPublisher.addObserver(warning_trapper) - learner.learn_from_teacher_node() assert len(warnings) == 1 - #TODO: Why no assert? Is this in progress? - warnings[0]['log_format'] == learner.unknown_version_message.format(new_node, new_node.TEACHER_VERSION, - learner.LEARNER_VERSION) + assert warnings[0]['log_format'] == learner.unknown_version_message.format(new_node, + new_node.TEACHER_VERSION, + learner.LEARNER_VERSION) # Now let's go a little further: make the version totally unrecognizable. - crazy_bytes_representation = int(learner.LEARNER_VERSION + 1).to_bytes(2, - byteorder="big") + b"totally unintelligible nonsense" + crazy_bytes_representation = int(learner.LEARNER_VERSION + 1).to_bytes(2, byteorder="big") \ + + b"totally unintelligible nonsense" + Response = namedtuple("MockResponse", ("content", "status_code")) response = Response(content=crazy_bytes_representation, status_code=200) learner.network_middleware.get_nodes_via_rest = lambda *args, **kwargs: response learner.learn_from_teacher_node() assert len(warnings) == 2 - # TODO: Why no assert? Is this in progress? - warnings[1]['log_format'] == learner.unknown_version_message.format(new_node, new_node.TEACHER_VERSION, - learner.LEARNER_VERSION) + assert warnings[1]['log_format'] == learner.unknown_version_message.format(new_node, + new_node.TEACHER_VERSION, + learner.LEARNER_VERSION) globalLogPublisher.removeObserver(warning_trapper)