{"action":"created","comment":{"url":"https://api.github.com/repos/decred/dcrd/pulls/comments/192792195","pull_request_review_id":125636234,"id":192792195,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Mjc5MjE5NQ==","diff_hunk":"@@ -689,6 +689,69 @@ func TestOutboundPeer(t *testing.T) {\n \tp2.Disconnect()\n }\n \n+// TestDuplicateVersionMsg ensures that receiving a version message after one\n+// has already been received results in the peer being disconnected.\n+func TestDuplicateVersionMsg(t *testing.T) {\n+\t// Create a pair of peers that are connected to each other using a fake\n+\t// connection.\n+\tverack := make(chan struct{})\n+\tpeerCfg := &peer.Config{\n+\t\tListeners: peer.MessageListeners{\n+\t\t\tOnVerAck: func(p *peer.Peer, msg *wire.MsgVerAck) {\n+\t\t\t\tverack <- struct{}{}\n+\t\t\t},\n+\t\t},\n+\t\tUserAgentName:    \"peer\",\n+\t\tUserAgentVersion: \"1.0\",\n+\t\tChainParams:      &chaincfg.MainNetParams,\n+\t\tServices:         0,\n+\t}\n+\tinConn, outConn := pipe(\n+\t\t&conn{laddr: \"10.0.0.1:9108\", raddr: \"10.0.0.2:9108\"},\n+\t\t&conn{laddr: \"10.0.0.2:9108\", raddr: \"10.0.0.1:9108\"},\n+\t)\n+\toutPeer, err := peer.NewOutboundPeer(peerCfg, inConn.laddr)\n+\tif err != nil {\n+\t\tt.Fatalf(\"NewOutboundPeer: unexpected err: %v\\n\", err)\n+\t}\n+\toutPeer.AssociateConnection(outConn)\n+\tinPeer := peer.NewInboundPeer(peerCfg)\n+\tinPeer.AssociateConnection(inConn)\n+\n+\t// Wait for the veracks from the initial protocol version negotiation.\n+\tfor i := 0; i < 2; i++ {\n+\t\tselect {\n+\t\tcase <-verack:\n+\t\tcase <-time.After(time.Second):\n+\t\t\tt.Fatal(\"verack timeout\")\n+\t\t}\n+\t}\n+\n+\t// Queue a duplicate version message from the outbound peer and wait until\n+\t// it is sent.\n+\tdone := make(chan struct{})\n+\toutPeer.QueueMessage(&wire.MsgVersion{}, done)\n+\tselect {\n+\tcase <-done:\n+\tcase <-time.After(time.Second):\n+\t\tt.Fatal(\"send duplicate version timeout\")\n+\t}\n+\n+\t// Ensure the peer that is the recipient of the duplicate version closes the\n+\t// connection.\n+\tdisconnected := make(chan struct{})\n+\tgo func() {\n+\t\tinPeer.WaitForDisconnect()\n+\t\tdisconnected <- struct{}{}\n+\t}()\n+\tselect {\n+\tcase <-disconnected:\n+\t\tclose(disconnected)","path":"peer/peer_test.go","position":61,"original_position":61,"commit_id":"e5cae2199c831915d36e39a66423bba04946b5c3","original_commit_id":"e5cae2199c831915d36e39a66423bba04946b5c3","user":{"login":"jrick","id":1420313,"node_id":"MDQ6VXNlcjE0MjAzMTM=","avatar_url":"https://avatars3.githubusercontent.com/u/1420313?v=4","gravatar_id":"","url":"https://api.github.com/users/jrick","html_url":"https://github.com/jrick","followers_url":"https://api.github.com/users/jrick/followers","following_url":"https://api.github.com/users/jrick/following{/other_user}","gists_url":"https://api.github.com/users/jrick/gists{/gist_id}","starred_url":"https://api.github.com/users/jrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrick/subscriptions","organizations_url":"https://api.github.com/users/jrick/orgs","repos_url":"https://api.github.com/users/jrick/repos","events_url":"https://api.github.com/users/jrick/events{/privacy}","received_events_url":"https://api.github.com/users/jrick/received_events","type":"User","site_admin":false},"body":"Actually, this would panic if the disconnect took more than a second to complete.  Would be better to buffer the channel and not close it, or use a select to send if ready.","created_at":"2018-06-04T15:55:35Z","updated_at":"2018-06-04T15:55:40Z","html_url":"https://github.com/decred/dcrd/pull/1248#discussion_r192792195","pull_request_url":"https://api.github.com/repos/decred/dcrd/pulls/1248","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/decred/dcrd/pulls/comments/192792195"},"html":{"href":"https://github.com/decred/dcrd/pull/1248#discussion_r192792195"},"pull_request":{"href":"https://api.github.com/repos/decred/dcrd/pulls/1248"}}},"pull_request":{"url":"https://api.github.com/repos/decred/dcrd/pulls/1248","id":192225878,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyMjI1ODc4","html_url":"https://github.com/decred/dcrd/pull/1248","diff_url":"https://github.com/decred/dcrd/pull/1248.diff","patch_url":"https://github.com/decred/dcrd/pull/1248.patch","issue_url":"https://api.github.com/repos/decred/dcrd/issues/1248","number":1248,"state":"open","locked":false,"title":"peer: Remove superfluous dup version check.","user":{"login":"davecgh","id":2115102,"node_id":"MDQ6VXNlcjIxMTUxMDI=","avatar_url":"https://avatars3.githubusercontent.com/u/2115102?v=4","gravatar_id":"","url":"https://api.github.com/users/davecgh","html_url":"https://github.com/davecgh","followers_url":"https://api.github.com/users/davecgh/followers","following_url":"https://api.github.com/users/davecgh/following{/other_user}","gists_url":"https://api.github.com/users/davecgh/gists{/gist_id}","starred_url":"https://api.github.com/users/davecgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecgh/subscriptions","organizations_url":"https://api.github.com/users/davecgh/orgs","repos_url":"https://api.github.com/users/davecgh/repos","events_url":"https://api.github.com/users/davecgh/events{/privacy}","received_events_url":"https://api.github.com/users/davecgh/received_events","type":"User","site_admin":false},"body":"**This relies on PR #1247**.\r\n\r\nThis removes an impossible to hit duplicate version check and adds a test to ensure the behavior is correct.\r\n\r\nPreviously, the check was necessary because the handler was a part of the input handler loop, however, the initial negotiation logic was refactored some time ago to be synchronous and thus it is no longer possible to receive a second version message in the refactored code path.\r\n","created_at":"2018-06-03T01:42:13Z","updated_at":"2018-06-04T15:55:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e556754e72533e42e81c8b68973b02416b0271f7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/decred/dcrd/milestones/21","html_url":"https://github.com/decred/dcrd/milestone/21","labels_url":"https://api.github.com/repos/decred/dcrd/milestones/21/labels","id":3278664,"node_id":"MDk6TWlsZXN0b25lMzI3ODY2NA==","number":21,"title":"1.3.0","description":"","creator":{"login":"davecgh","id":2115102,"node_id":"MDQ6VXNlcjIxMTUxMDI=","avatar_url":"https://avatars3.githubusercontent.com/u/2115102?v=4","gravatar_id":"","url":"https://api.github.com/users/davecgh","html_url":"https://github.com/davecgh","followers_url":"https://api.github.com/users/davecgh/followers","following_url":"https://api.github.com/users/davecgh/following{/other_user}","gists_url":"https://api.github.com/users/davecgh/gists{/gist_id}","starred_url":"https://api.github.com/users/davecgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecgh/subscriptions","organizations_url":"https://api.github.com/users/davecgh/orgs","repos_url":"https://api.github.com/users/davecgh/repos","events_url":"https://api.github.com/users/davecgh/events{/privacy}","received_events_url":"https://api.github.com/users/davecgh/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":50,"state":"open","created_at":"2018-04-18T16:53:15Z","updated_at":"2018-06-04T15:50:04Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/decred/dcrd/pulls/1248/commits","review_comments_url":"https://api.github.com/repos/decred/dcrd/pulls/1248/comments","review_comment_url":"https://api.github.com/repos/decred/dcrd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/decred/dcrd/issues/1248/comments","statuses_url":"https://api.github.com/repos/decred/dcrd/statuses/e5cae2199c831915d36e39a66423bba04946b5c3","head":{"label":"davecgh:peer_remove_superfluous_dup_version_check","ref":"peer_remove_superfluous_dup_version_check","sha":"e5cae2199c831915d36e39a66423bba04946b5c3","user":{"login":"davecgh","id":2115102,"node_id":"MDQ6VXNlcjIxMTUxMDI=","avatar_url":"https://avatars3.githubusercontent.com/u/2115102?v=4","gravatar_id":"","url":"https://api.github.com/users/davecgh","html_url":"https://github.com/davecgh","followers_url":"https://api.github.com/users/davecgh/followers","following_url":"https://api.github.com/users/davecgh/following{/other_user}","gists_url":"https://api.github.com/users/davecgh/gists{/gist_id}","starred_url":"https://api.github.com/users/davecgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecgh/subscriptions","organizations_url":"https://api.github.com/users/davecgh/orgs","repos_url":"https://api.github.com/users/davecgh/repos","events_url":"https://api.github.com/users/davecgh/events{/privacy}","received_events_url":"https://api.github.com/users/davecgh/received_events","type":"User","site_admin":false},"repo":{"id":16972952,"node_id":"MDEwOlJlcG9zaXRvcnkxNjk3Mjk1Mg==","name":"btcd","full_name":"davecgh/btcd","owner":{"login":"davecgh","id":2115102,"node_id":"MDQ6VXNlcjIxMTUxMDI=","avatar_url":"https://avatars3.githubusercontent.com/u/2115102?v=4","gravatar_id":"","url":"https://api.github.com/users/davecgh","html_url":"https://github.com/davecgh","followers_url":"https://api.github.com/users/davecgh/followers","following_url":"https://api.github.com/users/davecgh/following{/other_user}","gists_url":"https://api.github.com/users/davecgh/gists{/gist_id}","starred_url":"https://api.github.com/users/davecgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecgh/subscriptions","organizations_url":"https://api.github.com/users/davecgh/orgs","repos_url":"https://api.github.com/users/davecgh/repos","events_url":"https://api.github.com/users/davecgh/events{/privacy}","received_events_url":"https://api.github.com/users/davecgh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/davecgh/btcd","description":"An alternative full node bitcoin implementation written in Go (golang)","fork":true,"url":"https://api.github.com/repos/davecgh/btcd","forks_url":"https://api.github.com/repos/davecgh/btcd/forks","keys_url":"https://api.github.com/repos/davecgh/btcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davecgh/btcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davecgh/btcd/teams","hooks_url":"https://api.github.com/repos/davecgh/btcd/hooks","issue_events_url":"https://api.github.com/repos/davecgh/btcd/issues/events{/number}","events_url":"https://api.github.com/repos/davecgh/btcd/events","assignees_url":"https://api.github.com/repos/davecgh/btcd/assignees{/user}","branches_url":"https://api.github.com/repos/davecgh/btcd/branches{/branch}","tags_url":"https://api.github.com/repos/davecgh/btcd/tags","blobs_url":"https://api.github.com/repos/davecgh/btcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davecgh/btcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davecgh/btcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/davecgh/btcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davecgh/btcd/statuses/{sha}","languages_url":"https://api.github.com/repos/davecgh/btcd/languages","stargazers_url":"https://api.github.com/repos/davecgh/btcd/stargazers","contributors_url":"https://api.github.com/repos/davecgh/btcd/contributors","subscribers_url":"https://api.github.com/repos/davecgh/btcd/subscribers","subscription_url":"https://api.github.com/repos/davecgh/btcd/subscription","commits_url":"https://api.github.com/repos/davecgh/btcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/davecgh/btcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/davecgh/btcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/davecgh/btcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/davecgh/btcd/contents/{+path}","compare_url":"https://api.github.com/repos/davecgh/btcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davecgh/btcd/merges","archive_url":"https://api.github.com/repos/davecgh/btcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davecgh/btcd/downloads","issues_url":"https://api.github.com/repos/davecgh/btcd/issues{/number}","pulls_url":"https://api.github.com/repos/davecgh/btcd/pulls{/number}","milestones_url":"https://api.github.com/repos/davecgh/btcd/milestones{/number}","notifications_url":"https://api.github.com/repos/davecgh/btcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davecgh/btcd/labels{/name}","releases_url":"https://api.github.com/repos/davecgh/btcd/releases{/id}","deployments_url":"https://api.github.com/repos/davecgh/btcd/deployments","created_at":"2014-02-19T03:45:51Z","updated_at":"2018-02-01T05:07:30Z","pushed_at":"2018-06-04T15:51:21Z","git_url":"git://github.com/davecgh/btcd.git","ssh_url":"git@github.com:davecgh/btcd.git","clone_url":"https://github.com/davecgh/btcd.git","svn_url":"https://github.com/davecgh/btcd","homepage":null,"size":27774,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"isc","name":"ISC License","spdx_id":"ISC","url":"https://api.github.com/licenses/isc","node_id":"MDc6TGljZW5zZTEw"},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"decred:master","ref":"master","sha":"4840587397f73d557542e582e79103738bf08992","user":{"login":"decred","id":16297194,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2Mjk3MTk0","avatar_url":"https://avatars3.githubusercontent.com/u/16297194?v=4","gravatar_id":"","url":"https://api.github.com/users/decred","html_url":"https://github.com/decred","followers_url":"https://api.github.com/users/decred/followers","following_url":"https://api.github.com/users/decred/following{/other_user}","gists_url":"https://api.github.com/users/decred/gists{/gist_id}","starred_url":"https://api.github.com/users/decred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decred/subscriptions","organizations_url":"https://api.github.com/users/decred/orgs","repos_url":"https://api.github.com/users/decred/repos","events_url":"https://api.github.com/users/decred/events{/privacy}","received_events_url":"https://api.github.com/users/decred/received_events","type":"Organization","site_admin":false},"repo":{"id":50457080,"node_id":"MDEwOlJlcG9zaXRvcnk1MDQ1NzA4MA==","name":"dcrd","full_name":"decred/dcrd","owner":{"login":"decred","id":16297194,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE2Mjk3MTk0","avatar_url":"https://avatars3.githubusercontent.com/u/16297194?v=4","gravatar_id":"","url":"https://api.github.com/users/decred","html_url":"https://github.com/decred","followers_url":"https://api.github.com/users/decred/followers","following_url":"https://api.github.com/users/decred/following{/other_user}","gists_url":"https://api.github.com/users/decred/gists{/gist_id}","starred_url":"https://api.github.com/users/decred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decred/subscriptions","organizations_url":"https://api.github.com/users/decred/orgs","repos_url":"https://api.github.com/users/decred/repos","events_url":"https://api.github.com/users/decred/events{/privacy}","received_events_url":"https://api.github.com/users/decred/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/decred/dcrd","description":"Decred daemon in Go (golang).","fork":true,"url":"https://api.github.com/repos/decred/dcrd","forks_url":"https://api.github.com/repos/decred/dcrd/forks","keys_url":"https://api.github.com/repos/decred/dcrd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/decred/dcrd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/decred/dcrd/teams","hooks_url":"https://api.github.com/repos/decred/dcrd/hooks","issue_events_url":"https://api.github.com/repos/decred/dcrd/issues/events{/number}","events_url":"https://api.github.com/repos/decred/dcrd/events","assignees_url":"https://api.github.com/repos/decred/dcrd/assignees{/user}","branches_url":"https://api.github.com/repos/decred/dcrd/branches{/branch}","tags_url":"https://api.github.com/repos/decred/dcrd/tags","blobs_url":"https://api.github.com/repos/decred/dcrd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/decred/dcrd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/decred/dcrd/git/refs{/sha}","trees_url":"https://api.github.com/repos/decred/dcrd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/decred/dcrd/statuses/{sha}","languages_url":"https://api.github.com/repos/decred/dcrd/languages","stargazers_url":"https://api.github.com/repos/decred/dcrd/stargazers","contributors_url":"https://api.github.com/repos/decred/dcrd/contributors","subscribers_url":"https://api.github.com/repos/decred/dcrd/subscribers","subscription_url":"https://api.github.com/repos/decred/dcrd/subscription","commits_url":"https://api.github.com/repos/decred/dcrd/commits{/sha}","git_commits_url":"https://api.github.com/repos/decred/dcrd/git/commits{/sha}","comments_url":"https://api.github.com/repos/decred/dcrd/comments{/number}","issue_comment_url":"https://api.github.com/repos/decred/dcrd/issues/comments{/number}","contents_url":"https://api.github.com/repos/decred/dcrd/contents/{+path}","compare_url":"https://api.github.com/repos/decred/dcrd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/decred/dcrd/merges","archive_url":"https://api.github.com/repos/decred/dcrd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/decred/dcrd/downloads","issues_url":"https://api.github.com/repos/decred/dcrd/issues{/number}","pulls_url":"https://api.github.com/repos/decred/dcrd/pulls{/number}","milestones_url":"https://api.github.com/repos/decred/dcrd/milestones{/number}","notifications_url":"https://api.github.com/repos/decred/dcrd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/decred/dcrd/labels{/name}","releases_url":"https://api.github.com/repos/decred/dcrd/releases{/id}","deployments_url":"https://api.github.com/repos/decred/dcrd/deployments","created_at":"2016-01-26T20:28:42Z","updated_at":"2018-06-04T15:50:07Z","pushed_at":"2018-06-04T15:51:22Z","git_url":"git://github.com/decred/dcrd.git","ssh_url":"git@github.com:decred/dcrd.git","clone_url":"https://github.com/decred/dcrd.git","svn_url":"https://github.com/decred/dcrd","homepage":"https://decred.org","size":24190,"stargazers_count":380,"watchers_count":380,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":137,"mirror_url":null,"archived":false,"open_issues_count":59,"license":{"key":"isc","name":"ISC License","spdx_id":"ISC","url":"https://api.github.com/licenses/isc","node_id":"MDc6TGljZW5zZTEw"},"forks":137,"open_issues":59,"watchers":380,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/decred/dcrd/pulls/1248"},"html":{"href":"https://github.com/decred/dcrd/pull/1248"},"issue":{"href":"https://api.github.com/repos/decred/dcrd/issues/1248"},"comments":{"href":"https://api.github.com/repos/decred/dcrd/issues/1248/comments"},"review_comments":{"href":"https://api.github.com/repos/decred/dcrd/pulls/1248/comments"},"review_comment":{"href":"https://api.github.com/repos/decred/dcrd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/decred/dcrd/pulls/1248/commits"},"statuses":{"href":"https://api.github.com/repos/decred/dcrd/statuses/e5cae2199c831915d36e39a66423bba04946b5c3"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jrick"}}