mirror of https://github.com/nucypher/nucypher.git
Handle geth --dev process as a fixture to stop when finished. Additional test bug fixes, found missing assertions.
parent
f9d9346c0f
commit
e74ba944f8
|
@ -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):
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue