Skip to content

Commit

Permalink
Raise EthNodeCommunicationError if problem
Browse files Browse the repository at this point in the history
If we got a problem during the deposit we should raise the EthNodecommunicationerror
  • Loading branch information
LefterisJP committed Sep 5, 2017
1 parent 0391bce commit e2c47c7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions raiden/api/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
EventTransferReceivedSuccess,
)
from raiden.exceptions import (
EthNodeCommunicationError,
NoPathError,
InvalidAddress,
InvalidAmount,
Expand Down Expand Up @@ -240,16 +241,21 @@ def deposit(self, token_address, partner_address, amount):
netting_channel.deposit(amount)

# Wait until the balance has been updated via a state transition triggered
# by processing the `ChannelNewBalance` event
# by processing the `ChannelNewBalance` event.
# Usually, it'll take a single gevent.sleep, as we already have waited
# for it to be mined, and only need to give the event handling greenlet
# the chance to process the event, but let's wait 10s to be safe
wait_timeout_secs = 10 # FIXME: hardcoded timeout
if not wait_until(
lambda: channel.contract_balance != old_balance,
10,
wait_timeout_secs,
self.raiden.alarm.wait_time,
):
log.debug('Wait until failed', contract_balance=channel.contract_balance)
raise EthNodeCommunicationError(
'After {} seconds the deposit was not properly processed.'.format(
wait_timeout_secs
)
)

return channel

Expand Down

0 comments on commit e2c47c7

Please sign in to comment.