2018-11-04 19:23:11 +00:00
|
|
|
"""
|
|
|
|
This file is part of nucypher.
|
|
|
|
|
|
|
|
nucypher is free software: you can redistribute it and/or modify
|
2019-03-05 02:50:11 +00:00
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
2018-11-04 19:23:11 +00:00
|
|
|
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
|
2019-03-05 02:50:11 +00:00
|
|
|
GNU Affero General Public License for more details.
|
2018-11-04 19:23:11 +00:00
|
|
|
|
2019-03-05 02:50:11 +00:00
|
|
|
You should have received a copy of the GNU Affero General Public License
|
2018-11-04 19:23:11 +00:00
|
|
|
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
"""
|
2018-10-17 16:33:20 +00:00
|
|
|
import os
|
|
|
|
|
2019-06-06 10:43:53 +00:00
|
|
|
from nucypher.blockchain.eth.agents import StakingEscrowAgent
|
2019-06-24 11:41:03 +00:00
|
|
|
from nucypher.blockchain.eth.deployers import NucypherTokenDeployer, StakingEscrowDeployer, DispatcherDeployer
|
2018-10-17 16:33:20 +00:00
|
|
|
|
|
|
|
|
2019-07-05 15:02:11 +00:00
|
|
|
def test_staking_escrow_deployer_and_agent(session_testerchain):
|
|
|
|
testerchain = session_testerchain
|
2019-06-18 23:59:55 +00:00
|
|
|
origin, *everybody_else = testerchain.client.accounts
|
2018-10-17 16:33:20 +00:00
|
|
|
|
|
|
|
# The big day...
|
|
|
|
token_deployer = NucypherTokenDeployer(blockchain=testerchain, deployer_address=origin)
|
|
|
|
token_deployer.deploy()
|
|
|
|
|
2019-06-24 11:41:03 +00:00
|
|
|
secret_hash = os.urandom(DispatcherDeployer.DISPATCHER_SECRET_LENGTH)
|
2019-05-29 14:15:18 +00:00
|
|
|
deployer = StakingEscrowDeployer(blockchain=testerchain,
|
2019-06-24 11:41:03 +00:00
|
|
|
deployer_address=origin)
|
2019-07-16 19:05:24 +00:00
|
|
|
deployment_receipts = deployer.deploy(secret_hash=secret_hash)
|
2018-10-17 16:33:20 +00:00
|
|
|
|
2019-07-16 19:05:24 +00:00
|
|
|
assert len(deployment_receipts) == 4
|
2019-06-24 11:41:03 +00:00
|
|
|
|
2019-07-16 19:05:24 +00:00
|
|
|
for title, receipt in deployment_receipts.items():
|
|
|
|
assert receipt['status'] == 1
|
2018-10-17 16:33:20 +00:00
|
|
|
|
2019-06-24 11:41:03 +00:00
|
|
|
# Create a StakingEscrowAgent instance
|
2019-05-29 14:15:18 +00:00
|
|
|
staking_agent = deployer.make_agent()
|
2018-10-17 16:33:20 +00:00
|
|
|
|
2019-06-24 11:41:03 +00:00
|
|
|
# TODO: #1102 - Check that token contract address and staking parameters are correct
|
2018-10-17 16:33:20 +00:00
|
|
|
|
2019-06-24 11:41:03 +00:00
|
|
|
# Retrieve the StakingEscrowAgent singleton
|
2019-06-06 10:43:53 +00:00
|
|
|
same_staking_agent = StakingEscrowAgent()
|
2019-06-24 11:41:03 +00:00
|
|
|
assert staking_agent == same_staking_agent
|
2018-10-17 16:33:20 +00:00
|
|
|
|
|
|
|
# Compare the contract address for equality
|
2019-05-29 14:15:18 +00:00
|
|
|
assert staking_agent.contract_address == same_staking_agent.contract_address
|
2018-10-17 16:33:20 +00:00
|
|
|
|
2019-06-17 21:10:19 +00:00
|
|
|
testerchain.registry.clear()
|