Removes PolicyManager shims

pull/2861/head
Kieran Prasch 2022-02-02 11:20:41 -08:00
parent fbf8d0fd1a
commit 9bbcfe399a
3 changed files with 4 additions and 67 deletions

View File

@ -209,23 +209,10 @@ class BlockchainPolicy(Policy):
def _make_reservoir(self, handpicked_addresses: List[ChecksumAddress]):
"""Returns a reservoir of staking nodes to create a decentralized policy."""
# TODO: This is a shim to provide compatibility between SubscriptionManager and StakingEscrow sampling
# Handles the duration unit difference between PolicyManager (periods) and SubscriptionManager (seconds)
# this can be further abstracted away (into payments?) or removed when
# StakingEscrow periods are fully deprecated.
from nucypher.policy.payment import SubscriptionManagerPayment
duration = self.duration
if isinstance(self.publisher.payment_method, SubscriptionManagerPayment):
economics = self.publisher.economics
expiration = maya.MayaDT(self.expiration)
duration = calculate_period_duration(future_time=expiration, seconds_per_period=economics.seconds_per_period)
duration += 1
staker_reservoir = make_decentralized_staker_reservoir(staking_agent=self.publisher.staking_agent,
duration_periods=duration,
include_addresses=handpicked_addresses)
return staker_reservoir
reservoir = make_decentralized_staking_provider_reservoir(application_agent=self.publisher.application_agent,
include_addresses=handpicked_addresses,
pagination_size=self.publisher.application_agent.get_staking_providers_population()) # TODO: Use another size?
return reservoir
class EnactedPolicy:

View File

@ -46,18 +46,6 @@ def check(policy, bob, ursulas):
# TODO: try to decrypt?
def test_decentralized_grant_policy_manager(blockchain_alice, blockchain_bob, blockchain_ursulas):
payment_method = PolicyManagerPayment(provider=TEST_PROVIDER_URI, network=TEMPORARY_DOMAIN)
blockchain_alice.payment_method = payment_method
policy = blockchain_alice.grant(bob=blockchain_bob,
label=os.urandom(16),
threshold=2,
shares=shares,
rate=int(1e18),
expiration=policy_end_datetime)
check(policy=policy, bob=blockchain_bob, ursulas=blockchain_ursulas)
def test_decentralized_grant_subscription_manager(blockchain_alice, blockchain_bob, blockchain_ursulas):
payment_method = SubscriptionManagerPayment(provider=TEST_PROVIDER_URI, network=TEMPORARY_DOMAIN)
blockchain_alice.payment_method = payment_method

View File

@ -28,43 +28,6 @@ from nucypher.policy.payment import PolicyManagerPayment
from tests.constants import TEST_PROVIDER_URI
def test_policy_simple_sinpa_policy_manager(blockchain_ursulas,
blockchain_alice,
blockchain_bob,
agency,
testerchain):
"""
Making a Policy without paying.
"""
# This test only applies to the PolicyManager payment method
blockchain_alice.payment_method = PolicyManagerPayment(provider=TEST_PROVIDER_URI, network=TEMPORARY_DOMAIN)
amonia = Amonia.from_lawful_alice(blockchain_alice)
# Setup the policy details
shares = 3
policy_end_datetime = maya.now() + datetime.timedelta(days=35)
label = b"this_is_the_path_to_which_access_is_being_granted"
bupkiss_policy = amonia.grant_without_paying(bob=blockchain_bob,
label=label,
threshold=2,
shares=shares,
rate=int(1e18), # one ether
expiration=policy_end_datetime)
# Enrico becomes
enrico = Enrico(policy_encrypting_key=bupkiss_policy.public_key)
plaintext = b"A crafty campaign"
message_kit = enrico.encrypt_message(plaintext)
with pytest.raises(Ursula.NotEnoughUrsulas): # Return a more descriptive request error?
blockchain_bob.retrieve_and_decrypt([message_kit],
alice_verifying_key=amonia.stamp.as_umbral_pubkey(),
encrypted_treasure_map=bupkiss_policy.treasure_map)
def test_try_to_post_free_service_by_hacking_enact(blockchain_ursulas,
blockchain_alice,
blockchain_bob,
@ -83,7 +46,6 @@ def test_try_to_post_free_service_by_hacking_enact(blockchain_ursulas,
label=label,
threshold=2,
shares=shares,
rate=int(1e18), # one ether
expiration=policy_end_datetime)
# Enrico becomes