mirror of https://github.com/nucypher/nucypher.git
Switching to maya for most DT things.
parent
391c8a3679
commit
1ea14e514b
|
@ -47,16 +47,16 @@ class Arrangement(BlockchainArrangement):
|
||||||
self.kfrag = kfrag
|
self.kfrag = kfrag
|
||||||
self.ursula = ursula
|
self.ursula = ursula
|
||||||
|
|
||||||
arrangement_delta = datetime.utcnow() - self.expiration
|
arrangement_delta = maya.now() - self.expiration
|
||||||
policy_duration = arrangement_delta.hours // 24
|
policy_duration = arrangement_delta.days
|
||||||
|
|
||||||
super().__init__(author=self.alice.address, miner=self.ursula.address,
|
super().__init__(author=self.alice, miner=ursula,
|
||||||
value=self.deposit, periods=policy_duration,
|
value=self.deposit, periods=policy_duration,
|
||||||
arrangement_id=self._make_arrangement_id())
|
arrangement_id=self._make_arrangement_id())
|
||||||
|
|
||||||
def __bytes__(self):
|
def __bytes__(self):
|
||||||
return bytes(self.alice.stamp) + bytes(
|
return bytes(self.alice.stamp) + bytes(
|
||||||
self.hrac) + self.expiration.isoformat().encode() + bytes(
|
self.hrac) + self.expiration.iso8601().encode() + bytes(
|
||||||
self.deposit)
|
self.deposit)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -82,7 +82,7 @@ class Arrangement(BlockchainArrangement):
|
||||||
# Publish arrangement to blockchain
|
# Publish arrangement to blockchain
|
||||||
# TODO Determine actual gas price here
|
# TODO Determine actual gas price here
|
||||||
# TODO Negotiate the receipt of a KFrag per Ursula
|
# TODO Negotiate the receipt of a KFrag per Ursula
|
||||||
super().publish(gas_price=0)
|
# super().publish(gas_price=0)
|
||||||
|
|
||||||
def encrypt_payload_for_ursula(self):
|
def encrypt_payload_for_ursula(self):
|
||||||
"""
|
"""
|
||||||
|
@ -268,7 +268,7 @@ class Policy(object):
|
||||||
for ursula, arrangement, result in found_ursulas:
|
for ursula, arrangement, result in found_ursulas:
|
||||||
if result.was_accepted: # TODO: Here, we need to assess the result and see if we're actually good to go.
|
if result.was_accepted: # TODO: Here, we need to assess the result and see if we're actually good to go.
|
||||||
kfrag = self.assign_kfrag_to_arrangement(arrangement)
|
kfrag = self.assign_kfrag_to_arrangement(arrangement)
|
||||||
arrangement.activate(kfrag, ursula, result)
|
arrangement.publish(kfrag, ursula, result)
|
||||||
# TODO: What if there weren't enough Arrangements approved to distribute n kfrags? We need to raise NotEnoughQualifiedUrsulas.
|
# TODO: What if there weren't enough Arrangements approved to distribute n kfrags? We need to raise NotEnoughQualifiedUrsulas.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,12 @@ from bytestring_splitter import BytestringSplitter
|
||||||
from tests.utilities import MockNetworkyStuff
|
from tests.utilities import MockNetworkyStuff
|
||||||
from umbral.fragments import KFrag
|
from umbral.fragments import KFrag
|
||||||
from umbral.keys import UmbralPublicKey
|
from umbral.keys import UmbralPublicKey
|
||||||
|
import maya
|
||||||
|
|
||||||
|
|
||||||
def test_grant(alice, bob, ursulas):
|
def test_grant(alice, bob, ursulas):
|
||||||
networky_stuff = MockNetworkyStuff(ursulas)
|
networky_stuff = MockNetworkyStuff(ursulas)
|
||||||
policy_end_datetime = datetime.datetime.now() + datetime.timedelta(days=5)
|
policy_end_datetime = maya.now() + datetime.timedelta(days=5)
|
||||||
n = 5
|
n = 5
|
||||||
uri = b"this_is_the_path_to_which_access_is_being_granted"
|
uri = b"this_is_the_path_to_which_access_is_being_granted"
|
||||||
policy = alice.grant(bob, uri, networky_stuff, m=3, n=n,
|
policy = alice.grant(bob, uri, networky_stuff, m=3, n=n,
|
||||||
|
|
|
@ -13,6 +13,7 @@ from sqlalchemy.engine import create_engine
|
||||||
from nkms.keystore import keystore
|
from nkms.keystore import keystore
|
||||||
from nkms.keystore.db import Base
|
from nkms.keystore.db import Base
|
||||||
from umbral import pre
|
from umbral import pre
|
||||||
|
import maya
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
|
@ -36,7 +37,7 @@ def idle_policy(alice, bob):
|
||||||
def enacted_policy(idle_policy, ursulas):
|
def enacted_policy(idle_policy, ursulas):
|
||||||
# Alice has a policy in mind and knows of enough qualifies Ursulas; she crafts an offer for them.
|
# Alice has a policy in mind and knows of enough qualifies Ursulas; she crafts an offer for them.
|
||||||
deposit = constants.NON_PAYMENT
|
deposit = constants.NON_PAYMENT
|
||||||
contract_end_datetime = datetime.datetime.now() + datetime.timedelta(days=5)
|
contract_end_datetime = maya.now() + datetime.timedelta(days=5)
|
||||||
# contract = Contract(idle_policy.n, deposit, contract_end_datetime)
|
# contract = Contract(idle_policy.n, deposit, contract_end_datetime)
|
||||||
|
|
||||||
networky_stuff = MockNetworkyStuff(ursulas)
|
networky_stuff = MockNetworkyStuff(ursulas)
|
||||||
|
|
Loading…
Reference in New Issue