diff --git a/nucypher/blockchain/eth/deployers.py b/nucypher/blockchain/eth/deployers.py index fdee24905..a65c68743 100644 --- a/nucypher/blockchain/eth/deployers.py +++ b/nucypher/blockchain/eth/deployers.py @@ -31,8 +31,8 @@ from nucypher.blockchain.eth.agents import ( NucypherTokenAgent, PolicyManagerAgent, PreallocationEscrowAgent, - AdjudicatorAgent -) + AdjudicatorAgent, + WorkLockAgent) from nucypher.blockchain.eth.constants import DISPATCHER_CONTRACT_NAME from nucypher.blockchain.eth.decorators import validate_secret, validate_checksum_address from nucypher.blockchain.eth.interfaces import BlockchainDeployerInterface, BlockchainInterfaceFactory, \ @@ -1094,7 +1094,7 @@ class WorklockDeployer(BaseContractDeployer): self.refund_rate = refund_rate self.locked_periods = locked_periods - def deploy(self, secret_hash: bytes, gas_limit: int = None) -> Dict[str, str]: + def deploy(self, gas_limit: int = None) -> Dict[str, str]: """ Worklock Constructor Parameters (Ordered) diff --git a/tests/blockchain/eth/entities/agents/test_worklock_agent.py b/tests/blockchain/eth/entities/agents/test_worklock_agent.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/blockchain/eth/entities/deployers/test_worklock_deployer.py b/tests/blockchain/eth/entities/deployers/test_worklock_deployer.py new file mode 100644 index 000000000..541a1bf9b --- /dev/null +++ b/tests/blockchain/eth/entities/deployers/test_worklock_deployer.py @@ -0,0 +1,61 @@ +""" +This file is part of nucypher. + +nucypher is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +nucypher is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with nucypher. If not, see . +""" + + +import pytest +from eth_utils import is_checksum_address + +from nucypher.blockchain.eth.agents import NucypherTokenAgent, WorkLockAgent +from nucypher.blockchain.eth.deployers import NucypherTokenDeployer, WorkLockDeployer +from nucypher.blockchain.eth.interfaces import EthereumContractRegistry + + +def test_token_deployer_and_agent(testerchain, agency, token_economics): + origin = testerchain.etherbase_account + + # Trying to get token from blockchain before it's been published fails + with pytest.raises(EthereumContractRegistry.UnknownContract): + WorkLockAgent(blockchain=testerchain) + + # Generate WorkLock params + # TODO: Move to "economics" class? + now = testerchain.w3.eth.getBlock(block_identifier='latest').timestamp + start_bid_date = now + (60 * 60) # 1 Hour + end_bid_date = start_bid_date + (60 * 60) + deposit_rate = 100 + refund_rate = 200 + locked_periods = 2 * token_economics.minimum_locked_periods + + # Create WorkLock Deployer + deployer = WorkLockDeployer(blockchain=testerchain, + deployer_address=origin, + start_date=start_bid_date, + end_date=end_bid_date, + refund_rate=refund_rate, + deposit_rate=deposit_rate, + locked_periods=locked_periods) + + # Deploy WorkLock + deployment_receipts = deployer.deploy() + assert len(deployment_receipts) == 1 + + # Create a token instance + assert deployer.contract + assert is_checksum_address(deployer.contract_address) + assert deployer.contract.address == deployer.contract_address + + testerchain.registry.clear()