forked from MASQ-Project/Node
-
Notifications
You must be signed in to change notification settings - Fork 0
GH-692: Self Review #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
utkarshg6
wants to merge
48
commits into
master
Choose a base branch
from
GH-692
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
7ad9ecb
GH-692: ignore file dbnavigator.xml
utkarshg6 befaf62
GH-692: add tests for command execution of set-configuration
utkarshg6 60ba1af
GH-692: revert the version number
utkarshg6 1c05e69
GH-692: add test for the error case
utkarshg6 852b928
GH-692: improve tests to work on macos
utkarshg6 1880543
GH-692: improve tests to work on macos
utkarshg6 2861594
GH-692: ignore dbnavigator.xml
utkarshg6 2059fc5
Merge remote-tracking branch 'upstream/GH-692' into GH-692
utkarshg6 edf2e52
GH-692: remove the redundant gitignore line
utkarshg6 afed349
Merge branch 'master' into GH-692
utkarshg6 96a1201
GH-692: add tests for setting min_hops using set-configuration
utkarshg6 aee599d
GH-692: add TODOs
utkarshg6 69110ee
GH-692: migrate the Consuming Wallet change and Password Change to a …
utkarshg6 d5d4970
GH-692: update field names inside SetConfigurationMessage and variant…
utkarshg6 782a5d1
GH-692: update field names inside SetConfigurationMessage and variant…
utkarshg6 48759b9
GH-692: write test can_update_min_hops_with_set_configuration_msg
utkarshg6 651f596
GH-692: set min hops value in db inside node_configurator/configurato…
utkarshg6 b3a9e28
GH-692: only change value of min hops in neighborhood using SetConfig…
utkarshg6 057f8de
Merge remote-tracking branch 'upstream/GH-692' into GH-692
utkarshg6 d587c65
GH-691: write more tests for setting min hops inside the node_configu…
utkarshg6 77fa3ef
GH-692: an attempt to remove the SetConsumingWalletMessage
utkarshg6 27d3381
GH-692: remove SetConsumingWalletMessage from all the other places be…
utkarshg6 294b23e
GH-692: remove the SetConsumingWalletMessage completely
utkarshg6 ced2827
GH-692: remove NewPasswordMessage
utkarshg6 160ad60
GH-692: replace NewPasswordMessage with SetConfigurationMessage
utkarshg6 a5ced94
GH-692: add test for UpdateNewPassword inside configurator.rs
utkarshg6 6bc25ce
GH-692: write more tests for the configurator.rs
utkarshg6 191c519
GH-692: improve test handle_set_configuration_handles_failure_on_min_…
utkarshg6 d3ea0a8
GH-692: change name of message to ConfigurationChangeMessage
utkarshg6 a2b5fce
GH-691: implement calculate_db_patch_size()
utkarshg6 23b3278
GH-692: add the fn to set_min_hops_and_db_patch_size()
utkarshg6 9d6e170
GH-692: set db_patch_size while setting min_hops
utkarshg6 c2a93dc
GH-692: completely remove NewPasswordMessage
utkarshg6 9387f39
GH-692: drive code for setting up patch size inside NeighborhoodMetadata
utkarshg6 279676a
GH-692: use db_patch_size or patch_size instead of min_hops while com…
utkarshg6 cca49aa
GH-692: remove redundant functions
utkarshg6 f4d840d
GH-692: formatting changes
utkarshg6 04d3ef3
GH-692: ignore the stray test - ci/all.sh is passing
utkarshg6 9d4cb4e
GH-692: migrate min_hops test to a new file in multinode tests
utkarshg6 b4cd8f3
GH-692: attempt to write multinode test
utkarshg6 09fa560
GH-692: why is this working? and not the previous version
utkarshg6 c897f0d
GH-692: improve multinode test
utkarshg6 91fa8ce
GH-692: test drive the RouteQuery after the min hops has been changed
utkarshg6 ed23d60
GH-692: refactor the neighborhood/mod.rs file
utkarshg6 9798e25
GH-692: min hops multinode test is passing
utkarshg6 cd034a3
GH-692: improve multinode test with better comments and refactoring
utkarshg6 ff31829
GH-692: improve logging inside Neighborhood and Configurator
utkarshg6 eda810b
GH-692: another formatting changes
utkarshg6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. | ||
|
|
||
| use masq_lib::messages::{ToMessageBody, UiSetConfigurationRequest}; | ||
| use masq_lib::utils::{find_free_port, index_of}; | ||
| use multinode_integration_tests_lib::masq_node::MASQNode; | ||
| use multinode_integration_tests_lib::masq_node_cluster::MASQNodeCluster; | ||
| use multinode_integration_tests_lib::masq_real_node::{ | ||
| make_consuming_wallet_info, MASQRealNode, NodeStartupConfigBuilder, | ||
| }; | ||
| use node_lib::sub_lib::neighborhood::Hops; | ||
| use std::thread; | ||
| use std::time::Duration; | ||
|
|
||
| #[test] | ||
| fn http_end_to_end_routing_test_with_different_min_hops() { | ||
| // This test fails sometimes due to a timeout: "Couldn't read chunk: Kind(TimedOut)" | ||
| // You may fix it by increasing the timeout for the client. | ||
| assert_http_end_to_end_routing_test(Hops::OneHop); | ||
| assert_http_end_to_end_routing_test(Hops::TwoHops); | ||
| assert_http_end_to_end_routing_test(Hops::SixHops); | ||
| } | ||
|
|
||
| fn assert_http_end_to_end_routing_test(min_hops: Hops) { | ||
| let mut cluster = MASQNodeCluster::start().unwrap(); | ||
| let config = NodeStartupConfigBuilder::standard() | ||
| .min_hops(min_hops) | ||
| .chain(cluster.chain) | ||
| .consuming_wallet_info(make_consuming_wallet_info("first_node")) | ||
| .build(); | ||
| let first_node = cluster.start_real_node(config); | ||
|
|
||
| let nodes_count = 2 * (min_hops as usize) + 1; | ||
| let nodes = (0..nodes_count) | ||
| .map(|_| { | ||
| cluster.start_real_node( | ||
| NodeStartupConfigBuilder::standard() | ||
| .neighbor(first_node.node_reference()) | ||
| .chain(cluster.chain) | ||
| .build(), | ||
| ) | ||
| }) | ||
| .collect::<Vec<MASQRealNode>>(); | ||
|
|
||
| thread::sleep(Duration::from_millis(500 * (nodes.len() as u64))); | ||
|
|
||
| let mut client = first_node.make_client(8080, 5000); | ||
| client.send_chunk(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); | ||
| let response = client.wait_for_chunk(); | ||
|
|
||
| assert_eq!( | ||
| index_of(&response, &b"<h1>Example Domain</h1>"[..]).is_some(), | ||
| true, | ||
| "Actual response:\n{}", | ||
| String::from_utf8(response).unwrap() | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn min_hops_can_be_changed_during_runtime() { | ||
| let initial_min_hops = Hops::OneHop; | ||
| let new_min_hops = Hops::TwoHops; | ||
| let mut cluster = MASQNodeCluster::start().unwrap(); | ||
| let ui_port = find_free_port(); | ||
| let first_node_config = NodeStartupConfigBuilder::standard() | ||
| .min_hops(initial_min_hops) | ||
| .chain(cluster.chain) | ||
| .consuming_wallet_info(make_consuming_wallet_info("first_node")) | ||
| .ui_port(ui_port) | ||
| .build(); | ||
| let first_node = cluster.start_real_node(first_node_config); | ||
| let ui_client = first_node.make_ui(ui_port); | ||
| let mut prev_node_reference = first_node.node_reference(); | ||
utkarshg6 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| for _ in 0..initial_min_hops as u8 { | ||
| let new_node_config = NodeStartupConfigBuilder::standard() | ||
| .neighbor(prev_node_reference) | ||
| .chain(cluster.chain) | ||
| .build(); | ||
| let new_node = cluster.start_real_node(new_node_config); | ||
utkarshg6 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| prev_node_reference = new_node.node_reference(); | ||
| } | ||
| thread::sleep(Duration::from_millis(1000)); | ||
|
|
||
| let mut client = first_node.make_client(8080, 5000); | ||
| client.send_chunk(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); | ||
| let response = client.wait_for_chunk(); | ||
|
|
||
| // Client shutdown is necessary to re-initialize stream keys for old requests | ||
| client.shutdown(); | ||
|
|
||
| assert_eq!( | ||
| index_of(&response, &b"<h1>Example Domain</h1>"[..]).is_some(), | ||
| true, | ||
| "Actual response:\n{}", | ||
| String::from_utf8(response).unwrap() | ||
| ); | ||
|
|
||
| ui_client.send_request( | ||
| UiSetConfigurationRequest { | ||
| name: "min-hops".to_string(), | ||
| value: new_min_hops.to_string(), | ||
| } | ||
| .tmb(1), | ||
| ); | ||
| let response = ui_client.wait_for_response(1, Duration::from_secs(2)); | ||
| assert!(response.payload.is_ok()); | ||
|
|
||
| let mut client = first_node.make_client(8080, 5000); | ||
| client.send_chunk(b"GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); | ||
| let response = client.wait_for_chunk(); | ||
| assert_eq!( | ||
| index_of( | ||
| &response, | ||
| &b"<h3>Subtitle: Can't find a route to www.example.com</h3>"[..] | ||
| ) | ||
| .is_some(), | ||
| true, | ||
| "Actual response:\n{}", | ||
| String::from_utf8(response).unwrap() | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.