From 9a00a84f4c385d37c1fc4ddfeeb1c6f1da0d13ea Mon Sep 17 00:00:00 2001 From: "Kieran R. Prasch" Date: Wed, 30 Jan 2019 19:14:46 -0800 Subject: [PATCH] Allow beneficiary allocation registry specification to accept an instance or filepath --- nucypher/blockchain/eth/actors.py | 8 ++++++-- tests/blockchain/eth/entities/actors/test_deployer.py | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nucypher/blockchain/eth/actors.py b/nucypher/blockchain/eth/actors.py index 917533d66..8c0359155 100644 --- a/nucypher/blockchain/eth/actors.py +++ b/nucypher/blockchain/eth/actors.py @@ -228,7 +228,8 @@ class Deployer(NucypherTokenActor): def deploy_beneficiary_contracts(self, allocations: List[Dict[str, Union[str, int]]], - allocation_outfile: str = None + allocation_outfile: str = None, + allocation_registry: AllocationRegistry = None, ) -> None: """ @@ -238,7 +239,10 @@ class Deployer(NucypherTokenActor): {'address': '0xabced120', 'amount': 133432, 'duration': 31540000*2}, {'address': '0xf7aefec2', 'amount': 999, 'duration': 31540000*3}] """ - allocation_registry = AllocationRegistry(registry_filepath=allocation_outfile) + if allocation_registry and allocation_outfile: + raise self.ActorError("Pass either allocation registry or allocation_outfile, not both.") + if allocation_registry is None: + allocation_registry = AllocationRegistry(registry_filepath=allocation_outfile) for allocation in allocations: deployer = self.deploy_user_escrow(allocation_registry=allocation_registry) deployer.deliver(value=allocation['amount'], diff --git a/tests/blockchain/eth/entities/actors/test_deployer.py b/tests/blockchain/eth/entities/actors/test_deployer.py index 6facadb4a..9fc8ebc05 100644 --- a/tests/blockchain/eth/entities/actors/test_deployer.py +++ b/tests/blockchain/eth/entities/actors/test_deployer.py @@ -43,7 +43,6 @@ def test_rapid_deployment(): origin, *everyone = blockchain.interface.w3.eth.accounts deployer = Deployer(blockchain=blockchain, - allocation_registry=allocation_registry, deployer_address=origin) deployer_address, *all_yall = deployer.blockchain.interface.w3.eth.accounts @@ -73,4 +72,4 @@ def test_rapid_deployment(): random_allocation = {'address': beneficiary_address, 'amount': amount, 'duration': duration} allocation_data.append(random_allocation) - deployer.deploy_beneficiary_contracts(allocations=allocation_data) + deployer.deploy_beneficiary_contracts(allocations=allocation_data, allocation_registry=allocation_registry)