mirror of https://github.com/nucypher/nucypher.git
This will be the basis of a merge commit in the rebase of these tests. One of them reactivates Vladimir; the other fixes the method for testing the presence of Treasure Maps.
parent
babcd9174e
commit
b199830947
|
@ -238,3 +238,32 @@ def test_alice_refuses_to_make_arrangement_unless_ursula_is_valid(blockchain_ali
|
|||
idle_blockchain_policy.propose_arrangement(network_middleware=blockchain_alice.network_middleware,
|
||||
arrangement=FakeArrangement(),
|
||||
ursula=vladimir)
|
||||
|
||||
|
||||
def test_treasure_map_cannot_be_duplicated(blockchain_ursulas, blockchain_alice, blockchain_bob, agency):
|
||||
|
||||
# Setup the policy details
|
||||
n = 3
|
||||
policy_end_datetime = maya.now() + datetime.timedelta(days=5)
|
||||
label = b"this_is_the_path_to_which_access_is_being_granted"
|
||||
|
||||
# Create the Policy, Granting access to Bob
|
||||
policy = blockchain_alice.grant(bob=blockchain_bob,
|
||||
label=label,
|
||||
m=2,
|
||||
n=n,
|
||||
rate=int(1e18), # one ether
|
||||
expiration=policy_end_datetime)
|
||||
|
||||
u = blockchain_bob.matching_nodes_among(blockchain_alice.known_nodes)[0]
|
||||
saved_map = u.treasure_maps[bytes.fromhex(policy.treasure_map.public_id())]
|
||||
assert saved_map == policy.treasure_map
|
||||
# This Ursula was actually a Vladimir.
|
||||
# Thus, he has access to the (encrypted) TreasureMap and can use its details to
|
||||
# try to store his own fake details.
|
||||
vladimir = Vladimir.from_target_ursula(u)
|
||||
node_on_which_to_store_bad_map = blockchain_ursulas[1]
|
||||
with pytest.raises(vladimir.network_middleware.UnexpectedResponse) as e:
|
||||
vladimir.publish_fraudulent_treasure_map(legit_treasure_map=saved_map,
|
||||
target_node=node_on_which_to_store_bad_map)
|
||||
assert e.value.status == 402
|
||||
|
|
|
@ -40,9 +40,12 @@ def test_alice_sets_treasure_map(enacted_federated_policy, federated_ursulas):
|
|||
"""
|
||||
enacted_federated_policy.publish_treasure_map(network_middleware=MockRestMiddleware())
|
||||
treasure_map_index = bytes.fromhex(enacted_federated_policy.treasure_map.public_id())
|
||||
# TODO: Ensure that this is... an actual... hmm...
|
||||
treasure_map_as_set_on_network = list(federated_ursulas)[0].treasure_maps[treasure_map_index]
|
||||
assert treasure_map_as_set_on_network == enacted_federated_policy.treasure_map
|
||||
found = 0
|
||||
for node in enacted_federated_policy.bob.matching_nodes_among(enacted_federated_policy.alice.known_nodes):
|
||||
treasure_map_as_set_on_network = node.treasure_maps[treasure_map_index]
|
||||
assert treasure_map_as_set_on_network == enacted_federated_policy.treasure_map
|
||||
found += 1
|
||||
assert found
|
||||
|
||||
|
||||
def test_treasure_map_stored_by_ursula_is_the_correct_one_for_bob(federated_alice, federated_bob, federated_ursulas,
|
||||
|
|
Loading…
Reference in New Issue