{"action":"created","comment":{"url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/comments/182424975","pull_request_review_id":113215927,"id":182424975,"diff_hunk":"@@ -10,53 +10,100 @@ const should = require('chai')\n \n contract('LiquidDemocracy', function (accounts){\n \n-  beforeEach(async function () {\n-    // Set up ballot instance and register 4 voters\n-    this.liquidDemocracyBallot = await LiquidDemocracy.new();\n-    for (let i = 0; i < 4; i++) {\n-      await this.liquidDemocracyBallot.registerNewVoter({ from: accounts[i] });\n-    }\n-  });\n-  \n-  describe('registration set up', function () {\n-    it('should register voters successfully', async function () {\n-      const registered = await this.liquidDemocracyBallot.getVoterData(accounts[0]);\n-      let registeredWeight = registered[0].toString();\n-      let registeredStatus = registered[1];\n-      const unregistered = await this.liquidDemocracyBallot.getVoterData(accounts[4]);\n-      let unregisteredWeight = unregistered[0].toString();\n-      let unregisteredStatus = unregistered[1];\n-  \n-      registeredWeight.should.equal('1');\n-      registeredStatus.should.equal(true);\n-      unregisteredWeight.should.equal('0');\n-      unregisteredStatus.should.equal(false);\n-    });\n-  });\n-  \n-  describe('voting', function () {\n-    it('should allow registered voters to vote', async function () {\n-      await this.liquidDemocracyBallot.vote(accounts[0], 0);\n-      await this.liquidDemocracyBallot.vote(accounts[1], 0);\n-      await this.liquidDemocracyBallot.vote(accounts[2], 1);\n-      const voteCountOption0 = await this.liquidDemocracyBallot.getBallotVoteCount(0);\n-      const voteCountOption1 = await this.liquidDemocracyBallot.getBallotVoteCount(1);\n-\n-      voteCountOption0.toNumber().should.equal(2);\n-      voteCountOption1.toNumber().should.equal(1);\n+    beforeEach(async function () {\n+        // Set up ballot instance and register 4 voters\n+        this.liquidDemocracyBallot = await LiquidDemocracy.new();\n+        for (let i = 0; i < 4; i++) {\n+            await this.liquidDemocracyBallot.registerNewVoter({ from: accounts[i] });\n+        }\n     });\n \n-    it('should not allow unregistered voters to vote', async function () {\n-      await assertRevert(this.liquidDemocracyBallot.vote(accounts[4], 0));\n+    describe('registration set up', function () {\n+        it('should register voters successfully', async function () {\n+            const registered = await this.liquidDemocracyBallot.getVoterData(accounts[0]);\n+            let registeredWeight = registered[0].toString();\n+            let registeredStatus = registered[1];\n+            const unregistered = await this.liquidDemocracyBallot.getVoterData(accounts[4]);\n+            let unregisteredWeight = unregistered[0].toString();\n+            let unregisteredStatus = unregistered[1];\n+\n+            registeredWeight.should.equal('1');\n+            registeredStatus.should.equal(true);\n+            unregisteredWeight.should.equal('0');\n+            unregisteredStatus.should.equal(false);\n+        });\n     });\n \n-    it('should not allow registered voters to vote more than once', async function () {\n-      await this.liquidDemocracyBallot.vote(accounts[0], 0);\n-      await assertRevert(this.liquidDemocracyBallot.vote(accounts[0], 0));\n+    describe('voting', function () {\n+        it('should allow registered voters to vote', async function () {\n+            await this.liquidDemocracyBallot.vote(accounts[0], 0);\n+            await this.liquidDemocracyBallot.vote(accounts[1], 0);\n+            await this.liquidDemocracyBallot.vote(accounts[2], 1);\n+            const voteCountOption0 = await this.liquidDemocracyBallot.getBallotVoteCount(0);\n+            const voteCountOption1 = await this.liquidDemocracyBallot.getBallotVoteCount(1);\n+\n+            voteCountOption0.toNumber().should.equal(2);\n+            voteCountOption1.toNumber().should.equal(1);\n+        });\n+\n+        it('should not allow unregistered voters to vote', async function () {\n+            await assertRevert(this.liquidDemocracyBallot.vote(accounts[4], 0));\n+        });\n+\n+        it('should not allow registered voters to vote more than once', async function () {\n+            await this.liquidDemocracyBallot.vote(accounts[0], 0);\n+            await assertRevert(this.liquidDemocracyBallot.vote(accounts[0], 0));\n+        });\n     });\n-  });\n \n-  describe('delegating', function () {\n-    // TODO\n-  });\n+    describe('delegations produce the expected output', function () {\n+\n+        it('should perform a simple delegation', async function () {\n+            await this.liquidDemocracyBallot.delegate(accounts[1], { from: accounts[0] });\n+\n+            const representative = await this.liquidDemocracyBallot.getMyRepresentative({ from: accounts[0] })\n+            const representativeWeight = await this.liquidDemocracyBallot.getMyWeight({ from: accounts[1] })\n+            const representeeWeight = await this.liquidDemocracyBallot.getMyWeight({ from: accounts[0] })\n+\n+            assert.equal(representative, accounts[1]);\n+            assert.equal(representativeWeight, 2);\n+            assert.equal(representeeWeight, 0);\n+        });\n+\n+        it('should perform 1 hop transitive delegation', async function () {\n+            await this.liquidDemocracyBallot.delegate(accounts[1], { from: accounts[0] });\n+            await this.liquidDemocracyBallot.delegate(accounts[2], { from: accounts[1] });\n+\n+            const representative1 = await this.liquidDemocracyBallot.getMyRepresentative({ from: accounts[0] })\n+            const representative2 = await this.liquidDemocracyBallot.getMyRepresentative({ from: accounts[1] })\n+            const representative1Weight = await this.liquidDemocracyBallot.getMyWeight({ from: accounts[1] })\n+            const representative2Weight = await this.liquidDemocracyBallot.getMyWeight({ from: accounts[2] })\n+            const representeeWeight = await this.liquidDemocracyBallot.getMyWeight({ from: accounts[0] })\n+\n+            assert.equal(representative1, accounts[1]);\n+            assert.equal(representative2, accounts[2]);\n+            assert.equal(representative1Weight, 0);\n+            assert.equal(representative2Weight, 3);","path":"test/LiquidDemocracy.test.js","position":120,"original_position":120,"commit_id":"76befc1bed97167835cb8d3b8102985b752d4d07","original_commit_id":"76befc1bed97167835cb8d3b8102985b752d4d07","user":{"login":"aecc","id":6069300,"avatar_url":"https://avatars0.githubusercontent.com/u/6069300?v=4","gravatar_id":"","url":"https://api.github.com/users/aecc","html_url":"https://github.com/aecc","followers_url":"https://api.github.com/users/aecc/followers","following_url":"https://api.github.com/users/aecc/following{/other_user}","gists_url":"https://api.github.com/users/aecc/gists{/gist_id}","starred_url":"https://api.github.com/users/aecc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aecc/subscriptions","organizations_url":"https://api.github.com/users/aecc/orgs","repos_url":"https://api.github.com/users/aecc/repos","events_url":"https://api.github.com/users/aecc/events{/privacy}","received_events_url":"https://api.github.com/users/aecc/received_events","type":"User","site_admin":false},"body":"I added C.7 to the spec and modified C.5","created_at":"2018-04-18T13:26:16Z","updated_at":"2018-04-18T13:26:17Z","html_url":"https://github.com/DemocracyEarth/contracts/pull/21#discussion_r182424975","pull_request_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/comments/182424975"},"html":{"href":"https://github.com/DemocracyEarth/contracts/pull/21#discussion_r182424975"},"pull_request":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21"}},"in_reply_to_id":182102484},"pull_request":{"url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21","id":181324081,"html_url":"https://github.com/DemocracyEarth/contracts/pull/21","diff_url":"https://github.com/DemocracyEarth/contracts/pull/21.diff","patch_url":"https://github.com/DemocracyEarth/contracts/pull/21.patch","issue_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/21","number":21,"state":"open","locked":false,"title":"Added delegate() together with some tests","user":{"login":"aecc","id":6069300,"avatar_url":"https://avatars0.githubusercontent.com/u/6069300?v=4","gravatar_id":"","url":"https://api.github.com/users/aecc","html_url":"https://github.com/aecc","followers_url":"https://api.github.com/users/aecc/followers","following_url":"https://api.github.com/users/aecc/following{/other_user}","gists_url":"https://api.github.com/users/aecc/gists{/gist_id}","starred_url":"https://api.github.com/users/aecc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aecc/subscriptions","organizations_url":"https://api.github.com/users/aecc/orgs","repos_url":"https://api.github.com/users/aecc/repos","events_url":"https://api.github.com/users/aecc/events{/privacy}","received_events_url":"https://api.github.com/users/aecc/received_events","type":"User","site_admin":false},"body":"Delegate() (#13) implemented and some minimal tests. We will probably have some conflicts, we can merge you PR first or second, as you wish.","created_at":"2018-04-12T20:59:33Z","updated_at":"2018-04-18T13:26:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e62faf7543ac1dab0431e18aa50c17eee6901a6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":868578114,"url":"https://api.github.com/repos/DemocracyEarth/contracts/labels/review","name":"review","color":"e6e6e6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21/commits","review_comments_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21/comments","review_comment_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/21/comments","statuses_url":"https://api.github.com/repos/DemocracyEarth/contracts/statuses/76befc1bed97167835cb8d3b8102985b752d4d07","head":{"label":"DemocracyEarth:13-delegate","ref":"13-delegate","sha":"76befc1bed97167835cb8d3b8102985b752d4d07","user":{"login":"DemocracyEarth","id":15898510,"avatar_url":"https://avatars1.githubusercontent.com/u/15898510?v=4","gravatar_id":"","url":"https://api.github.com/users/DemocracyEarth","html_url":"https://github.com/DemocracyEarth","followers_url":"https://api.github.com/users/DemocracyEarth/followers","following_url":"https://api.github.com/users/DemocracyEarth/following{/other_user}","gists_url":"https://api.github.com/users/DemocracyEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/DemocracyEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemocracyEarth/subscriptions","organizations_url":"https://api.github.com/users/DemocracyEarth/orgs","repos_url":"https://api.github.com/users/DemocracyEarth/repos","events_url":"https://api.github.com/users/DemocracyEarth/events{/privacy}","received_events_url":"https://api.github.com/users/DemocracyEarth/received_events","type":"Organization","site_admin":false},"repo":{"id":98763038,"name":"contracts","full_name":"DemocracyEarth/contracts","owner":{"login":"DemocracyEarth","id":15898510,"avatar_url":"https://avatars1.githubusercontent.com/u/15898510?v=4","gravatar_id":"","url":"https://api.github.com/users/DemocracyEarth","html_url":"https://github.com/DemocracyEarth","followers_url":"https://api.github.com/users/DemocracyEarth/followers","following_url":"https://api.github.com/users/DemocracyEarth/following{/other_user}","gists_url":"https://api.github.com/users/DemocracyEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/DemocracyEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemocracyEarth/subscriptions","organizations_url":"https://api.github.com/users/DemocracyEarth/orgs","repos_url":"https://api.github.com/users/DemocracyEarth/repos","events_url":"https://api.github.com/users/DemocracyEarth/events{/privacy}","received_events_url":"https://api.github.com/users/DemocracyEarth/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DemocracyEarth/contracts","description":"The social smart contract implementation","fork":false,"url":"https://api.github.com/repos/DemocracyEarth/contracts","forks_url":"https://api.github.com/repos/DemocracyEarth/contracts/forks","keys_url":"https://api.github.com/repos/DemocracyEarth/contracts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DemocracyEarth/contracts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DemocracyEarth/contracts/teams","hooks_url":"https://api.github.com/repos/DemocracyEarth/contracts/hooks","issue_events_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/events{/number}","events_url":"https://api.github.com/repos/DemocracyEarth/contracts/events","assignees_url":"https://api.github.com/repos/DemocracyEarth/contracts/assignees{/user}","branches_url":"https://api.github.com/repos/DemocracyEarth/contracts/branches{/branch}","tags_url":"https://api.github.com/repos/DemocracyEarth/contracts/tags","blobs_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/refs{/sha}","trees_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DemocracyEarth/contracts/statuses/{sha}","languages_url":"https://api.github.com/repos/DemocracyEarth/contracts/languages","stargazers_url":"https://api.github.com/repos/DemocracyEarth/contracts/stargazers","contributors_url":"https://api.github.com/repos/DemocracyEarth/contracts/contributors","subscribers_url":"https://api.github.com/repos/DemocracyEarth/contracts/subscribers","subscription_url":"https://api.github.com/repos/DemocracyEarth/contracts/subscription","commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/commits{/sha}","git_commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/commits{/sha}","comments_url":"https://api.github.com/repos/DemocracyEarth/contracts/comments{/number}","issue_comment_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/comments{/number}","contents_url":"https://api.github.com/repos/DemocracyEarth/contracts/contents/{+path}","compare_url":"https://api.github.com/repos/DemocracyEarth/contracts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DemocracyEarth/contracts/merges","archive_url":"https://api.github.com/repos/DemocracyEarth/contracts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DemocracyEarth/contracts/downloads","issues_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues{/number}","pulls_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls{/number}","milestones_url":"https://api.github.com/repos/DemocracyEarth/contracts/milestones{/number}","notifications_url":"https://api.github.com/repos/DemocracyEarth/contracts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DemocracyEarth/contracts/labels{/name}","releases_url":"https://api.github.com/repos/DemocracyEarth/contracts/releases{/id}","deployments_url":"https://api.github.com/repos/DemocracyEarth/contracts/deployments","created_at":"2017-07-29T23:01:42Z","updated_at":"2018-04-15T21:43:48Z","pushed_at":"2018-04-17T16:02:25Z","git_url":"git://github.com/DemocracyEarth/contracts.git","ssh_url":"git@github.com:DemocracyEarth/contracts.git","clone_url":"https://github.com/DemocracyEarth/contracts.git","svn_url":"https://github.com/DemocracyEarth/contracts","homepage":"","size":23869,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":1,"open_issues":13,"watchers":9,"default_branch":"master"}},"base":{"label":"DemocracyEarth:master","ref":"master","sha":"bf174a82f15273991f543dfa97ea5123d52c0bb8","user":{"login":"DemocracyEarth","id":15898510,"avatar_url":"https://avatars1.githubusercontent.com/u/15898510?v=4","gravatar_id":"","url":"https://api.github.com/users/DemocracyEarth","html_url":"https://github.com/DemocracyEarth","followers_url":"https://api.github.com/users/DemocracyEarth/followers","following_url":"https://api.github.com/users/DemocracyEarth/following{/other_user}","gists_url":"https://api.github.com/users/DemocracyEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/DemocracyEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemocracyEarth/subscriptions","organizations_url":"https://api.github.com/users/DemocracyEarth/orgs","repos_url":"https://api.github.com/users/DemocracyEarth/repos","events_url":"https://api.github.com/users/DemocracyEarth/events{/privacy}","received_events_url":"https://api.github.com/users/DemocracyEarth/received_events","type":"Organization","site_admin":false},"repo":{"id":98763038,"name":"contracts","full_name":"DemocracyEarth/contracts","owner":{"login":"DemocracyEarth","id":15898510,"avatar_url":"https://avatars1.githubusercontent.com/u/15898510?v=4","gravatar_id":"","url":"https://api.github.com/users/DemocracyEarth","html_url":"https://github.com/DemocracyEarth","followers_url":"https://api.github.com/users/DemocracyEarth/followers","following_url":"https://api.github.com/users/DemocracyEarth/following{/other_user}","gists_url":"https://api.github.com/users/DemocracyEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/DemocracyEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DemocracyEarth/subscriptions","organizations_url":"https://api.github.com/users/DemocracyEarth/orgs","repos_url":"https://api.github.com/users/DemocracyEarth/repos","events_url":"https://api.github.com/users/DemocracyEarth/events{/privacy}","received_events_url":"https://api.github.com/users/DemocracyEarth/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DemocracyEarth/contracts","description":"The social smart contract implementation","fork":false,"url":"https://api.github.com/repos/DemocracyEarth/contracts","forks_url":"https://api.github.com/repos/DemocracyEarth/contracts/forks","keys_url":"https://api.github.com/repos/DemocracyEarth/contracts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DemocracyEarth/contracts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DemocracyEarth/contracts/teams","hooks_url":"https://api.github.com/repos/DemocracyEarth/contracts/hooks","issue_events_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/events{/number}","events_url":"https://api.github.com/repos/DemocracyEarth/contracts/events","assignees_url":"https://api.github.com/repos/DemocracyEarth/contracts/assignees{/user}","branches_url":"https://api.github.com/repos/DemocracyEarth/contracts/branches{/branch}","tags_url":"https://api.github.com/repos/DemocracyEarth/contracts/tags","blobs_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/refs{/sha}","trees_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DemocracyEarth/contracts/statuses/{sha}","languages_url":"https://api.github.com/repos/DemocracyEarth/contracts/languages","stargazers_url":"https://api.github.com/repos/DemocracyEarth/contracts/stargazers","contributors_url":"https://api.github.com/repos/DemocracyEarth/contracts/contributors","subscribers_url":"https://api.github.com/repos/DemocracyEarth/contracts/subscribers","subscription_url":"https://api.github.com/repos/DemocracyEarth/contracts/subscription","commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/commits{/sha}","git_commits_url":"https://api.github.com/repos/DemocracyEarth/contracts/git/commits{/sha}","comments_url":"https://api.github.com/repos/DemocracyEarth/contracts/comments{/number}","issue_comment_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues/comments{/number}","contents_url":"https://api.github.com/repos/DemocracyEarth/contracts/contents/{+path}","compare_url":"https://api.github.com/repos/DemocracyEarth/contracts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DemocracyEarth/contracts/merges","archive_url":"https://api.github.com/repos/DemocracyEarth/contracts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DemocracyEarth/contracts/downloads","issues_url":"https://api.github.com/repos/DemocracyEarth/contracts/issues{/number}","pulls_url":"https://api.github.com/repos/DemocracyEarth/contracts/pulls{/number}","milestones_url":"https://api.github.com/repos/DemocracyEarth/contracts/milestones{/number}","notifications_url":"https://api.github.com/repos/DemocracyEarth/contracts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DemocracyEarth/contracts/labels{/name}","releases_url":"https://api.github.com/repos/DemocracyEarth/contracts/releases{/id}","deployments_url":"https://api.github.com/repos/DemocracyEarth/contracts/deployments","created_at":"2017-07-29T23:01:42Z","updated_at":"2018-04-15T21:43:48Z","pushed_at":"2018-04-17T16:02:25Z","git_url":"git://github.com/DemocracyEarth/contracts.git","ssh_url":"git@github.com:DemocracyEarth/contracts.git","clone_url":"https://github.com/DemocracyEarth/contracts.git","svn_url":"https://github.com/DemocracyEarth/contracts","homepage":"","size":23869,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":13,"license":null,"forks":1,"open_issues":13,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21"},"html":{"href":"https://github.com/DemocracyEarth/contracts/pull/21"},"issue":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/issues/21"},"comments":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/DemocracyEarth/contracts/statuses/76befc1bed97167835cb8d3b8102985b752d4d07"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"aecc"}}