{"action":"created","comment":{"url":"https://api.github.com/repos/livepeer/protocol/pulls/comments/236009052","pull_request_review_id":177964371,"id":236009052,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNjAwOTA1Mg==","diff_hunk":"@@ -620,4 +648,245 @@ contract(\"TicketBroker\", accounts => {\n             assert.equal(events[0].returnValues.recipient, recipient)\n         })\n     })\n+\n+    describe(\"unlock\", () => {\n+        it(\"reverts when both deposit and penaltyEscrow are zero\", async () => {\n+            await expectRevertWithReason(broker.unlock(), \"sender deposit and penalty escrow are zero\")\n+        })\n+\n+        it(\"reverts when called twice\", async () => {\n+            await broker.fundDeposit({from: sender, value: 1000})\n+            await broker.unlock()\n+\n+            await expectRevertWithReason(broker.unlock(), \"unlock already initiated\")\n+        })\n+\n+        it(\"reverts when called twice by multiple senders\", async () => {\n+            const sender2 = accounts[2]\n+            await broker.fundDeposit({from: sender, value: 1000})\n+            await broker.fundDeposit({from: sender2, value: 2000})\n+            await broker.unlock({from: sender})\n+            await broker.unlock({from: sender2})\n+\n+            await expectRevertWithReason(broker.unlock({from: sender}), \"unlock already initiated\")\n+            await expectRevertWithReason(broker.unlock({from: sender2}), \"unlock already initiated\")\n+        })\n+\n+        it(\"sets withdrawBlock according to constructor config\", async () => {\n+            await broker.fundDeposit({from: sender, value: 1000})\n+            const fromBlock = (await web3.eth.getBlock(\"latest\")).number\n+\n+            await broker.unlock({from: sender})\n+\n+            const withdrawBlock = (await broker.senders.call(sender)).withdrawBlock.toString()\n+            const expectedWithdrawBlock = fromBlock + unlockPeriod + 1 // +1 to account for the block created executing unlock\n+            assert.equal(withdrawBlock, expectedWithdrawBlock.toString())\n+        })\n+\n+        it(\"sets isUnlockInProgress to true\", async () => {\n+            await broker.fundDeposit({from: sender, value: 1000})\n+\n+            await broker.unlock({from: sender})\n+\n+            const isUnlockInProgress = await broker.isUnlockInProgress.call(sender)\n+            assert(isUnlockInProgress)\n+        })\n+\n+        it(\"emits an Unlock event\", async () => {\n+            await broker.fundDeposit({from: sender, value: 1000})\n+\n+            const txResult = await broker.unlock({from: sender})\n+\n+            truffleAssert.eventEmitted(txResult, \"Unlock\", ev => {\n+                return ev.sender === sender\n+            })\n+        })\n+\n+        it(\"emits an Unlock event indexed by sender\", async () => {\n+            const fromBlock = (await web3.eth.getBlock(\"latest\")).number\n+            await broker.fundDeposit({from: sender, value: 1000})\n+\n+            await broker.unlock({from: sender})\n+\n+            const events = await broker.getPastEvents(\"Unlock\", {\n+                filter: {\n+                    sender\n+                },\n+                fromBlock,\n+                toBlock: \"latest\"\n+            })\n+            assert.equal(events.length, 1)\n+            const event = events[0]\n+            assert.equal(event.returnValues.sender, sender)\n+        })\n+    })\n+\n+    describe(\"cancelUnlock\", () => {\n+        it(\"reverts if sender is not in an unlocking state\", async () => {\n+            await expectRevertWithReason(broker.cancelUnlock(), \"no unlock request in progress\")\n+        })\n+\n+        it(\"sets isUnlockInProgress to false\", async () => {\n+            await broker.fundDeposit({from: sender, value: 1000})\n+            await broker.unlock()\n+\n+            await broker.cancelUnlock()\n+\n+            const isUnlockInProgress = await broker.isUnlockInProgress.call(sender)\n+            assert.equal(isUnlockInProgress, false)","path":"test/unit/TicketBroker.js","position":159,"original_position":159,"commit_id":"875f4e14141e1b527360643f1c3ecda53350db06","original_commit_id":"867faee5a8d9ceca86965d4600fabe505c6d10a0","user":{"login":"yondonfu","id":5933273,"node_id":"MDQ6VXNlcjU5MzMyNzM=","avatar_url":"https://avatars0.githubusercontent.com/u/5933273?v=4","gravatar_id":"","url":"https://api.github.com/users/yondonfu","html_url":"https://github.com/yondonfu","followers_url":"https://api.github.com/users/yondonfu/followers","following_url":"https://api.github.com/users/yondonfu/following{/other_user}","gists_url":"https://api.github.com/users/yondonfu/gists{/gist_id}","starred_url":"https://api.github.com/users/yondonfu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yondonfu/subscriptions","organizations_url":"https://api.github.com/users/yondonfu/orgs","repos_url":"https://api.github.com/users/yondonfu/repos","events_url":"https://api.github.com/users/yondonfu/events{/privacy}","received_events_url":"https://api.github.com/users/yondonfu/received_events","type":"User","site_admin":false},"body":"`assert(!isUnlockInProgress)`?","created_at":"2018-11-23T19:16:00Z","updated_at":"2018-11-23T19:32:08Z","html_url":"https://github.com/livepeer/protocol/pull/260#discussion_r236009052","pull_request_url":"https://api.github.com/repos/livepeer/protocol/pulls/260","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/livepeer/protocol/pulls/comments/236009052"},"html":{"href":"https://github.com/livepeer/protocol/pull/260#discussion_r236009052"},"pull_request":{"href":"https://api.github.com/repos/livepeer/protocol/pulls/260"}}},"pull_request":{"url":"https://api.github.com/repos/livepeer/protocol/pulls/260","id":233226046,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzMjI2MDQ2","html_url":"https://github.com/livepeer/protocol/pull/260","diff_url":"https://github.com/livepeer/protocol/pull/260.diff","patch_url":"https://github.com/livepeer/protocol/pull/260.patch","issue_url":"https://api.github.com/repos/livepeer/protocol/issues/260","number":260,"state":"open","locked":false,"title":"Delayed withdrawal","user":{"login":"eladmallel","id":1137044,"node_id":"MDQ6VXNlcjExMzcwNDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1137044?v=4","gravatar_id":"","url":"https://api.github.com/users/eladmallel","html_url":"https://github.com/eladmallel","followers_url":"https://api.github.com/users/eladmallel/followers","following_url":"https://api.github.com/users/eladmallel/following{/other_user}","gists_url":"https://api.github.com/users/eladmallel/gists{/gist_id}","starred_url":"https://api.github.com/users/eladmallel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eladmallel/subscriptions","organizations_url":"https://api.github.com/users/eladmallel/orgs","repos_url":"https://api.github.com/users/eladmallel/repos","events_url":"https://api.github.com/users/eladmallel/events{/privacy}","received_events_url":"https://api.github.com/users/eladmallel/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-11-23T15:09:24Z","updated_at":"2018-11-23T19:32:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"20eb93cdb250a1a8ff50dbbda492f7324ff2027c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/livepeer/protocol/pulls/260/commits","review_comments_url":"https://api.github.com/repos/livepeer/protocol/pulls/260/comments","review_comment_url":"https://api.github.com/repos/livepeer/protocol/pulls/comments{/number}","comments_url":"https://api.github.com/repos/livepeer/protocol/issues/260/comments","statuses_url":"https://api.github.com/repos/livepeer/protocol/statuses/875f4e14141e1b527360643f1c3ecda53350db06","head":{"label":"livepeer:em/delayed-withdrawal","ref":"em/delayed-withdrawal","sha":"875f4e14141e1b527360643f1c3ecda53350db06","user":{"login":"livepeer","id":25355022,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MzU1MDIy","avatar_url":"https://avatars2.githubusercontent.com/u/25355022?v=4","gravatar_id":"","url":"https://api.github.com/users/livepeer","html_url":"https://github.com/livepeer","followers_url":"https://api.github.com/users/livepeer/followers","following_url":"https://api.github.com/users/livepeer/following{/other_user}","gists_url":"https://api.github.com/users/livepeer/gists{/gist_id}","starred_url":"https://api.github.com/users/livepeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/livepeer/subscriptions","organizations_url":"https://api.github.com/users/livepeer/orgs","repos_url":"https://api.github.com/users/livepeer/repos","events_url":"https://api.github.com/users/livepeer/events{/privacy}","received_events_url":"https://api.github.com/users/livepeer/received_events","type":"Organization","site_admin":false},"repo":{"id":89298984,"node_id":"MDEwOlJlcG9zaXRvcnk4OTI5ODk4NA==","name":"protocol","full_name":"livepeer/protocol","private":false,"owner":{"login":"livepeer","id":25355022,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MzU1MDIy","avatar_url":"https://avatars2.githubusercontent.com/u/25355022?v=4","gravatar_id":"","url":"https://api.github.com/users/livepeer","html_url":"https://github.com/livepeer","followers_url":"https://api.github.com/users/livepeer/followers","following_url":"https://api.github.com/users/livepeer/following{/other_user}","gists_url":"https://api.github.com/users/livepeer/gists{/gist_id}","starred_url":"https://api.github.com/users/livepeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/livepeer/subscriptions","organizations_url":"https://api.github.com/users/livepeer/orgs","repos_url":"https://api.github.com/users/livepeer/repos","events_url":"https://api.github.com/users/livepeer/events{/privacy}","received_events_url":"https://api.github.com/users/livepeer/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/livepeer/protocol","description":"Livepeer protocol","fork":false,"url":"https://api.github.com/repos/livepeer/protocol","forks_url":"https://api.github.com/repos/livepeer/protocol/forks","keys_url":"https://api.github.com/repos/livepeer/protocol/keys{/key_id}","collaborators_url":"https://api.github.com/repos/livepeer/protocol/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/livepeer/protocol/teams","hooks_url":"https://api.github.com/repos/livepeer/protocol/hooks","issue_events_url":"https://api.github.com/repos/livepeer/protocol/issues/events{/number}","events_url":"https://api.github.com/repos/livepeer/protocol/events","assignees_url":"https://api.github.com/repos/livepeer/protocol/assignees{/user}","branches_url":"https://api.github.com/repos/livepeer/protocol/branches{/branch}","tags_url":"https://api.github.com/repos/livepeer/protocol/tags","blobs_url":"https://api.github.com/repos/livepeer/protocol/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/livepeer/protocol/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/livepeer/protocol/git/refs{/sha}","trees_url":"https://api.github.com/repos/livepeer/protocol/git/trees{/sha}","statuses_url":"https://api.github.com/repos/livepeer/protocol/statuses/{sha}","languages_url":"https://api.github.com/repos/livepeer/protocol/languages","stargazers_url":"https://api.github.com/repos/livepeer/protocol/stargazers","contributors_url":"https://api.github.com/repos/livepeer/protocol/contributors","subscribers_url":"https://api.github.com/repos/livepeer/protocol/subscribers","subscription_url":"https://api.github.com/repos/livepeer/protocol/subscription","commits_url":"https://api.github.com/repos/livepeer/protocol/commits{/sha}","git_commits_url":"https://api.github.com/repos/livepeer/protocol/git/commits{/sha}","comments_url":"https://api.github.com/repos/livepeer/protocol/comments{/number}","issue_comment_url":"https://api.github.com/repos/livepeer/protocol/issues/comments{/number}","contents_url":"https://api.github.com/repos/livepeer/protocol/contents/{+path}","compare_url":"https://api.github.com/repos/livepeer/protocol/compare/{base}...{head}","merges_url":"https://api.github.com/repos/livepeer/protocol/merges","archive_url":"https://api.github.com/repos/livepeer/protocol/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/livepeer/protocol/downloads","issues_url":"https://api.github.com/repos/livepeer/protocol/issues{/number}","pulls_url":"https://api.github.com/repos/livepeer/protocol/pulls{/number}","milestones_url":"https://api.github.com/repos/livepeer/protocol/milestones{/number}","notifications_url":"https://api.github.com/repos/livepeer/protocol/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/livepeer/protocol/labels{/name}","releases_url":"https://api.github.com/repos/livepeer/protocol/releases{/id}","deployments_url":"https://api.github.com/repos/livepeer/protocol/deployments","created_at":"2017-04-25T00:22:38Z","updated_at":"2018-11-22T00:20:19Z","pushed_at":"2018-11-23T19:31:07Z","git_url":"git://github.com/livepeer/protocol.git","ssh_url":"git@github.com:livepeer/protocol.git","clone_url":"https://github.com/livepeer/protocol.git","svn_url":"https://github.com/livepeer/protocol","homepage":null,"size":1639,"stargazers_count":73,"watchers_count":73,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"archived":false,"open_issues_count":36,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":16,"open_issues":36,"watchers":73,"default_branch":"master"}},"base":{"label":"livepeer:yf/ticket-broker-livepeer","ref":"yf/ticket-broker-livepeer","sha":"73842e1295d883be8df5c4389a92f418cc7198d4","user":{"login":"livepeer","id":25355022,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MzU1MDIy","avatar_url":"https://avatars2.githubusercontent.com/u/25355022?v=4","gravatar_id":"","url":"https://api.github.com/users/livepeer","html_url":"https://github.com/livepeer","followers_url":"https://api.github.com/users/livepeer/followers","following_url":"https://api.github.com/users/livepeer/following{/other_user}","gists_url":"https://api.github.com/users/livepeer/gists{/gist_id}","starred_url":"https://api.github.com/users/livepeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/livepeer/subscriptions","organizations_url":"https://api.github.com/users/livepeer/orgs","repos_url":"https://api.github.com/users/livepeer/repos","events_url":"https://api.github.com/users/livepeer/events{/privacy}","received_events_url":"https://api.github.com/users/livepeer/received_events","type":"Organization","site_admin":false},"repo":{"id":89298984,"node_id":"MDEwOlJlcG9zaXRvcnk4OTI5ODk4NA==","name":"protocol","full_name":"livepeer/protocol","private":false,"owner":{"login":"livepeer","id":25355022,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MzU1MDIy","avatar_url":"https://avatars2.githubusercontent.com/u/25355022?v=4","gravatar_id":"","url":"https://api.github.com/users/livepeer","html_url":"https://github.com/livepeer","followers_url":"https://api.github.com/users/livepeer/followers","following_url":"https://api.github.com/users/livepeer/following{/other_user}","gists_url":"https://api.github.com/users/livepeer/gists{/gist_id}","starred_url":"https://api.github.com/users/livepeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/livepeer/subscriptions","organizations_url":"https://api.github.com/users/livepeer/orgs","repos_url":"https://api.github.com/users/livepeer/repos","events_url":"https://api.github.com/users/livepeer/events{/privacy}","received_events_url":"https://api.github.com/users/livepeer/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/livepeer/protocol","description":"Livepeer protocol","fork":false,"url":"https://api.github.com/repos/livepeer/protocol","forks_url":"https://api.github.com/repos/livepeer/protocol/forks","keys_url":"https://api.github.com/repos/livepeer/protocol/keys{/key_id}","collaborators_url":"https://api.github.com/repos/livepeer/protocol/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/livepeer/protocol/teams","hooks_url":"https://api.github.com/repos/livepeer/protocol/hooks","issue_events_url":"https://api.github.com/repos/livepeer/protocol/issues/events{/number}","events_url":"https://api.github.com/repos/livepeer/protocol/events","assignees_url":"https://api.github.com/repos/livepeer/protocol/assignees{/user}","branches_url":"https://api.github.com/repos/livepeer/protocol/branches{/branch}","tags_url":"https://api.github.com/repos/livepeer/protocol/tags","blobs_url":"https://api.github.com/repos/livepeer/protocol/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/livepeer/protocol/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/livepeer/protocol/git/refs{/sha}","trees_url":"https://api.github.com/repos/livepeer/protocol/git/trees{/sha}","statuses_url":"https://api.github.com/repos/livepeer/protocol/statuses/{sha}","languages_url":"https://api.github.com/repos/livepeer/protocol/languages","stargazers_url":"https://api.github.com/repos/livepeer/protocol/stargazers","contributors_url":"https://api.github.com/repos/livepeer/protocol/contributors","subscribers_url":"https://api.github.com/repos/livepeer/protocol/subscribers","subscription_url":"https://api.github.com/repos/livepeer/protocol/subscription","commits_url":"https://api.github.com/repos/livepeer/protocol/commits{/sha}","git_commits_url":"https://api.github.com/repos/livepeer/protocol/git/commits{/sha}","comments_url":"https://api.github.com/repos/livepeer/protocol/comments{/number}","issue_comment_url":"https://api.github.com/repos/livepeer/protocol/issues/comments{/number}","contents_url":"https://api.github.com/repos/livepeer/protocol/contents/{+path}","compare_url":"https://api.github.com/repos/livepeer/protocol/compare/{base}...{head}","merges_url":"https://api.github.com/repos/livepeer/protocol/merges","archive_url":"https://api.github.com/repos/livepeer/protocol/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/livepeer/protocol/downloads","issues_url":"https://api.github.com/repos/livepeer/protocol/issues{/number}","pulls_url":"https://api.github.com/repos/livepeer/protocol/pulls{/number}","milestones_url":"https://api.github.com/repos/livepeer/protocol/milestones{/number}","notifications_url":"https://api.github.com/repos/livepeer/protocol/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/livepeer/protocol/labels{/name}","releases_url":"https://api.github.com/repos/livepeer/protocol/releases{/id}","deployments_url":"https://api.github.com/repos/livepeer/protocol/deployments","created_at":"2017-04-25T00:22:38Z","updated_at":"2018-11-22T00:20:19Z","pushed_at":"2018-11-23T19:31:07Z","git_url":"git://github.com/livepeer/protocol.git","ssh_url":"git@github.com:livepeer/protocol.git","clone_url":"https://github.com/livepeer/protocol.git","svn_url":"https://github.com/livepeer/protocol","homepage":null,"size":1639,"stargazers_count":73,"watchers_count":73,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"archived":false,"open_issues_count":36,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":16,"open_issues":36,"watchers":73,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/livepeer/protocol/pulls/260"},"html":{"href":"https://github.com/livepeer/protocol/pull/260"},"issue":{"href":"https://api.github.com/repos/livepeer/protocol/issues/260"},"comments":{"href":"https://api.github.com/repos/livepeer/protocol/issues/260/comments"},"review_comments":{"href":"https://api.github.com/repos/livepeer/protocol/pulls/260/comments"},"review_comment":{"href":"https://api.github.com/repos/livepeer/protocol/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/livepeer/protocol/pulls/260/commits"},"statuses":{"href":"https://api.github.com/repos/livepeer/protocol/statuses/875f4e14141e1b527360643f1c3ecda53350db06"}},"author_association":"NONE"}}
{"actor":{"display_login":"yondonfu"}}