Fixes #1283 - Allow staking to maximum amount per address.

pull/1283/head
Kieran Prasch 2019-09-01 09:41:19 -07:00
parent 69b41a7b5b
commit 307bfe3ad6
No known key found for this signature in database
GPG Key ID: 199AB839D4125A62
3 changed files with 4 additions and 5 deletions

View File

@ -515,8 +515,9 @@ class Staker(NucypherTokenActor):
# Ensure the new stake will not exceed the staking limit
if (self.current_stake + amount) > self.economics.maximum_allowed_locked:
raise Stake.StakingError(f"Cannot divide stake - "
f"Maximum stake value exceeded with a target value of {amount}.")
raise Stake.StakingError(f"Cannot initialize stake - "
f"Maximum stake value exceeded for {self.checksum_address} "
f"with a target value of {amount}.")
# Write to blockchain
new_stake = Stake.initialize_stake(staker=self,

View File

@ -1447,11 +1447,10 @@ class StakeHolder(Staker):
return stakes
@property
def current_stake(self) -> NU:
def total_stake(self) -> NU:
"""
The total number of staked tokens, either locked or unlocked in the current period.
"""
# TODO: This is skipping a layer. Fix me?
stake = sum(self.staking_agent.owned_tokens(staker_address=account) for account in self.wallet.accounts)
nu_stake = NU.from_nunits(stake)
return nu_stake

View File

@ -20,7 +20,6 @@ from nucypher.utilities.sandbox.constants import (
TEST_PROVIDER_URI,
MOCK_URSULA_STARTING_PORT,
INSECURE_DEVELOPMENT_PASSWORD,
MOCK_REGISTRY_FILEPATH,
TEMPORARY_DOMAIN,
MOCK_KNOWN_URSULAS_CACHE,
select_test_port,