Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
hackaugusto committed Nov 22, 2017
1 parent 3832815 commit 33317be
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Changelog
=========

* :bug:`1138` REST and Python API close did not working if a transfer was made.
* :bug:`1138` REST and Python API close did not work if a transfer was made.
* :feature:`1097` Added `--gas-price` command line option.
* :feature:`1038` Introduce an upper limit for the ``settle_timeout`` attribute of the netting channel.
* :bug:`1044` Rename ``/connection`` API endpoint to ``/connections`` for consistency.
Expand All @@ -17,5 +17,5 @@ Changelog
* :feature:`921` Add ``/api/1/connection`` API endpoint returning information about all connected token networks.
* :bug:`1011` Remove ``settled`` attribute from the NettingChannel smart contract.

* :release:`0.1.0 <2017-09-12>`.
* :release:`0.1.0 <2017-09-12>`
* :feature:`-` This is the `Raiden Developer Preview <https://github.com/raiden-network/raiden/releases/tag/v0.1.0>`_ release. Introduces a raiden test network on ropsten, the API and all the basic functionality required to use Raiden in Dapps. For more information read the `blog post <https://medium.com/@raiden_network/raiden-network-developer-preview-dad83ec3fc23>`_ or the `documentation of v0.1.0 <http://raiden-network.readthedocs.io/en/v0.1.0/>`_.
4 changes: 2 additions & 2 deletions raiden/tests/api/test_pythonapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
NODE_NETWORK_REACHABLE,
NODE_NETWORK_UNKNOWN,
)
from raiden.tests.utils.blockchain import wait_until_block
from raiden.transfer.state import (
CHANNEL_STATE_CLOSED,
CHANNEL_STATE_OPENED,
CHANNEL_STATE_SETTLED,
)
from raiden.utils import get_contract_path
from raiden.tests.utils.blockchain import wait_until_block


@pytest.mark.parametrize('privatekey_seed', ['test_token_addresses:{}'])
Expand Down Expand Up @@ -112,7 +112,7 @@ def test_channel_lifecycle(blockchain_type, raiden_network, token_addresses, dep
assert channel12.contract_balance == deposit
assert api1.get_channel_list(token_address, api2.address) == [channel12]

# there is a channel open, they must be checking each other
# there is a channel open, they must be healthchecking each other
assert api1.get_node_network_state(api2.address) == NODE_NETWORK_REACHABLE
assert api2.get_node_network_state(api1.address) == NODE_NETWORK_REACHABLE

Expand Down
37 changes: 36 additions & 1 deletion raiden/tests/api/test_pythonapi_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,57 @@
import pytest

from raiden.api.python import RaidenAPI
from raiden.tests.utils.blockchain import wait_until_block
from raiden.transfer.state import (
CHANNEL_STATE_CLOSED,
CHANNEL_STATE_SETTLED,
)


@pytest.mark.parametrize('privatekey_seed', ['test_close_regression:{}'])
@pytest.mark.parametrize('number_of_nodes', [2])
@pytest.mark.parametrize('channels_per_node', [1])
def test_close_regression(raiden_network, token_addresses):
def test_close_regression(blockchain_type, raiden_network, token_addresses):
""" The python api was using the wrong balance proof to close the channel,
thus the close was failling if a transfer was made.
"""
if blockchain_type == 'tester':
pytest.skip('event polling is not reliable')

node1, node2 = raiden_network
token_address = token_addresses[0]

api1 = RaidenAPI(node1.raiden)
api2 = RaidenAPI(node2.raiden)

channel_list = api1.get_channel_list(token_address, node2.raiden.address)
channel12 = channel_list[0]

token_proxy = node1.raiden.chain.token(token_address)
node1_balance_before = token_proxy.balance_of(api1.address)
node2_balance_before = token_proxy.balance_of(api2.address)
channel_balance = token_proxy.balance_of(channel12.channel_address)

amount = 10
assert api1.transfer(token_address, amount, api2.address)

api1.close(token_address, api2.address)

node1.raiden.poll_blockchain_events()
assert channel12.state == CHANNEL_STATE_CLOSED

settlement_block = (
channel12.external_state.closed_block +
channel12.settle_timeout +
5 # arbitrary number of additional blocks, used to wait for the settle() call
)
wait_until_block(node1.raiden.chain, settlement_block)

node1.raiden.poll_blockchain_events()
assert channel12.state == CHANNEL_STATE_SETTLED

node1_withdraw_amount = channel12.balance
node2_withdraw_amount = channel_balance - node1_withdraw_amount

assert token_proxy.balance_of(api1.address) == node1_balance_before + node1_withdraw_amount
assert token_proxy.balance_of(api2.address) == node2_balance_before + node2_withdraw_amount

0 comments on commit 33317be

Please sign in to comment.