Small bug fixes found while unit testing worklock

pull/1949/head
Kieran R. Prasch 2020-05-02 08:28:34 -07:00
parent cf1c40c919
commit a731b749b4
4 changed files with 13 additions and 15 deletions

View File

@ -115,7 +115,10 @@ class BaseActor:
def __eq__(self, other) -> bool:
"""Actors are equal if they have the same address."""
try:
return bool(self.checksum_address == other.checksum_address)
except AttributeError:
return False
@property
def eth_balance(self) -> Decimal:

View File

@ -1282,7 +1282,8 @@ class WorkLockAgent(EthereumContractAgent):
def is_claiming_available(self) -> bool:
"""Returns True if claiming is available"""
return self.contract.functions.isClaimingAvailable().call()
result = self.contract.functions.isClaimingAvailable().call()
return result
@property
def next_bidder_to_check(self) -> int:

View File

@ -436,26 +436,19 @@ class EthereumTesterClient(EthereumClient):
def unlock_account(self, account, password, duration: int = None) -> bool:
"""Returns True if the testing backend keyring has control of the given address."""
account = to_canonical_address(account)
try:
# PyEVM backend
keystore = self.w3.provider.ethereum_tester.backend._key_lookup
except AttributeError:
# Mock provider, probably
keystore = self.w3.provider.ethereum_tester.backend.get_accounts()
if account in keystore:
keystore_accounts = self.w3.provider.ethereum_tester.backend.get_accounts()
if account in keystore_accounts:
return True
else:
return self.w3.provider.ethereum_tester.unlock_account(account=account,
return self.w3.provider.ethereum_tester.unlock_account(account=to_checksum_address(account),
password=password,
unlock_seconds=duration)
def lock_account(self, account) -> bool:
"""Returns True if the testing backend keyring has control of the given address."""
account = to_canonical_address(account)
keystore = self.w3.provider.ethereum_tester.backend._key_lookup
if account in keystore:
keystore_accounts = self.w3.provider.ethereum_tester.backend.get_accounts()
if account in keystore_accounts:
return True
else:
return self.w3.provider.ethereum_tester.lock_account(account=account)

View File

@ -154,7 +154,8 @@ def bid(general_config, worklock_options, force, hw_wallet, value):
worklock_agent = ContractAgency.get_agent(WorkLockAgent, registry=registry) # type: WorkLockAgent
now = maya.now().epoch
if not worklock_agent.start_bidding_date <= now <= worklock_agent.end_bidding_date:
raise click.Abort(f"You can't bid, the bidding window is closed.")
emitter.echo(f"You can't bid, the bidding window is closed.", color='red')
raise click.Abort()
if not worklock_options.bidder_address:
worklock_options.bidder_address = select_client_account(emitter=emitter,