{"action":"created","comment":{"url":"https://api.github.com/repos/raiden-network/raiden/pulls/comments/101987807","pull_request_review_id":22729414,"id":101987807,"diff_hunk":"@@ -615,32 +620,33 @@ def channel_closed(self, block_number):\n \n     def blockalarm_for_settle(self, block_number):\n         def _settle():\n-            for _ in range(3):\n-                # do not call settle if already settled, the event polling\n-                # might be lagging behind.\n-                settled_block = self.external_state.query_settled()\n-                if settled_block != 0:\n-                    self.external_state.set_settled(settled_block)\n-                    log.info('channel automatically settled')\n-                    return\n-\n-                try:\n-                    # TODO: to remove unecessary JSON-RPC calls, change to an\n-                    # async version of settle and stop polling if the\n-                    # settle_event was set\n-                    self.external_state.settle()\n-                except:\n-                    log.exception('Timedout while calling settle')\n-\n-                # wait for the settle event, it could be our transaction or our\n-                # partner's\n-                self.settle_event.wait(0.5)\n-\n-                if self.settle_event.is_set():\n-                    log.info('channel automatically settled')\n-                    return\n-\n-        if self.external_state.closed_block + self.settle_timeout >= block_number:\n+            # do not call settle if already settled, the event polling\n+            # might be lagging behind.\n+            settled_block = self.external_state.query_settled()\n+            if settled_block != 0:\n+                self.external_state.set_settled(settled_block)\n+                log.info('channel automatically settled')\n+                return\n+\n+            try:\n+                # TODO: to remove unecessary JSON-RPC calls, change to an\n+                # async version of settle and stop polling if the\n+                # settle_event was set","path":"raiden/channel.py","position":null,"original_position":84,"commit_id":"287600f4a8de022039cc257b34a2c4f16e1c7bed","original_commit_id":"99ba6e5066694af9f6bd0a025c778a1b86626106","user":{"login":"konradkonrad","id":3705643,"avatar_url":"https://avatars.githubusercontent.com/u/3705643?v=3","gravatar_id":"","url":"https://api.github.com/users/konradkonrad","html_url":"https://github.com/konradkonrad","followers_url":"https://api.github.com/users/konradkonrad/followers","following_url":"https://api.github.com/users/konradkonrad/following{/other_user}","gists_url":"https://api.github.com/users/konradkonrad/gists{/gist_id}","starred_url":"https://api.github.com/users/konradkonrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konradkonrad/subscriptions","organizations_url":"https://api.github.com/users/konradkonrad/orgs","repos_url":"https://api.github.com/users/konradkonrad/repos","events_url":"https://api.github.com/users/konradkonrad/events{/privacy}","received_events_url":"https://api.github.com/users/konradkonrad/received_events","type":"User","site_admin":false},"body":"done","created_at":"2017-02-20T10:34:42Z","updated_at":"2017-02-20T10:34:42Z","html_url":"https://github.com/raiden-network/raiden/pull/391#discussion_r101987807","pull_request_url":"https://api.github.com/repos/raiden-network/raiden/pulls/391","_links":{"self":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/comments/101987807"},"html":{"href":"https://github.com/raiden-network/raiden/pull/391#discussion_r101987807"},"pull_request":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/391"}}},"pull_request":{"url":"https://api.github.com/repos/raiden-network/raiden/pulls/391","id":105947727,"html_url":"https://github.com/raiden-network/raiden/pull/391","diff_url":"https://github.com/raiden-network/raiden/pull/391.diff","patch_url":"https://github.com/raiden-network/raiden/pull/391.patch","issue_url":"https://api.github.com/repos/raiden-network/raiden/issues/391","number":391,"state":"open","locked":false,"title":"Fix test_settlement","user":{"login":"konradkonrad","id":3705643,"avatar_url":"https://avatars.githubusercontent.com/u/3705643?v=3","gravatar_id":"","url":"https://api.github.com/users/konradkonrad","html_url":"https://github.com/konradkonrad","followers_url":"https://api.github.com/users/konradkonrad/followers","following_url":"https://api.github.com/users/konradkonrad/following{/other_user}","gists_url":"https://api.github.com/users/konradkonrad/gists{/gist_id}","starred_url":"https://api.github.com/users/konradkonrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konradkonrad/subscriptions","organizations_url":"https://api.github.com/users/konradkonrad/orgs","repos_url":"https://api.github.com/users/konradkonrad/repos","events_url":"https://api.github.com/users/konradkonrad/events{/privacy}","received_events_url":"https://api.github.com/users/konradkonrad/received_events","type":"User","site_admin":false},"body":"This fixes the automatic settlement as tested in `tests/integration/test_settlement.py::test_settlement` and allows to remove the pytest skip on travis-CI. Due to the applied fixes a couple of other tests that apparently adjusted to the formerly broken behavior needed changes, too. \r\n\r\nThere were a couple of issues that lead us to start skipping the test and I'd like you to give the PR a thorough review -- to ensure it fixes what it is supposed to fix and also to learn:\r\n- The main cause for the [\"flakyness\"](https://github.com/raiden-network/raiden/issues/389) of the test was an incorrect [Yoda-style](https://en.wikipedia.org/wiki/Yoda_conditions) boolean comparison in the [`blockalarm_for_settle`](https://github.com/raiden-network/raiden/pull/391/commits/3bac2c5158db69ef484f56bb3713f6e99e162973). I believe there is no reason for Yoda-boolean in python and we should avoid it, because it is harder to reason about it (the bug went unnoticed for several months).\r\n- The flakyness of `test_settlement.py::test_settlement` was most likely caused by the sometimes late spawned `_settle` task (which could only then run successfully).\r\n- Due to the skipped test in CI, we also missed a [breaking change for the arguments to `close`](https://github.com/raiden-network/raiden/commit/e82f7b3e5725f68d08c1791ff8a25515bfbd7232), which [was also fixed](https://github.com/raiden-network/raiden/pull/391/files#diff-9161c3328a41e5b779ebb4d7966b8abcR109).\r\n- `test_settlement.py::test_settlement` [missed to properly check the postconditions](https://github.com/raiden-network/raiden/pull/391/files#diff-9161c3328a41e5b779ebb4d7966b8abcR142). Due to a [padding mismatch for the secret](https://github.com/raiden-network/raiden/pull/391/files#diff-9161c3328a41e5b779ebb4d7966b8abcR53) the [unlock call](https://github.com/raiden-network/raiden/pull/391/files#diff-9161c3328a41e5b779ebb4d7966b8abcR125) never succeeded before (i.e. there were assets lost). See also #395.\r\n- I increased some of the pytest-timeouts to let the tests pass consistently here. I believe we should use timeouts **only** as a last resort to keep the test suite from locking up completely, but never to \"speed things up\".\r\n- One of the other tests [affected by the fix]() already [suspected something fishy](https://github.com/raiden-network/raiden/pull/391/files#diff-e9ba3bf3caea82260af91c81e3782dbaL716) -- I suggest we should take the time to investigate odd behavior instead of coding around it :)\r\n- ~~I added an [explicit context switch](https://github.com/konradkonrad/raiden/blob/99ba6e5066694af9f6bd0a025c778a1b86626106/raiden/tests/utils/blockchain.py#L44-L51) to the `wait_until_block` pattern, and applied it to all tests I touched. This [wasn't enough in all instances](https://github.com/raiden-network/raiden/pull/391/commits/fe7cfc2e49915f3dd5559a65551920c7db790d85) and I'd like to get your opinion on a best-practice for coroutine testing.~~\r\n\r\nThere are a couple of follow up issues:\r\n- #393 -- issuing callbacks for lifecycle changes\r\n- #394 -- channel proxy return values\r\n- #395 -- hashlock/secret padding pitfall\r\n- #396 -- debug tooling\r\n- #397 -- review skip/xfail test markers\r\n\r\nThis fixes #390 :) :)","created_at":"2017-02-13T18:06:24Z","updated_at":"2017-02-20T10:34:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c5e3572e39e68122aa08671862461de94c8fd404","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/raiden-network/raiden/pulls/391/commits","review_comments_url":"https://api.github.com/repos/raiden-network/raiden/pulls/391/comments","review_comment_url":"https://api.github.com/repos/raiden-network/raiden/pulls/comments{/number}","comments_url":"https://api.github.com/repos/raiden-network/raiden/issues/391/comments","statuses_url":"https://api.github.com/repos/raiden-network/raiden/statuses/287600f4a8de022039cc257b34a2c4f16e1c7bed","head":{"label":"konradkonrad:fix_test_settlement","ref":"fix_test_settlement","sha":"287600f4a8de022039cc257b34a2c4f16e1c7bed","user":{"login":"konradkonrad","id":3705643,"avatar_url":"https://avatars.githubusercontent.com/u/3705643?v=3","gravatar_id":"","url":"https://api.github.com/users/konradkonrad","html_url":"https://github.com/konradkonrad","followers_url":"https://api.github.com/users/konradkonrad/followers","following_url":"https://api.github.com/users/konradkonrad/following{/other_user}","gists_url":"https://api.github.com/users/konradkonrad/gists{/gist_id}","starred_url":"https://api.github.com/users/konradkonrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konradkonrad/subscriptions","organizations_url":"https://api.github.com/users/konradkonrad/orgs","repos_url":"https://api.github.com/users/konradkonrad/repos","events_url":"https://api.github.com/users/konradkonrad/events{/privacy}","received_events_url":"https://api.github.com/users/konradkonrad/received_events","type":"User","site_admin":false},"repo":{"id":71461264,"name":"raiden","full_name":"konradkonrad/raiden","owner":{"login":"konradkonrad","id":3705643,"avatar_url":"https://avatars.githubusercontent.com/u/3705643?v=3","gravatar_id":"","url":"https://api.github.com/users/konradkonrad","html_url":"https://github.com/konradkonrad","followers_url":"https://api.github.com/users/konradkonrad/followers","following_url":"https://api.github.com/users/konradkonrad/following{/other_user}","gists_url":"https://api.github.com/users/konradkonrad/gists{/gist_id}","starred_url":"https://api.github.com/users/konradkonrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konradkonrad/subscriptions","organizations_url":"https://api.github.com/users/konradkonrad/orgs","repos_url":"https://api.github.com/users/konradkonrad/repos","events_url":"https://api.github.com/users/konradkonrad/events{/privacy}","received_events_url":"https://api.github.com/users/konradkonrad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/konradkonrad/raiden","description":"Raiden Network","fork":true,"url":"https://api.github.com/repos/konradkonrad/raiden","forks_url":"https://api.github.com/repos/konradkonrad/raiden/forks","keys_url":"https://api.github.com/repos/konradkonrad/raiden/keys{/key_id}","collaborators_url":"https://api.github.com/repos/konradkonrad/raiden/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/konradkonrad/raiden/teams","hooks_url":"https://api.github.com/repos/konradkonrad/raiden/hooks","issue_events_url":"https://api.github.com/repos/konradkonrad/raiden/issues/events{/number}","events_url":"https://api.github.com/repos/konradkonrad/raiden/events","assignees_url":"https://api.github.com/repos/konradkonrad/raiden/assignees{/user}","branches_url":"https://api.github.com/repos/konradkonrad/raiden/branches{/branch}","tags_url":"https://api.github.com/repos/konradkonrad/raiden/tags","blobs_url":"https://api.github.com/repos/konradkonrad/raiden/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/konradkonrad/raiden/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/konradkonrad/raiden/git/refs{/sha}","trees_url":"https://api.github.com/repos/konradkonrad/raiden/git/trees{/sha}","statuses_url":"https://api.github.com/repos/konradkonrad/raiden/statuses/{sha}","languages_url":"https://api.github.com/repos/konradkonrad/raiden/languages","stargazers_url":"https://api.github.com/repos/konradkonrad/raiden/stargazers","contributors_url":"https://api.github.com/repos/konradkonrad/raiden/contributors","subscribers_url":"https://api.github.com/repos/konradkonrad/raiden/subscribers","subscription_url":"https://api.github.com/repos/konradkonrad/raiden/subscription","commits_url":"https://api.github.com/repos/konradkonrad/raiden/commits{/sha}","git_commits_url":"https://api.github.com/repos/konradkonrad/raiden/git/commits{/sha}","comments_url":"https://api.github.com/repos/konradkonrad/raiden/comments{/number}","issue_comment_url":"https://api.github.com/repos/konradkonrad/raiden/issues/comments{/number}","contents_url":"https://api.github.com/repos/konradkonrad/raiden/contents/{+path}","compare_url":"https://api.github.com/repos/konradkonrad/raiden/compare/{base}...{head}","merges_url":"https://api.github.com/repos/konradkonrad/raiden/merges","archive_url":"https://api.github.com/repos/konradkonrad/raiden/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/konradkonrad/raiden/downloads","issues_url":"https://api.github.com/repos/konradkonrad/raiden/issues{/number}","pulls_url":"https://api.github.com/repos/konradkonrad/raiden/pulls{/number}","milestones_url":"https://api.github.com/repos/konradkonrad/raiden/milestones{/number}","notifications_url":"https://api.github.com/repos/konradkonrad/raiden/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/konradkonrad/raiden/labels{/name}","releases_url":"https://api.github.com/repos/konradkonrad/raiden/releases{/id}","deployments_url":"https://api.github.com/repos/konradkonrad/raiden/deployments","created_at":"2016-10-20T12:33:32Z","updated_at":"2016-10-20T12:33:34Z","pushed_at":"2017-02-20T10:27:01Z","git_url":"git://github.com/konradkonrad/raiden.git","ssh_url":"git@github.com:konradkonrad/raiden.git","clone_url":"https://github.com/konradkonrad/raiden.git","svn_url":"https://github.com/konradkonrad/raiden","homepage":null,"size":2522,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"raiden-network:master","ref":"master","sha":"aa3dec0bd265edec5e1713923aceaa770a6f782f","user":{"login":"raiden-network","id":19666847,"avatar_url":"https://avatars.githubusercontent.com/u/19666847?v=3","gravatar_id":"","url":"https://api.github.com/users/raiden-network","html_url":"https://github.com/raiden-network","followers_url":"https://api.github.com/users/raiden-network/followers","following_url":"https://api.github.com/users/raiden-network/following{/other_user}","gists_url":"https://api.github.com/users/raiden-network/gists{/gist_id}","starred_url":"https://api.github.com/users/raiden-network/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raiden-network/subscriptions","organizations_url":"https://api.github.com/users/raiden-network/orgs","repos_url":"https://api.github.com/users/raiden-network/repos","events_url":"https://api.github.com/users/raiden-network/events{/privacy}","received_events_url":"https://api.github.com/users/raiden-network/received_events","type":"Organization","site_admin":false},"repo":{"id":50646767,"name":"raiden","full_name":"raiden-network/raiden","owner":{"login":"raiden-network","id":19666847,"avatar_url":"https://avatars.githubusercontent.com/u/19666847?v=3","gravatar_id":"","url":"https://api.github.com/users/raiden-network","html_url":"https://github.com/raiden-network","followers_url":"https://api.github.com/users/raiden-network/followers","following_url":"https://api.github.com/users/raiden-network/following{/other_user}","gists_url":"https://api.github.com/users/raiden-network/gists{/gist_id}","starred_url":"https://api.github.com/users/raiden-network/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raiden-network/subscriptions","organizations_url":"https://api.github.com/users/raiden-network/orgs","repos_url":"https://api.github.com/users/raiden-network/repos","events_url":"https://api.github.com/users/raiden-network/events{/privacy}","received_events_url":"https://api.github.com/users/raiden-network/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/raiden-network/raiden","description":"Raiden Network","fork":false,"url":"https://api.github.com/repos/raiden-network/raiden","forks_url":"https://api.github.com/repos/raiden-network/raiden/forks","keys_url":"https://api.github.com/repos/raiden-network/raiden/keys{/key_id}","collaborators_url":"https://api.github.com/repos/raiden-network/raiden/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/raiden-network/raiden/teams","hooks_url":"https://api.github.com/repos/raiden-network/raiden/hooks","issue_events_url":"https://api.github.com/repos/raiden-network/raiden/issues/events{/number}","events_url":"https://api.github.com/repos/raiden-network/raiden/events","assignees_url":"https://api.github.com/repos/raiden-network/raiden/assignees{/user}","branches_url":"https://api.github.com/repos/raiden-network/raiden/branches{/branch}","tags_url":"https://api.github.com/repos/raiden-network/raiden/tags","blobs_url":"https://api.github.com/repos/raiden-network/raiden/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/raiden-network/raiden/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/raiden-network/raiden/git/refs{/sha}","trees_url":"https://api.github.com/repos/raiden-network/raiden/git/trees{/sha}","statuses_url":"https://api.github.com/repos/raiden-network/raiden/statuses/{sha}","languages_url":"https://api.github.com/repos/raiden-network/raiden/languages","stargazers_url":"https://api.github.com/repos/raiden-network/raiden/stargazers","contributors_url":"https://api.github.com/repos/raiden-network/raiden/contributors","subscribers_url":"https://api.github.com/repos/raiden-network/raiden/subscribers","subscription_url":"https://api.github.com/repos/raiden-network/raiden/subscription","commits_url":"https://api.github.com/repos/raiden-network/raiden/commits{/sha}","git_commits_url":"https://api.github.com/repos/raiden-network/raiden/git/commits{/sha}","comments_url":"https://api.github.com/repos/raiden-network/raiden/comments{/number}","issue_comment_url":"https://api.github.com/repos/raiden-network/raiden/issues/comments{/number}","contents_url":"https://api.github.com/repos/raiden-network/raiden/contents/{+path}","compare_url":"https://api.github.com/repos/raiden-network/raiden/compare/{base}...{head}","merges_url":"https://api.github.com/repos/raiden-network/raiden/merges","archive_url":"https://api.github.com/repos/raiden-network/raiden/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/raiden-network/raiden/downloads","issues_url":"https://api.github.com/repos/raiden-network/raiden/issues{/number}","pulls_url":"https://api.github.com/repos/raiden-network/raiden/pulls{/number}","milestones_url":"https://api.github.com/repos/raiden-network/raiden/milestones{/number}","notifications_url":"https://api.github.com/repos/raiden-network/raiden/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/raiden-network/raiden/labels{/name}","releases_url":"https://api.github.com/repos/raiden-network/raiden/releases{/id}","deployments_url":"https://api.github.com/repos/raiden-network/raiden/deployments","created_at":"2016-01-29T07:40:47Z","updated_at":"2017-02-19T08:45:13Z","pushed_at":"2017-02-20T10:27:03Z","git_url":"git://github.com/raiden-network/raiden.git","ssh_url":"git@github.com:raiden-network/raiden.git","clone_url":"https://github.com/raiden-network/raiden.git","svn_url":"https://github.com/raiden-network/raiden","homepage":null,"size":2362,"stargazers_count":204,"watchers_count":204,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":47,"mirror_url":null,"open_issues_count":107,"forks":47,"open_issues":107,"watchers":204,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/391"},"html":{"href":"https://github.com/raiden-network/raiden/pull/391"},"issue":{"href":"https://api.github.com/repos/raiden-network/raiden/issues/391"},"comments":{"href":"https://api.github.com/repos/raiden-network/raiden/issues/391/comments"},"review_comments":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/391/comments"},"review_comment":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/391/commits"},"statuses":{"href":"https://api.github.com/repos/raiden-network/raiden/statuses/287600f4a8de022039cc257b34a2c4f16e1c7bed"}}}}
{"actor":{"display_login":"konradkonrad"}}