Improve coverage of StakingEscrowAgent wrt to StakingEscrow contract

pull/1259/head
David Núñez 2019-08-29 17:17:58 +02:00
parent 99403a3a93
commit beb0e04d86
2 changed files with 6 additions and 2 deletions

View File

@ -231,6 +231,9 @@ class StakingEscrowAgent(EthereumContractAgent):
at_period = self.contract.functions.getCurrentPeriod().call()
return self.contract.functions.lockedPerPeriod(at_period).call()
def get_staker_info(self, staker_address: str):
return self.contract.functions.stakerInfo(staker_address).call()
def get_locked_tokens(self, staker_address: str, periods: int = 0) -> int:
"""
Returns the amount of tokens this staker has locked
@ -241,7 +244,8 @@ class StakingEscrowAgent(EthereumContractAgent):
return self.contract.functions.getLockedTokens(staker_address, periods).call()
def owned_tokens(self, staker_address: str) -> int:
return self.contract.functions.getAllTokens(staker_address).call()
staker_info = self.get_staker_info(staker_address)
return staker_info[0]
def get_substake_info(self, staker_address: str, stake_index: int) -> Tuple[int, int, int]:
first_period, *others, locked_value = self.contract.functions.getSubStakeInfo(staker_address, stake_index).call()

View File

@ -512,7 +512,7 @@ def paint_stakers(emitter, stakers: List[str], agent) -> None:
nickname, _ = nickname_from_seed(staker)
emitter.echo(f"{staker} {'Nickname:':10} {nickname}")
tab = " " * len(staker)
info = agent.contract.functions.stakerInfo(staker).call()
info = agent.get_staker_info(staker)
stake, confirmed1, confirmed2, restake, *remaining_info = info
locked_restake_until_period, worker, worker_start, last_active = remaining_info
last_confirmed_period = max(confirmed1, confirmed2)