Added acceptable deviation between current and expected USD ballance

This commit is contained in:
Serhy 2017-12-27 20:03:57 +02:00 committed by Anton Danchenko
parent c531ece0bd
commit 977db7ab9c
1 changed files with 3 additions and 2 deletions

View File

@ -93,6 +93,7 @@ class WalletViewObject(BaseViewObject):
usd = self.get_usd_total_value()
eth = self.get_eth_value()
expected_usd = round(eth * expected_rate, 2)
if expected_usd != usd:
errors.append('Current USD balance %s is not equal to the expected %s' % (usd, expected_usd))
percentage_diff = abs((usd - expected_usd) / ((usd + expected_usd) / 2)) * 100
if percentage_diff > 2:
errors.append('Difference between current (%s) and expected (%s) USD balance > 2%%!!' % (usd, expected_usd))
logging.info('Current USD balance %s is ok' % usd)