{"action":"created","comment":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/31871437","id":31871437,"diff_hunk":"@@ -0,0 +1,212 @@\n+package consensus\n+\n+import (\n+\t\"testing\"\n+\t\"time\"\n+\n+\t\"github.com/NebulousLabs/Sia/types\"\n+)\n+\n+// TestSynchronize tests that the consensus set can successfully synchronize\n+// to a peer.\n+func TestSynchronize(t *testing.T) {\n+\tif testing.Short() {\n+\t\tt.SkipNow()\n+\t}\n+\tcst1, err := createConsensusSetTester(\"TestSynchronize1\")\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\tcst2, err := createConsensusSetTester(\"TestSynchronize2\")\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\t// mine on cst2 until it is above cst1\n+\tfor cst1.cs.Height() >= cst2.cs.Height() {\n+\t\t_, _, err = cst2.miner.FindBlock()\n+\t\tif err != nil {\n+\t\t\tt.Fatal(err)\n+\t\t}\n+\t\tcst2.csUpdateWait()\n+\t}\n+\n+\t// connect gateways, triggering a Synchronize\n+\terr = cst1.gateway.Connect(cst2.gateway.Address())\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\t// blockchains should now match\n+\tif cst1.cs.currentBlockID() != cst2.cs.currentBlockID() {\n+\t\tt.Fatal(\"Consensus Sets did not synchronize\")\n+\t}\n+\n+\t// Synchronize again; nothing should change\n+\toldHeight := cst1.cs.Height()\n+\terr = cst1.cs.Synchronize(cst2.gateway.Address())\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\tif cst1.cs.Height() != oldHeight {\n+\t\tt.Fatalf(\"height changed after synchronizing to equal peer: %v -> %v\", oldHeight, cst1.cs.Height())\n+\t}\n+\n+\t// Mine on cst2 until it is more than 'MaxCatchUpBlocks' ahead of cst2.\n+\t// NOTE: we have to disconnect prior to this, otherwise cst2 will relay\n+\t// blocks to cst1.\n+\terr = cst1.gateway.Disconnect(cst2.gateway.Address())\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\t// TODO: more than 30 causes a race condition!\n+\tfor cst2.cs.Height() < cst1.cs.Height()+20 {\n+\t\t_, _, err = cst2.miner.FindBlock()\n+\t\tif err != nil {\n+\t\t\tt.Fatal(err)\n+\t\t}\n+\t\tcst2.csUpdateWait()\n+\t}\n+\t// reconnect\n+\terr = cst1.gateway.Connect(cst2.gateway.Address())\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\t// block heights should now match\n+\tif cst1.cs.Height() != cst2.cs.Height() {\n+\t\tt.Fatalf(\"Consensus Sets did not synchronize: %v %v\", cst1.cs.Height(), cst2.cs.Height())\n+\t}\n+\n+\t// extend cst2 with a \"bad\" (old) block, and synchronize. cst1 should\n+\t// reject the bad block.\n+\tlockID := cst2.cs.mu.Lock()\n+\tcst2.cs.currentPath = append(cst2.cs.currentPath, cst2.cs.currentPath[0])\n+\tcst2.cs.mu.Unlock(lockID)\n+\n+\terr = cst1.cs.Synchronize(cst2.gateway.Address())\n+\tif err != ErrBlockKnown {\n+\t\tt.Fatal(\"expected ErrBlockKnown, got\", err)\n+\t}\n+}\n+\n+func TestResynchronize(t *testing.T) {\n+\tt.Skip(\"takes way too long\")","path":"modules/consensus/synchronize_test.go","position":94,"original_position":94,"commit_id":"67023f1639933b67e3ed98dfa1b516f3b696c6c3","original_commit_id":"67023f1639933b67e3ed98dfa1b516f3b696c6c3","user":{"login":"lukechampine","id":3344749,"avatar_url":"https://avatars.githubusercontent.com/u/3344749?v=3","gravatar_id":"","url":"https://api.github.com/users/lukechampine","html_url":"https://github.com/lukechampine","followers_url":"https://api.github.com/users/lukechampine/followers","following_url":"https://api.github.com/users/lukechampine/following{/other_user}","gists_url":"https://api.github.com/users/lukechampine/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechampine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechampine/subscriptions","organizations_url":"https://api.github.com/users/lukechampine/orgs","repos_url":"https://api.github.com/users/lukechampine/repos","events_url":"https://api.github.com/users/lukechampine/events{/privacy}","received_events_url":"https://api.github.com/users/lukechampine/received_events","type":"User","site_admin":false},"body":"\"too long\" meaning 3 minutes.","created_at":"2015-06-06T20:51:24Z","updated_at":"2015-06-06T20:51:24Z","html_url":"https://github.com/NebulousLabs/Sia/pull/562#discussion_r31871437","pull_request_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/562","_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/31871437"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/562#discussion_r31871437"},"pull_request":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/562"}}},"pull_request":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/562","id":37096550,"html_url":"https://github.com/NebulousLabs/Sia/pull/562","diff_url":"https://github.com/NebulousLabs/Sia/pull/562.diff","patch_url":"https://github.com/NebulousLabs/Sia/pull/562.patch","issue_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/562","number":562,"state":"open","locked":false,"title":"Synchronize tests","user":{"login":"lukechampine","id":3344749,"avatar_url":"https://avatars.githubusercontent.com/u/3344749?v=3","gravatar_id":"","url":"https://api.github.com/users/lukechampine","html_url":"https://github.com/lukechampine","followers_url":"https://api.github.com/users/lukechampine/followers","following_url":"https://api.github.com/users/lukechampine/following{/other_user}","gists_url":"https://api.github.com/users/lukechampine/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechampine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechampine/subscriptions","organizations_url":"https://api.github.com/users/lukechampine/orgs","repos_url":"https://api.github.com/users/lukechampine/repos","events_url":"https://api.github.com/users/lukechampine/events{/privacy}","received_events_url":"https://api.github.com/users/lukechampine/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-06T20:50:45Z","updated_at":"2015-06-06T20:51:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e14fa2948e99c714c9f9709da21395974191ff3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/562/commits","review_comments_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/562/comments","review_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/562/comments","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/67023f1639933b67e3ed98dfa1b516f3b696c6c3","head":{"label":"NebulousLabs:sync-test","ref":"sync-test","sha":"67023f1639933b67e3ed98dfa1b516f3b696c6c3","user":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","created_at":"2014-10-17T17:50:25Z","updated_at":"2015-06-06T16:14:49Z","pushed_at":"2015-06-06T20:50:46Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"http://siacoin.com","size":31485,"stargazers_count":34,"watchers_count":34,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":31,"forks":7,"open_issues":31,"watchers":34,"default_branch":"master"}},"base":{"label":"NebulousLabs:master","ref":"master","sha":"8c54a1aa897cf1c2172685791b44fe2c75e05eff","user":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"avatar_url":"https://avatars.githubusercontent.com/u/7471422?v=3","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","created_at":"2014-10-17T17:50:25Z","updated_at":"2015-06-06T16:14:49Z","pushed_at":"2015-06-06T20:50:46Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"http://siacoin.com","size":31485,"stargazers_count":34,"watchers_count":34,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":31,"forks":7,"open_issues":31,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/562"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/562"},"issue":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/562"},"comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/562/comments"},"review_comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/562/comments"},"review_comment":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/562/commits"},"statuses":{"href":"https://api.github.com/repos/NebulousLabs/Sia/statuses/67023f1639933b67e3ed98dfa1b516f3b696c6c3"}}}}