{"action":"created","comment":{"url":"https://api.github.com/repos/maidsafe/routing/pulls/comments/169941215","pull_request_review_id":98547355,"id":169941215,"diff_hunk":"@@ -185,3 +171,309 @@ impl Chain {\n         }\n     }\n }\n+\n+impl Debug for Chain {\n+    fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {\n+        writeln!(formatter, \"Chain {{\")?;\n+        writeln!(formatter, \"    group_size: {},\", self.group_size)?;\n+        writeln!(formatter, \"    path: {:?},\", self.path)?;\n+        writeln!(formatter, \"    blocks:\")?;\n+        for block in &self.blocks {\n+            writeln!(\n+                formatter,\n+                \"        {:?} signed by {:?},\",\n+                block.payload(),\n+                block.proofs()\n+            )?;\n+        }\n+        writeln!(formatter, \"    valid_nodes:\")?;\n+        for block in &self.valid_nodes {\n+            writeln!(\n+                formatter,\n+                \"        {:?},\",\n+                block.payload(),\n+            )?;\n+        }\n+        writeln!(formatter, \"    data:\")?;\n+        for block in &self.data {\n+            writeln!(\n+                formatter,\n+                \"        {:?} signed by {:?},\",\n+                block.payload(),\n+                block.proofs()\n+            )?;\n+        }\n+        writeln!(formatter, \"    pending_blocks:\")?;\n+        for block in &self.pending_blocks {\n+            writeln!(\n+                formatter,\n+                \"        {:?} signed by {:?},\",\n+                block.payload(),\n+                block.proofs()\n+            )?;\n+        }\n+        writeln!(formatter, \"}}\")\n+    }\n+}\n+\n+#[cfg(test)]\n+mod tests {\n+    use super::*;\n+    use super::super::tests;\n+    use data_chain::{NodeState, Proof, State};\n+    use full_info::FullInfo;\n+    use maidsafe_utilities::SeededRng;\n+    use rand::Rng;\n+    use routing_table::Prefix;\n+    use rust_sodium;\n+\n+    #[ignore]\n+    #[test]\n+    fn pending_blocks() {\n+        // Start with the chain having Live(A).  Create blocks for Offline(A), Live(B), and\n+        // Relocated(B), Live(C).  Add the four of them in reverse order and assert after each is\n+        // added that they're held in the `pending_blocks` until the final one is added and they can\n+        // all be added to the chain in the order defined above.\n+        let mut rng = SeededRng::thread_rng();\n+        unwrap!(rust_sodium::init_with_rng(&mut rng));\n+\n+        let prefix = Prefix::default().pushed(rng.gen()).with_version(rng.gen());\n+        let nodes = tests::create_full_infos(Some(prefix));\n+\n+        // Create Live(A) and Offline(A).\n+        let node_a = FullInfo::within_range(5, &prefix.lower_bound(), &prefix.upper_bound());\n+        let mut payload = NodeState {\n+            state: State::ElderLive,\n+            public_key: *node_a.public_info().sign_key(),\n+            age: node_a.public_info().age(),\n+            section: prefix,\n+        };\n+        let live_a = tests::create_block(payload, &nodes, false);\n+        payload = NodeState {\n+            state: State::ElderOffline,\n+            public_key: *node_a.public_info().sign_key(),\n+            age: node_a.public_info().age(),\n+            section: prefix,\n+        };\n+        let offline_a = tests::create_block(payload, &nodes, false);\n+\n+        // Create Live(B) and Relocated(B).\n+        let node_b = FullInfo::within_range(6, &prefix.lower_bound(), &prefix.upper_bound());\n+        payload = NodeState {\n+            state: State::ElderLive,\n+            public_key: *node_b.public_info().sign_key(),\n+            age: node_b.public_info().age(),\n+            section: prefix,\n+        };\n+        let live_b = tests::create_block(payload, &nodes, false);\n+        payload = NodeState {\n+            state: State::ElderRelocated,\n+            public_key: *node_b.public_info().sign_key(),\n+            age: node_b.public_info().age(),\n+            section: prefix,\n+        };\n+        let relocated_b = tests::create_block(payload, &nodes, false);\n+\n+        // Create Live(C).\n+        let node_c = FullInfo::within_range(7, &prefix.lower_bound(), &prefix.upper_bound());\n+        payload = NodeState {\n+            state: State::ElderLive,\n+            public_key: *node_c.public_info().sign_key(),\n+            age: node_c.public_info().age(),\n+            section: prefix,\n+        };\n+        let live_c = tests::create_block(payload, &nodes, false);\n+\n+        // Create chain containing just Live(A).\n+        let mut chain = Chain::from_blocks(vec![live_a.clone()], vec![], nodes.len());","path":"src/data_chain/chain.rs","position":220,"original_position":220,"commit_id":"b4d66eaf5e9412f601d1933b5328e77604ce16dc","original_commit_id":"b4d66eaf5e9412f601d1933b5328e77604ce16dc","user":{"login":"Fraser999","id":190532,"avatar_url":"https://avatars3.githubusercontent.com/u/190532?v=4","gravatar_id":"","url":"https://api.github.com/users/Fraser999","html_url":"https://github.com/Fraser999","followers_url":"https://api.github.com/users/Fraser999/followers","following_url":"https://api.github.com/users/Fraser999/following{/other_user}","gists_url":"https://api.github.com/users/Fraser999/gists{/gist_id}","starred_url":"https://api.github.com/users/Fraser999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fraser999/subscriptions","organizations_url":"https://api.github.com/users/Fraser999/orgs","repos_url":"https://api.github.com/users/Fraser999/repos","events_url":"https://api.github.com/users/Fraser999/events{/privacy}","received_events_url":"https://api.github.com/users/Fraser999/received_events","type":"User","site_admin":false},"body":"We already have a dev config option for this.  How about if I do:\r\n```rust\r\nlet group_size = nodes.len();\r\nlet mut chain = Chain::from_blocks(vec![live_a.clone()], vec![], group_size);\r\n```","created_at":"2018-02-22T12:32:08Z","updated_at":"2018-02-22T12:32:08Z","html_url":"https://github.com/maidsafe/routing/pull/1542#discussion_r169941215","pull_request_url":"https://api.github.com/repos/maidsafe/routing/pulls/1542","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/maidsafe/routing/pulls/comments/169941215"},"html":{"href":"https://github.com/maidsafe/routing/pull/1542#discussion_r169941215"},"pull_request":{"href":"https://api.github.com/repos/maidsafe/routing/pulls/1542"}},"in_reply_to_id":169897537},"pull_request":{"url":"https://api.github.com/repos/maidsafe/routing/pulls/1542","id":170537465,"html_url":"https://github.com/maidsafe/routing/pull/1542","diff_url":"https://github.com/maidsafe/routing/pull/1542.diff","patch_url":"https://github.com/maidsafe/routing/pull/1542.patch","issue_url":"https://api.github.com/repos/maidsafe/routing/issues/1542","number":1542,"state":"open","locked":false,"title":"MAID-2469: add unit tests for chain","user":{"login":"Fraser999","id":190532,"avatar_url":"https://avatars3.githubusercontent.com/u/190532?v=4","gravatar_id":"","url":"https://api.github.com/users/Fraser999","html_url":"https://github.com/Fraser999","followers_url":"https://api.github.com/users/Fraser999/followers","following_url":"https://api.github.com/users/Fraser999/following{/other_user}","gists_url":"https://api.github.com/users/Fraser999/gists{/gist_id}","starred_url":"https://api.github.com/users/Fraser999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fraser999/subscriptions","organizations_url":"https://api.github.com/users/Fraser999/orgs","repos_url":"https://api.github.com/users/Fraser999/repos","events_url":"https://api.github.com/users/Fraser999/events{/privacy}","received_events_url":"https://api.github.com/users/Fraser999/received_events","type":"User","site_admin":false},"body":"Also added some Debug impls and moved test helpers to avoid code duplication.","created_at":"2018-02-21T17:28:18Z","updated_at":"2018-02-22T12:32:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff2d21c674ee3ecc41404625382f212082a98011","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/maidsafe/routing/pulls/1542/commits","review_comments_url":"https://api.github.com/repos/maidsafe/routing/pulls/1542/comments","review_comment_url":"https://api.github.com/repos/maidsafe/routing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/maidsafe/routing/issues/1542/comments","statuses_url":"https://api.github.com/repos/maidsafe/routing/statuses/b4d66eaf5e9412f601d1933b5328e77604ce16dc","head":{"label":"Fraser999:MAID-2469","ref":"MAID-2469","sha":"b4d66eaf5e9412f601d1933b5328e77604ce16dc","user":{"login":"Fraser999","id":190532,"avatar_url":"https://avatars3.githubusercontent.com/u/190532?v=4","gravatar_id":"","url":"https://api.github.com/users/Fraser999","html_url":"https://github.com/Fraser999","followers_url":"https://api.github.com/users/Fraser999/followers","following_url":"https://api.github.com/users/Fraser999/following{/other_user}","gists_url":"https://api.github.com/users/Fraser999/gists{/gist_id}","starred_url":"https://api.github.com/users/Fraser999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fraser999/subscriptions","organizations_url":"https://api.github.com/users/Fraser999/orgs","repos_url":"https://api.github.com/users/Fraser999/repos","events_url":"https://api.github.com/users/Fraser999/events{/privacy}","received_events_url":"https://api.github.com/users/Fraser999/received_events","type":"User","site_admin":false},"repo":{"id":32315702,"name":"routing","full_name":"Fraser999/routing","owner":{"login":"Fraser999","id":190532,"avatar_url":"https://avatars3.githubusercontent.com/u/190532?v=4","gravatar_id":"","url":"https://api.github.com/users/Fraser999","html_url":"https://github.com/Fraser999","followers_url":"https://api.github.com/users/Fraser999/followers","following_url":"https://api.github.com/users/Fraser999/following{/other_user}","gists_url":"https://api.github.com/users/Fraser999/gists{/gist_id}","starred_url":"https://api.github.com/users/Fraser999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fraser999/subscriptions","organizations_url":"https://api.github.com/users/Fraser999/orgs","repos_url":"https://api.github.com/users/Fraser999/repos","events_url":"https://api.github.com/users/Fraser999/events{/privacy}","received_events_url":"https://api.github.com/users/Fraser999/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Fraser999/routing","description":"Routing - specialised storage DHT","fork":true,"url":"https://api.github.com/repos/Fraser999/routing","forks_url":"https://api.github.com/repos/Fraser999/routing/forks","keys_url":"https://api.github.com/repos/Fraser999/routing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Fraser999/routing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Fraser999/routing/teams","hooks_url":"https://api.github.com/repos/Fraser999/routing/hooks","issue_events_url":"https://api.github.com/repos/Fraser999/routing/issues/events{/number}","events_url":"https://api.github.com/repos/Fraser999/routing/events","assignees_url":"https://api.github.com/repos/Fraser999/routing/assignees{/user}","branches_url":"https://api.github.com/repos/Fraser999/routing/branches{/branch}","tags_url":"https://api.github.com/repos/Fraser999/routing/tags","blobs_url":"https://api.github.com/repos/Fraser999/routing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Fraser999/routing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Fraser999/routing/git/refs{/sha}","trees_url":"https://api.github.com/repos/Fraser999/routing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Fraser999/routing/statuses/{sha}","languages_url":"https://api.github.com/repos/Fraser999/routing/languages","stargazers_url":"https://api.github.com/repos/Fraser999/routing/stargazers","contributors_url":"https://api.github.com/repos/Fraser999/routing/contributors","subscribers_url":"https://api.github.com/repos/Fraser999/routing/subscribers","subscription_url":"https://api.github.com/repos/Fraser999/routing/subscription","commits_url":"https://api.github.com/repos/Fraser999/routing/commits{/sha}","git_commits_url":"https://api.github.com/repos/Fraser999/routing/git/commits{/sha}","comments_url":"https://api.github.com/repos/Fraser999/routing/comments{/number}","issue_comment_url":"https://api.github.com/repos/Fraser999/routing/issues/comments{/number}","contents_url":"https://api.github.com/repos/Fraser999/routing/contents/{+path}","compare_url":"https://api.github.com/repos/Fraser999/routing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Fraser999/routing/merges","archive_url":"https://api.github.com/repos/Fraser999/routing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Fraser999/routing/downloads","issues_url":"https://api.github.com/repos/Fraser999/routing/issues{/number}","pulls_url":"https://api.github.com/repos/Fraser999/routing/pulls{/number}","milestones_url":"https://api.github.com/repos/Fraser999/routing/milestones{/number}","notifications_url":"https://api.github.com/repos/Fraser999/routing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Fraser999/routing/labels{/name}","releases_url":"https://api.github.com/repos/Fraser999/routing/releases{/id}","deployments_url":"https://api.github.com/repos/Fraser999/routing/deployments","created_at":"2015-03-16T09:53:56Z","updated_at":"2016-01-11T11:52:43Z","pushed_at":"2018-02-21T17:22:26Z","git_url":"git://github.com/Fraser999/routing.git","ssh_url":"git@github.com:Fraser999/routing.git","clone_url":"https://github.com/Fraser999/routing.git","svn_url":"https://github.com/Fraser999/routing","homepage":null,"size":12092,"stargazers_count":0,"watchers_count":0,"language":"Rust","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":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"maidsafe:dev","ref":"dev","sha":"48d2952ff1ac493808df38c5b97ae8b944e60020","user":{"login":"maidsafe","id":536423,"avatar_url":"https://avatars1.githubusercontent.com/u/536423?v=4","gravatar_id":"","url":"https://api.github.com/users/maidsafe","html_url":"https://github.com/maidsafe","followers_url":"https://api.github.com/users/maidsafe/followers","following_url":"https://api.github.com/users/maidsafe/following{/other_user}","gists_url":"https://api.github.com/users/maidsafe/gists{/gist_id}","starred_url":"https://api.github.com/users/maidsafe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maidsafe/subscriptions","organizations_url":"https://api.github.com/users/maidsafe/orgs","repos_url":"https://api.github.com/users/maidsafe/repos","events_url":"https://api.github.com/users/maidsafe/events{/privacy}","received_events_url":"https://api.github.com/users/maidsafe/received_events","type":"Organization","site_admin":false},"repo":{"id":31270514,"name":"routing","full_name":"maidsafe/routing","owner":{"login":"maidsafe","id":536423,"avatar_url":"https://avatars1.githubusercontent.com/u/536423?v=4","gravatar_id":"","url":"https://api.github.com/users/maidsafe","html_url":"https://github.com/maidsafe","followers_url":"https://api.github.com/users/maidsafe/followers","following_url":"https://api.github.com/users/maidsafe/following{/other_user}","gists_url":"https://api.github.com/users/maidsafe/gists{/gist_id}","starred_url":"https://api.github.com/users/maidsafe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maidsafe/subscriptions","organizations_url":"https://api.github.com/users/maidsafe/orgs","repos_url":"https://api.github.com/users/maidsafe/repos","events_url":"https://api.github.com/users/maidsafe/events{/privacy}","received_events_url":"https://api.github.com/users/maidsafe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/maidsafe/routing","description":"Routing - specialised storage DHT","fork":false,"url":"https://api.github.com/repos/maidsafe/routing","forks_url":"https://api.github.com/repos/maidsafe/routing/forks","keys_url":"https://api.github.com/repos/maidsafe/routing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maidsafe/routing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maidsafe/routing/teams","hooks_url":"https://api.github.com/repos/maidsafe/routing/hooks","issue_events_url":"https://api.github.com/repos/maidsafe/routing/issues/events{/number}","events_url":"https://api.github.com/repos/maidsafe/routing/events","assignees_url":"https://api.github.com/repos/maidsafe/routing/assignees{/user}","branches_url":"https://api.github.com/repos/maidsafe/routing/branches{/branch}","tags_url":"https://api.github.com/repos/maidsafe/routing/tags","blobs_url":"https://api.github.com/repos/maidsafe/routing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maidsafe/routing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maidsafe/routing/git/refs{/sha}","trees_url":"https://api.github.com/repos/maidsafe/routing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maidsafe/routing/statuses/{sha}","languages_url":"https://api.github.com/repos/maidsafe/routing/languages","stargazers_url":"https://api.github.com/repos/maidsafe/routing/stargazers","contributors_url":"https://api.github.com/repos/maidsafe/routing/contributors","subscribers_url":"https://api.github.com/repos/maidsafe/routing/subscribers","subscription_url":"https://api.github.com/repos/maidsafe/routing/subscription","commits_url":"https://api.github.com/repos/maidsafe/routing/commits{/sha}","git_commits_url":"https://api.github.com/repos/maidsafe/routing/git/commits{/sha}","comments_url":"https://api.github.com/repos/maidsafe/routing/comments{/number}","issue_comment_url":"https://api.github.com/repos/maidsafe/routing/issues/comments{/number}","contents_url":"https://api.github.com/repos/maidsafe/routing/contents/{+path}","compare_url":"https://api.github.com/repos/maidsafe/routing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maidsafe/routing/merges","archive_url":"https://api.github.com/repos/maidsafe/routing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maidsafe/routing/downloads","issues_url":"https://api.github.com/repos/maidsafe/routing/issues{/number}","pulls_url":"https://api.github.com/repos/maidsafe/routing/pulls{/number}","milestones_url":"https://api.github.com/repos/maidsafe/routing/milestones{/number}","notifications_url":"https://api.github.com/repos/maidsafe/routing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maidsafe/routing/labels{/name}","releases_url":"https://api.github.com/repos/maidsafe/routing/releases{/id}","deployments_url":"https://api.github.com/repos/maidsafe/routing/deployments","created_at":"2015-02-24T16:52:53Z","updated_at":"2018-02-12T15:27:58Z","pushed_at":"2018-02-22T10:36:54Z","git_url":"git://github.com/maidsafe/routing.git","ssh_url":"git@github.com:maidsafe/routing.git","clone_url":"https://github.com/maidsafe/routing.git","svn_url":"https://github.com/maidsafe/routing","homepage":null,"size":112178,"stargazers_count":171,"watchers_count":171,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":47,"mirror_url":null,"archived":false,"open_issues_count":7,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":47,"open_issues":7,"watchers":171,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/maidsafe/routing/pulls/1542"},"html":{"href":"https://github.com/maidsafe/routing/pull/1542"},"issue":{"href":"https://api.github.com/repos/maidsafe/routing/issues/1542"},"comments":{"href":"https://api.github.com/repos/maidsafe/routing/issues/1542/comments"},"review_comments":{"href":"https://api.github.com/repos/maidsafe/routing/pulls/1542/comments"},"review_comment":{"href":"https://api.github.com/repos/maidsafe/routing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/maidsafe/routing/pulls/1542/commits"},"statuses":{"href":"https://api.github.com/repos/maidsafe/routing/statuses/b4d66eaf5e9412f601d1933b5328e77604ce16dc"}},"author_association":"OWNER"}}
{"actor":{"display_login":"Fraser999"}}