From 307bfe3ad66064c32056e382cdb58cd7ed31963c Mon Sep 17 00:00:00 2001 From: Kieran Prasch Date: Sun, 1 Sep 2019 09:41:19 -0700 Subject: [PATCH] Fixes #1283 - Allow staking to maximum amount per address. --- nucypher/blockchain/eth/actors.py | 5 +++-- nucypher/characters/lawful.py | 3 +-- tests/cli/ursula/test_stakeholder_and_ursula.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/nucypher/blockchain/eth/actors.py b/nucypher/blockchain/eth/actors.py index 07b5a2ea1..6cabc6950 100644 --- a/nucypher/blockchain/eth/actors.py +++ b/nucypher/blockchain/eth/actors.py @@ -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, diff --git a/nucypher/characters/lawful.py b/nucypher/characters/lawful.py index d76ee49e7..6efaa66e6 100644 --- a/nucypher/characters/lawful.py +++ b/nucypher/characters/lawful.py @@ -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 diff --git a/tests/cli/ursula/test_stakeholder_and_ursula.py b/tests/cli/ursula/test_stakeholder_and_ursula.py index 6a28e3cd8..78e72fd9d 100644 --- a/tests/cli/ursula/test_stakeholder_and_ursula.py +++ b/tests/cli/ursula/test_stakeholder_and_ursula.py @@ -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,