mirror of https://github.com/nucypher/nucypher.git
Respond to RFCs in PR #1989
parent
bf6d2ad65f
commit
9b9ddac234
|
@ -29,7 +29,7 @@ from decimal import Decimal
|
|||
from eth_tester.exceptions import TransactionFailed as TestTransactionFailed
|
||||
from eth_utils import to_canonical_address, to_checksum_address
|
||||
from twisted.logger import Logger
|
||||
from typing import Dict, Generator, List, Optional, Tuple
|
||||
from typing import Dict, Iterable, List, Optional, Tuple
|
||||
from web3 import Web3
|
||||
from web3.exceptions import ValidationError
|
||||
|
||||
|
@ -866,7 +866,7 @@ class Staker(NucypherTokenActor):
|
|||
return self.locked_tokens(periods=0)
|
||||
|
||||
@property
|
||||
def active_stakes(self) -> Generator[Stake, None, None]:
|
||||
def active_stakes(self) -> Iterable[Stake]:
|
||||
"""Returns active stakes for this staker."""
|
||||
stakes = (stake for stake in self.stakes if stake.is_active)
|
||||
return stakes
|
||||
|
@ -883,7 +883,7 @@ class Staker(NucypherTokenActor):
|
|||
what constitutes a divisible stake amongst a given iterable of stakes.
|
||||
"""
|
||||
min_divisible_stake_value = self.economics.minimum_allowed_locked * 2
|
||||
result = bool(stake.value >= min_divisible_stake_value)
|
||||
result = stake.value >= min_divisible_stake_value
|
||||
return result
|
||||
|
||||
@property
|
||||
|
|
|
@ -140,7 +140,7 @@ def test_valid_bid(click_runner,
|
|||
assert_successful_transaction_echo(bidder_address=surrogate_bidder.checksum_address, cli_output=result.output)
|
||||
|
||||
# Transactions
|
||||
mock_worklock_agent.assert_no_unexpected_transactions(allowed=[mock_worklock_agent.bid])
|
||||
mock_worklock_agent.assert_only_transactions(allowed=[mock_worklock_agent.bid])
|
||||
mock_worklock_agent.bid.assert_called_with(checksum_address=surrogate_bidder.checksum_address, value=nunits)
|
||||
|
||||
# Calls
|
||||
|
@ -170,7 +170,7 @@ def test_cancel_bid(click_runner,
|
|||
assert_successful_transaction_echo(bidder_address=surrogate_bidder.checksum_address, cli_output=result.output)
|
||||
|
||||
# Transactions
|
||||
mock_worklock_agent.assert_no_unexpected_transactions(allowed=[mock_worklock_agent.cancel_bid])
|
||||
mock_worklock_agent.assert_only_transactions(allowed=[mock_worklock_agent.cancel_bid])
|
||||
mock_worklock_agent.cancel_bid.called_once_with(checksum_address=surrogate_bidder.checksum_address)
|
||||
|
||||
# Calls
|
||||
|
@ -201,7 +201,7 @@ def test_post_initialization(click_runner,
|
|||
assert_successful_transaction_echo(bidder_address=surrogate_bidder.checksum_address, cli_output=result.output)
|
||||
|
||||
# Transactions
|
||||
mock_worklock_agent.assert_no_unexpected_transactions(allowed=mock_worklock_agent.enable_claiming)
|
||||
mock_worklock_agent.assert_only_transactions(allowed=mock_worklock_agent.enable_claiming)
|
||||
mock_worklock_agent.enable_claiming.assert_called_with(hecksum_address=surrogate_bidder.checksum_address)
|
||||
|
||||
|
||||
|
@ -338,7 +338,7 @@ def test_refund(click_runner,
|
|||
assert_successful_transaction_echo(bidder_address=surrogate_bidder.checksum_address, cli_output=result.output)
|
||||
|
||||
# Transactions
|
||||
mock_worklock_agent.assert_no_unexpected_transactions(allowed=[mock_worklock_agent.refund])
|
||||
mock_worklock_agent.assert_only_transactions(allowed=[mock_worklock_agent.refund])
|
||||
mock_worklock_agent.refund.assert_called_with(checksum_address=surrogate_bidder.checksum_address)
|
||||
|
||||
|
||||
|
|
|
@ -52,8 +52,6 @@ class MockContractAgent:
|
|||
r = f'Mock{self.agent_class.__name__}(id={id(self)})'
|
||||
return r
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def __setup_mock(cls, agent_class: Type[EthereumContractAgent]) -> None:
|
||||
|
||||
|
@ -137,7 +135,7 @@ class MockContractAgent:
|
|||
unexpected_transactions = list(filter(predicate, self.all_transactions))
|
||||
return unexpected_transactions
|
||||
|
||||
def assert_no_unexpected_transactions(self, allowed: Iterable[Callable]) -> None:
|
||||
def assert_only_transactions(self, allowed: Iterable[Callable]) -> None:
|
||||
unexpected_transactions = self.get_unexpected_transactions(allowed=allowed)
|
||||
assert not bool(unexpected_transactions)
|
||||
|
||||
|
|
Loading…
Reference in New Issue