mirror of https://github.com/nucypher/nucypher.git
Fixed test in test_actors.py
parent
48ce0a6428
commit
55e1a254ec
|
@ -152,10 +152,11 @@ class Miner(TokenActor):
|
|||
def collect_staking_reward(self) -> str:
|
||||
"""Withdraw tokens rewarded for staking."""
|
||||
|
||||
token_amount_bytes = self.miner_agent.contract.functions.minerInfo(self.address).call()[0]
|
||||
token_amount = self.blockchain.provider.w3.toInt(token_amount_bytes)
|
||||
token_amount = self.miner_agent.contract.functions.minerInfo(self.address).call()[0]
|
||||
staked_amount = max(self.miner_agent.contract.functions.getLockedTokens(self.address).call(),
|
||||
self.miner_agent.contract.functions.getLockedTokens(self.address, 1).call())
|
||||
|
||||
collection_txhash = self.miner_agent.contract.functions.withdraw(token_amount).transact({'from': self.address})
|
||||
collection_txhash = self.miner_agent.contract.functions.withdraw(token_amount - staked_amount).transact({'from': self.address})
|
||||
|
||||
self.blockchain.wait_for_receipt(collection_txhash)
|
||||
self._transactions.append((datetime.utcnow(), collection_txhash))
|
||||
|
|
|
@ -269,7 +269,7 @@ class MinerEscrowDeployer(ContractDeployer, NucypherMinerConfig):
|
|||
_reward_receipt = self.blockchain.wait_for_receipt(reward_txhash)
|
||||
|
||||
# 4 - Initialize the Miner Escrow contract
|
||||
init_txhash = the_escrow_contract.transact(origin_args).initialize()
|
||||
init_txhash = the_escrow_contract.functions.initialize().transact(origin_args)
|
||||
_init_receipt = self.blockchain.wait_for_receipt(init_txhash)
|
||||
|
||||
# Gather the transaction hashes
|
||||
|
|
|
@ -32,14 +32,14 @@ def test_miner_locking_tokens(chain, miner, mock_miner_agent):
|
|||
assert mock_miner_agent.contract.functions.getLockedTokens(miner.address).call() == mock_miner_agent.min_allowed_locked
|
||||
|
||||
|
||||
def test_miner_collects_staking_reward_tokens(chain, miner, mock_token_agent, mock_miner_agent):
|
||||
def test_miner_collects_staking_reward_tokens(chain, miner, mock_token_agent, mock_miner_agent, mock_policy_agent):
|
||||
|
||||
# Capture the current token balance of the miner
|
||||
initial_balance = miner.token_balance()
|
||||
assert mock_token_agent.get_balance(miner.address) == miner.token_balance()
|
||||
|
||||
# Have other address lock tokens
|
||||
_origin, ursula, *everybody_else = chain.provider.w3.eth.accounts
|
||||
_origin, *everybody_else = chain.provider.w3.eth.accounts
|
||||
mock_miner_agent.spawn_random_miners(addresses=everybody_else)
|
||||
|
||||
# ...wait out the lock period...
|
||||
|
|
|
@ -12,7 +12,6 @@ from geth import LoggingMixin, DevGethProcess
|
|||
from web3 import EthereumTesterProvider, IPCProvider, Web3
|
||||
from web3.middleware import geth_poa_middleware
|
||||
|
||||
from nucypher.blockchain.eth.agents import PolicyAgent
|
||||
from nucypher.blockchain.eth.chains import TheBlockchain, TesterBlockchain
|
||||
from nucypher.blockchain.eth.deployers import PolicyManagerDeployer
|
||||
from nucypher.blockchain.eth.interfaces import Registrar, ContractProvider
|
||||
|
@ -186,8 +185,8 @@ def mock_miner_escrow_deployer(mock_token_agent):
|
|||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def mock_policy_manager_deployer(mock_miner_escrow_deployer):
|
||||
policy_manager_deployer = PolicyManagerDeployer(miner_agent=mock_token_deployer)
|
||||
def mock_policy_manager_deployer(mock_miner_agent):
|
||||
policy_manager_deployer = PolicyManagerDeployer(miner_agent=mock_miner_agent)
|
||||
policy_manager_deployer.arm()
|
||||
policy_manager_deployer.deploy()
|
||||
yield policy_manager_deployer
|
||||
|
@ -215,8 +214,8 @@ def mock_miner_agent(mock_miner_escrow_deployer):
|
|||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def mock_policy_agent(mock_miner_agent, mock_token_agent, mock_token_deployer, mock_miner_escrow_deployer):
|
||||
policy_agent = PolicyAgent(miner_agent=mock_miner_agent)
|
||||
def mock_policy_agent(mock_policy_manager_deployer):
|
||||
policy_agent = mock_policy_manager_deployer.make_agent()
|
||||
|
||||
assert mock_token_deployer._contract.address == policy_agent.contract_address
|
||||
assert mock_policy_manager_deployer._contract.address == policy_agent.contract_address
|
||||
yield policy_agent
|
||||
|
|
Loading…
Reference in New Issue