mirror of https://github.com/nucypher/nucypher.git
Alice script properly sends a Contract and then, subsequently, sends a KFrag.
parent
8520dda1d6
commit
12f7990a09
|
@ -19,13 +19,15 @@ class SandboxNetworkyStuff(NetworkyStuff):
|
|||
def find_ursula(self, contract=None):
|
||||
ursula = Ursula.as_discovered_on_network(None, None, pubkey_sig_bytes=bytes(URSULA.seal),
|
||||
rest_address="localhost", rest_port=3500)
|
||||
response = ursula.consider_contract(contract) # TODO: This needs to be a REST call.
|
||||
response = requests.post("http://localhost:3500/consider_contract", bytes(contract))
|
||||
response.was_accepted = True
|
||||
return ursula, response
|
||||
|
||||
def enact_policy(self, ursula, hrac, payload):
|
||||
response = requests.post('http://{}:{}/kFrag/{}'.format(ursula.rest_address, ursula.rest_port, hrac.hex()), payload)
|
||||
return True, ursula.interface_dht_key() # TODO: Something useful here and it's probably ready to go down into NetworkyStuff.
|
||||
# TODO: Something useful here and it's probably ready to go down into NetworkyStuff.
|
||||
return response.status_code == 200
|
||||
|
||||
|
||||
networky_stuff = SandboxNetworkyStuff()
|
||||
|
||||
|
|
|
@ -454,7 +454,7 @@ class Ursula(Character):
|
|||
return self.server.listen(port, interface)
|
||||
|
||||
def dht_interface_info(self):
|
||||
return self.port, self.interface, self.dht_ttl
|
||||
return self.dht_port, self.dht_interface, self.dht_ttl
|
||||
|
||||
def interface_dht_key(self):
|
||||
return self.hash(self.seal + self.interface_hrac())
|
||||
|
@ -499,8 +499,7 @@ class Ursula(Character):
|
|||
self._contracts[contract.hrac] = contract_to_store
|
||||
|
||||
# TODO: Make the rest of this logic actually work - do something here to decide if this Contract is worth accepting.
|
||||
from tests.utilities import MockContractResponse
|
||||
return Response(bytes(MockContractResponse()), content_type="application/octet-stream")
|
||||
return Response(b"This will eventually be an actual acceptance of the contract.", content_type="application/octet-stream")
|
||||
|
||||
def set_policy(self, hrac_as_hex, request: http.Request):
|
||||
"""
|
||||
|
|
|
@ -70,7 +70,6 @@ class MockNetworkyStuff(NetworkyStuff):
|
|||
except StopIteration:
|
||||
raise self.NotEnoughQualifiedUrsulas
|
||||
mock_client = TestClient(ursula.rest_app)
|
||||
# contract_response = ursula.consider_contract(contract)
|
||||
response = mock_client.post("http://localhost/consider_contract", bytes(contract))
|
||||
return ursula, MockContractResponse()
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue