Skip to content

Commit 0b26033

Browse files
utkarshg6BertFinsaasGHkauri-herobertllll
authored
GH-574: Overall Connection Status of a Node with the MASQ Network (#136)
* GH-574: feat - create initial skeleton for new node's connection * GH-574: feat - add empty connect_to_masq_network() * GH-574: feat - add overall_connection_status and it's impl block with tests * GH-574: feat - add test and code for the remove() * GH-574: refactor - remove unnecessary comments and update explanation for fields and variants * GH-574: feat - add ConnectionProgressMessage to neighborhood.rs along with it's subscriber and handler * GH-574: - add update_connection_stage() to overall_connection_status * GH-574: trying to write test for connection_progress_message - switching to Bert * GH-574: test established, implementation can begin * GH-574: migrate AssertionMessage to test_utils/mod.rs and write code inside ConnectionProgressMessage handler * GH-574: add ConnectionProgressMessage for TcpConnectionFailed * GH-574: feat - test drive and change unwrap() to expect(); rename 'Internal Error' to 'Neighborhood Unbound' * GH-574: rename tell_neighorhood and other small fixes * GH-574: add AskAboutDebutGossipResponseMessage to neighborhood.rs * GH-574: add the ability to panic in case we're skipping updation of stage * GH-574: add boilerplate for handling AskAboutDebutGossipResponseMessage * GH-574: test drive the event TcpConnectionFailed * GH-574: improve test node_gossips_to_neighbors_on_startup * feat: change NodeDescriptor to IpAddr for the overall_connection_status * GH-574: add an expect in send_debut_gossip and eliminate a test * GH-574: fix the expect statement by adding as_ref() * GH-574: add ability to receive cpm_recipient inside GossipHandler via GossipAcceptorReal from Neighborhood; modify PassHandler to send CPM for Pass Gossip * GH-574: add a test to verify whether bind message is populating gossip acceptor and producer; fixed another test * GH-574: test drive the constructor for pass handler * GH-574: remove previous_pass_targets from the overall_connection_status * GH-574: Add Support for timestamp while handling pass gossip * GH-574: migrate previous_pass_targets to gossip_acceptors and add tests for various cases * GH-574: timestamp the pass targets received and update hashmap accordingly * GH-574: allow neighborhood to handle CPM for Pass Gossips and OCS can update Connection Progress * GH-574: neighborhood and OCS can handle CPM for event DeadEndFound * GH-574: add the handler for AskAboutDebutGossipMessage; test event NoGossipResponseReceived * GH-574: test drove CPM for Introduction Gossip * GH-574: add a fn to check full neighborship by gossip source's ip * GH-574: segregate standard gossips into 4 cases by checking full neighborship before and after db changes * GH-574: test drive the cases for StandardGossipReceived, IntroductionGossipReceived and NoGossipResponseReceived * GH-574: refactor the handle() for StandardGossipHandler * GH-574: fix the failing test inside gossip_acceptor.rs * GH-574: add the ability to update the stages of overall_connection_status * GH-574: refactored the handle() of CPM * GH-574: rename the fn from get_connection_progress() to get_connection_progress_by_ip() * GH-574: refactor the handle_pass_gossip() * GH-574: refactor tests in overall_connection_status.rs * GH-574: add Node to UI Message named UiConnectionChangeBroadcast * GH-574: send message to the ui for the advancing stages of overall connection * GH-574: fix failing tests in neighborhood/mod.rs by providing recipient of node_to_ui and remove some compiler warnings * GH-574: remove most of the compiler warnings * GH-574: remove all the compiler warnings * GH-574: add suffix _opt to variabled storing Option<T> in src/neighborhood/mod.rs * GH-574: fix the clippy warnings * GH-574: fix the test setup_results_are_broadcast_to_all_uis_integration * GH-574: minor refactoring changes * GH-574: fix ubuntu build by making the constant public * GH-574: change the panic message inside masq/tests/utils.rs * GH-574: change interval for starting DaemonProcess in tests to 5s and remove relative thread sleeps * GH-574: change the thread sleep to 10_000ms in the test provided_and_consumed_services_are_recorded_in_databases * GH-574: add review changes for gossip_acceptor.rs * GH-574: add review changes for neighborhood.rs and stream_handler_pool.rs * GH-574: refactor tests in neighborhood/mod.rs * GH-574: rename DeadEndFound to PassLoopFound * GH-574: add review changes for src/neighborhood/mod.rs * GH-574: add review changes for overall_connection_status.rs and neighborhood_test_utils.rs * GH-574: add a generalized fn for building recipients * GH-574: fix the handle() of StandardGossip * GH-574: add test progress_done_by_one_connection_progress_can_not_be_overridden_by_other_in_overall_connection_progress * GH-574: parameterize test regarding gossip and can_make_routes bool into 4 tests * GH-574: make ConnectionProgress owner of initial_node_descriptors and remove clone * GH-574: add some helper functions in overall_connection_status.rs * GH-574: make helper function make_node_and_recipient() * GH-574: migrate helper functions to neighborhood_test_utils.rs * GH-574: refactored the helper fn result_when_neighborship_is_established_and_can_make_routes_is_updated * GH-574: refactor two more tests that doesn't sends any message to the UI * GH-574: use make_ip() to create a new ip for tests * GH-574: add minor refactor changes to overall_connection_status.rs * GH-574: rename utility fn to make_descriptor() * GH-574: rename fn names and make pub key using string name in fn make_node_descriptor() (#142) * Gh 574 merge master (#144) * Docs/contributing plus cleanup (#138) * update Practice with reference to version & QA * update practice with version release info * DRAFT: Update docs/branch (#133) * Update node top level README add list of component README files for easy navigation * Added reference to UI-Interface-Interface Added reference to UI-Interface-Interface document that lives in the Node repo main folder * Update README.md * Delete SHRD-faucet This is no longer usable and is not connected to the MASQ token contracts * Update to blockchain service details Update to blockchain service details about Polygon, testnets, Alchemy also removed old images * wording and formattting * update LICENSE updated with corrected copyright for MASQ, and added info regarding previous codebase being removed from GitHub and original repo disappeared * Update Practice with QA blurb Thanks Stew * adjust copyright * remove old DNS doc * remove old DNS doc * remove old DNS doc * delete old faucet info * updated with component readmes * remove old logo * remove old logo2 * Create brand-guidelines.md * add masq logos * remove to move logos * add masq logos * added masq logo to readme * update from reviews * update and copyright bump * copyright bump [skip ci] [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * docs/contributing-plus-cleanup: last polishment Co-authored-by: KauriHero <[email protected]> Co-authored-by: Bert <[email protected]> Co-authored-by: Bert <[email protected]> * GH-597: correct AutomapProtocol db storage (#120) * GH-597: code and tests established; some new features or work style used: no_share_test wider use * GH-597: little corrections and formatting * GH-597: auto review * GH-597: cosmetics, added a few places with logs * GH-597: A rookie mistake :) not running and so forgetting integration tests * update Practice with reference to version & QA * update practice with version release info * DRAFT: Update docs/branch (#133) * Update node top level README add list of component README files for easy navigation * Added reference to UI-Interface-Interface Added reference to UI-Interface-Interface document that lives in the Node repo main folder * Update README.md * Delete SHRD-faucet This is no longer usable and is not connected to the MASQ token contracts * Update to blockchain service details Update to blockchain service details about Polygon, testnets, Alchemy also removed old images * wording and formattting * update LICENSE updated with corrected copyright for MASQ, and added info regarding previous codebase being removed from GitHub and original repo disappeared * Update Practice with QA blurb Thanks Stew * adjust copyright * remove old DNS doc * remove old DNS doc * remove old DNS doc * delete old faucet info * updated with component readmes * remove old logo * remove old logo2 * Create brand-guidelines.md * add masq logos * remove to move logos * add masq logos * added masq logo to readme * GH-597: backup; closely before finishing / fixed an old issue with annoying 'Send' requirement; introducet a new concept of an arbitrary_id_stamp for testing specific situations * GH-597: finished the concept of ArbitraryIdStamp * GH-597: updated github yml files; the release one is now more optimized * GH-597: last polishing before another review * GH-597: second review addressed * update from reviews * update and copyright bump * copyright bump [skip ci] [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * copyright bump [skip ci] * docs/contributing-plus-cleanup: last polishment * GH-597: a little correction in docs * GH-597: fixed a labile test in WebsocketSuperwisor and added an explanation of an unclear solution around there too * GH-597: removing unknown extern crate usage * GH-597: trying to get the release build for Node working properly * GH-597: removing an optimized build script because of an issue on Mac; we don't know how to fix that at the moment Co-authored-by: Bert <[email protected]> Co-authored-by: KauriHero <[email protected]> * GH-574: modify ci-matrix.yml * GH-574: allow multinode integration tests to fail in actions Co-authored-by: FinsaasGH <[email protected]> Co-authored-by: KauriHero <[email protected]> Co-authored-by: Bert <[email protected]> Co-authored-by: Bert <[email protected]> * GH-574: add todo for the fix of the failing test in GH Actions * GH-574: change get_connection_progress_by_ip() to return a Result * GH-574: migrate updation of OCS Stage from update_connection_stage() to handler for ConnectionProgressMessage * GH-574: migrate the test to check whether two cpm's progress override each other to neighborhood/mod.rs * GH-574: Improve the tests in Neighborhood * GH-574: Bert invented a method in Recorder to stop the system after a certain type of message is received. * GH-574: modify make_recipient_and_recording_arc() to accept stopping_message * GH-574: use hashmap for the stop condition inside the Recorder * GH-574: use stopping_message inside the tests of neighborhood * GH-574: refactor tests in Overall Connection Status to test whether a message is sent or not and updates the stage * GH-574: eliminate warnings, eprintlns and comments * GH-574: eliminate the helper fn make_node_and_recipient() * GH-574: add safety measure to recorder and refactor tests for handling CPM in Neighborhood * GH-574: strengthen tests for handling CPM by asserting on the complete struct of OverallConnectionStatus * GH-574: remove comment * GH-574: improve test for tcp connection failed * GH-574: activate the script for ci-matrix.yml * GH-574: change chrono to time * GH-574: fix the problem in receiving OffsetDateTime in log() of TestLogger * GH-574: migrate the code related to recorder in a different module * GH-574: use time instead of chrono in the test setup_results_are_broadcast_to_all_uis_integration * GH-574: review changes * GH-574: extend tests to assert whether neighborhood logs when it receives messages from unknown ip or desc * GH-574: migrate the function real_format_function() to a different file * GH-574: fix test transmit_log_handles_overloading_by_sending_msgs_from_multiple_threads * GH-574: fix clippy warnings * GH-574: add more rpc urls for polygon mainnet * GH-574: ignore the test in logger.rs - transmit_log_handles_overloading_by_sending_msgs_from_multiple_threads * GH-574: change the precision of time to milliseconds in logs * GH-574: remove ignore attribute from the test transmit_log_handles_overloading_by_sending_msgs_from_multiple_threads * GH-574: change duration from 1ms to 10ms in overloading_function * GH-574: display messages on the terminal screen * Added multinode test * GH-622: Add Connection Status Interrogation (Conversation Message) and introduce logs on connection stage update (#158) * GH-622: introduce new command named connection-status and related request and response messages * GH-622: sent stdout and stderr messages for the Connection Status Command * GH-622: handle the connection status message inside neighborhood * GH-622: write logs in debug mode when a debut gossip is sent or any connection stage gets updated * GH-622: send connection status message to the specific client instead of all clients * GH-622: add a multinode test connection_progress_can_be_requested * GH-622: Very minor changes * Removed comment * GH 622 Review 1 (#160) * GH-622: change the messages for connected to neighbor and three hops route found inside connection_status_command.rs * GH-622: migrate the test connection_status_command_works() to command_factory.rs * GH-622: write a helper function named get_transact_params_and_std_output_for_connection_status() * GH-622: rename the todo inside connection_change_notification.rs * GH-622: split the debut gossip logs to debug and trace. * GH-622: Change the debug log message for connection stage update of pass gossip. * GH-622: add docs for connectionStatus command to the USER-INTERFACE-INTERFACE.md * Gh 622 Review 2 (#161) * GH-622: fix typo inside the debug log of handle pass gossip * GH-622: refactor the tests to make them inline in connection_status_command.rs * GH-622: add clap subcommand code for connection status and introduce the command in schema.rs * GH-622: remove clippy warnings * GH-622: capitalize first letter in Node wherever it is used in logs Co-authored-by: Dan Wiebe <[email protected]> * GH-574: remove warnings * GH-574: Trying to figure out why connection status broadcasts have stopped * Added consuming wallet to multinode test * GH-574: add formatting * I think I have StreamHandlerPool right * Formatting, mostly * Trying to get pnet compiling * Revert "Trying to get pnet compiling" This reverts commit 385003d. * Revert "Formatting, mostly" This reverts commit ceb2a6f. * Revert "Merge branch 'GH-574' of github.com:MASQ-Project/Node into GH-574" This reverts commit 467be87, reversing changes made to 70a1fdf. * Revert "I think I have StreamHandlerPool right" This reverts commit 70a1fdf. * Added three more Nodes in a multinode test * More imports * Added some logging * GH-574: Update OCS stage and send the message to the UI from check_connectedness() * GH-574: fixed the test util in multinode tests that waits for messages for the UI; Utkarsh's test finally passing :) * GH-574: I forgot to include one more file to the previous commit * GH-574: add debug log when the stage of OCS has changed and message is sent to the UI. * GH-574: Refactor of the function update_ocs_stage_and_send_message_to_ui() and improved logging. * GH-574: improve logging for check_connectedness() and write tests for it. * GH-574: refactor the function that returns neighborhood linearly connected to nodes * GH-574: add test for debug log when the check_connectedness() hasn't found a 3 hops route * GH: add some formatting * GH-574: remove clippy warnings exclusive to the current card * GH-574: review 7 changes Co-authored-by: Bert <[email protected]> Co-authored-by: FinsaasGH <[email protected]> Co-authored-by: KauriHero <[email protected]> Co-authored-by: Bert <[email protected]> Co-authored-by: Dan Wiebe <[email protected]>
1 parent b0e9bb4 commit 0b26033

39 files changed

+3725
-505
lines changed

USER-INTERFACE-INTERFACE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,37 @@ interested, you can send a `configuration` request and get the new info; or you
485485
if you don't care. If you're caching the configuration information, this would be a good time to invalidate
486486
your cache.
487487

488+
#### `connectionStatus`
489+
##### Direction: Request
490+
##### Correspondent: Node
491+
##### Layout:
492+
```
493+
"payload": {}
494+
```
495+
##### Description:
496+
This message is used to check the connection status of the node with the MASQ Network.
497+
498+
#### `connectionStatus`
499+
##### Direction: Response
500+
##### Correspondent: Node
501+
##### Layout:
502+
```
503+
"payload": {
504+
"stage": <string>
505+
}
506+
```
507+
##### Description:
508+
If you send a `connectionStatus` request to the Node, it will respond back with a message containing the stage
509+
of the connection status with the MASQ Network.
510+
511+
There are following three connection stages:
512+
513+
1. NotConnected: No external neighbor is connected to us.
514+
2. ConnectedToNeighbor: External node(s) are connected to us.
515+
3. ThreeHopsRouteFound: You can relay data over the network.
516+
517+
The Node can only be on one of these connection stages during any moment of the Node's lifetime.
518+
488519
#### `crash`
489520
##### Direction: Request
490521
##### Correspondent: Node

automap/Cargo.lock

Lines changed: 23 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dns_utility/Cargo.lock

Lines changed: 21 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

masq/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ workspace = "../node"
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[dependencies]
14-
chrono = "0.4.19"
14+
time = {version = "0.3.11", features = [ "macros" ]}
1515
clap = "2.33.3"
1616
crossbeam-channel = "0.5.1"
1717
itertools = "0.8.0"

masq/src/command_factory.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::commands::change_password_command::ChangePasswordCommand;
55
use crate::commands::check_password_command::CheckPasswordCommand;
66
use crate::commands::commands_common::Command;
77
use crate::commands::configuration_command::ConfigurationCommand;
8+
use crate::commands::connection_status_command::ConnectionStatusCommand;
89
use crate::commands::crash_command::CrashCommand;
910
use crate::commands::descriptor_command::DescriptorCommand;
1011
use crate::commands::financials_command::FinancialsCommand;
@@ -45,6 +46,7 @@ impl CommandFactory for CommandFactoryReal {
4546
Ok(command) => Box::new(command),
4647
Err(msg) => return Err(CommandSyntax(msg)),
4748
},
49+
"connection-status" => Box::new(ConnectionStatusCommand::new()),
4850
"crash" => match CrashCommand::new(pieces) {
4951
Ok(command) => Box::new(command),
5052
Err(msg) => return Err(CommandSyntax(msg)),
@@ -196,6 +198,19 @@ mod tests {
196198
}
197199
}
198200

201+
#[test]
202+
fn connection_status_command_works() {
203+
let subject = CommandFactoryReal::new();
204+
205+
let command = subject.make(&["connection-status".to_string()]).unwrap();
206+
207+
let connnection_status_command = command
208+
.as_any()
209+
.downcast_ref::<ConnectionStatusCommand>()
210+
.unwrap();
211+
assert_eq!(connnection_status_command, &ConnectionStatusCommand {});
212+
}
213+
199214
#[test]
200215
fn factory_produces_set_password() {
201216
let subject = CommandFactoryReal::new();
@@ -310,6 +325,21 @@ mod tests {
310325
);
311326
}
312327

328+
#[test]
329+
fn factory_produces_connection_status() {
330+
let subject = CommandFactoryReal::new();
331+
332+
let command = subject.make(&["connection-status".to_string()]).unwrap();
333+
334+
assert_eq!(
335+
command
336+
.as_any()
337+
.downcast_ref::<ConnectionStatusCommand>()
338+
.unwrap(),
339+
&ConnectionStatusCommand {}
340+
);
341+
}
342+
313343
#[test]
314344
fn complains_about_generate_wallets_command_with_bad_syntax() {
315345
let subject = CommandFactoryReal::new();

0 commit comments

Comments
 (0)