def fleet_of_highperf_mocked_ursulas(ursula_federated_test_config, request): try: quantity = request.param except AttributeError: quantity = 5000 # Bigass fleet by default; that's kinda the point. with GlobalLoggerSettings.pause_all_logging_while(): with mock_secret_source(): with mock_cert_storage, mock_cert_loading, mock_rest_app_creation, mock_cert_generation, mock_remember_node, mock_message_verification: _ursulas = make_federated_ursulas(ursula_config=ursula_federated_test_config, quantity=quantity, know_each_other=False) all_ursulas = {u.checksum_address: u for u in _ursulas} for ursula in _ursulas: ursula.known_nodes._nodes = all_ursulas ursula.known_nodes.checksum = b"This is a fleet state checksum..".hex() return _ursulas
def test_alice_verifies_ursula_just_in_time(fleet_of_highperf_mocked_ursulas, highperf_mocked_alice, highperf_mocked_bob): _umbral_pubkey_from_bytes = UmbralPublicKey.from_bytes def actual_random_key_instead(*args, **kwargs): _previous_bytes = args[0] serial = _previous_bytes[-5:] pubkey = NotAPublicKey(serial=serial) return pubkey def mock_set_policy(id_as_hex): return "" def mock_receive_treasure_map(treasure_map_id): return Response(bytes(), status=202) with NotARestApp.replace_route("receive_treasure_map", mock_receive_treasure_map): with NotARestApp.replace_route("set_policy", mock_set_policy): with patch('umbral.keys.UmbralPublicKey.__eq__', lambda *args, **kwargs: True): with patch('umbral.keys.UmbralPublicKey.from_bytes', new=actual_random_key_instead): with mock_cert_loading, mock_metadata_validation, mock_message_verification: with mock_secret_source(): policy = highperf_mocked_alice.grant( highperf_mocked_bob, b"any label", m=20, n=30, expiration=maya.when('next week'), publish_treasure_map=False) # TODO: Make some assertions about policy. total_verified = sum(node.verified_node for node in highperf_mocked_alice.known_nodes) assert total_verified == 30