Skip to content

Commit

Permalink
GH-728: send a ConfigurtionChangeMessage when the consuming wallet is…
Browse files Browse the repository at this point in the history
… generated
  • Loading branch information
utkarshg6 committed Jan 23, 2024
1 parent 6a8086e commit 3ec34fe
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 149 deletions.
38 changes: 19 additions & 19 deletions node/src/accountant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,6 @@ mod tests {
DEFAULT_EARNING_WALLET, DEFAULT_PAYMENT_THRESHOLDS,
};
use crate::sub_lib::blockchain_bridge::OutboundPaymentsInstructions;
use crate::sub_lib::neighborhood::ConfigurationChange::UpdatePassword;
use crate::test_utils::persistent_configuration_mock::PersistentConfigurationMock;
use crate::test_utils::recorder::make_recorder;
use crate::test_utils::recorder::peer_actors_builder;
Expand Down Expand Up @@ -1207,24 +1206,25 @@ mod tests {

#[test]
fn accountant_updates_password_when_it_receives_configuration_change_msg() {
let system =
System::new("accountant_updates_password_when_it_receives_configuration_change_msg");
let mut config = bc_from_earning_wallet(make_wallet("earning_wallet"));
let subject = AccountantBuilder::default()
.bootstrapper_config(config)
.build();
let subject_addr = subject.start();
let peer_actors = peer_actors_builder().build();
subject_addr.try_send(BindMessage { peer_actors }).unwrap();

subject_addr
.try_send(ConfigurationChangeMessage {
change: UpdatePassword("new_password".to_string()),
})
.unwrap();

System::current().stop();
assert_eq!(system.run(), 0);
todo!("either remove this test or modify it");
// let system =
// System::new("accountant_updates_password_when_it_receives_configuration_change_msg");
// let mut config = bc_from_earning_wallet(make_wallet("earning_wallet"));
// let subject = AccountantBuilder::default()
// .bootstrapper_config(config)
// .build();
// let subject_addr = subject.start();
// let peer_actors = peer_actors_builder().build();
// subject_addr.try_send(BindMessage { peer_actors }).unwrap();
//
// subject_addr
// .try_send(ConfigurationChangeMessage {
// change: UpdatePassword("new_password".to_string()),
// })
// .unwrap();
//
// System::current().stop();
// assert_eq!(system.run(), 0);
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions node/src/actor_system_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::sub_lib::dispatcher::DispatcherSubs;
use crate::sub_lib::hopper::HopperConfig;
use crate::sub_lib::hopper::HopperSubs;
use crate::sub_lib::neighborhood::{
ConfigurationChangeMessage, NeighborhoodMode, NeighborhoodSubs,
NeighborhoodMode, NeighborhoodSubs,
};
use crate::sub_lib::peer_actors::{BindMessage, StartMessage};
use crate::sub_lib::peer_actors::{NewPublicIp, PeerActors};
Expand Down Expand Up @@ -536,7 +536,6 @@ impl ActorFactory for ActorFactoryReal {
ConfiguratorSubs {
bind: recipient!(addr, BindMessage),
node_from_ui_sub: recipient!(addr, NodeFromUiMessage),
configuration_change_msg_sub: recipient!(addr, ConfigurationChangeMessage),
}
}
}
Expand Down
44 changes: 22 additions & 22 deletions node/src/blockchain/blockchain_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ mod tests {
use crate::db_config::persistent_configuration::PersistentConfigError;
use crate::match_every_type_id;
use crate::node_test_utils::check_timestamp;
use crate::sub_lib::neighborhood::ConfigurationChange::UpdatePassword;
use crate::test_utils::persistent_configuration_mock::PersistentConfigurationMock;
use crate::test_utils::recorder::{make_recorder, peer_actors_builder};
use crate::test_utils::recorder_stop_conditions::StopCondition;
Expand Down Expand Up @@ -667,27 +666,28 @@ mod tests {

#[test]
fn blockchain_bridge_updates_password_when_it_receives_configuration_change_msg() {
let system = System::new(
"blockchain_bridge_updates_password_when_it_receives_configuration_change_msg",
);
let subject = BlockchainBridge::new(
stub_bi(),
Box::new(PersistentConfigurationMock::default()),
false,
None,
);
let subject_addr = subject.start();
let peer_actors = peer_actors_builder().build();
subject_addr.try_send(BindMessage { peer_actors }).unwrap();

subject_addr
.try_send(ConfigurationChangeMessage {
change: UpdatePassword("new_password".to_string()),
})
.unwrap();

System::current().stop();
assert_eq!(system.run(), 0);
todo!("remove this test");
// let system = System::new(
// "blockchain_bridge_updates_password_when_it_receives_configuration_change_msg",
// );
// let subject = BlockchainBridge::new(
// stub_bi(),
// Box::new(PersistentConfigurationMock::default()),
// false,
// None,
// );
// let subject_addr = subject.start();
// let peer_actors = peer_actors_builder().build();
// subject_addr.try_send(BindMessage { peer_actors }).unwrap();
//
// subject_addr
// .try_send(ConfigurationChangeMessage {
// change: UpdatePassword("new_password".to_string()),
// })
// .unwrap();
//
// System::current().stop();
// assert_eq!(system.run(), 0);
}

#[test]
Expand Down
49 changes: 23 additions & 26 deletions node/src/neighborhood/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ impl Handler<ConfigurationChangeMessage> for Neighborhood {
}
self.search_for_a_new_route();
}
ConfigurationChange::UpdatePassword(new_password) => {
self.handle_new_password(new_password);
}
}
}
}
Expand Down Expand Up @@ -1705,7 +1702,6 @@ mod tests {
use crate::neighborhood::overall_connection_status::{
ConnectionProgress, ConnectionStage, OverallConnectionStage,
};
use crate::sub_lib::neighborhood::ConfigurationChange::UpdatePassword;
use crate::test_utils::unshared_test_utils::notify_handlers::NotifyLaterHandleMock;
use masq_lib::test_utils::logging::{init_test_logging, TestLogHandler};

Expand Down Expand Up @@ -5865,28 +5861,29 @@ mod tests {

#[test]
fn password_can_be_updated_using_configuration_change_msg() {
let system = System::new("password_can_be_updated_using_configuration_change_msg");
let mut subject = make_standard_subject();
subject.db_password_opt = Some("old_password".to_string());
let subject_addr = subject.start();
let peer_actors = peer_actors_builder().build();
subject_addr.try_send(BindMessage { peer_actors }).unwrap();

subject_addr
.try_send(ConfigurationChangeMessage {
change: UpdatePassword("new_password".to_string()),
})
.unwrap();

subject_addr
.try_send(AssertionsMessage {
assertions: Box::new(|subject: &mut Neighborhood| {
assert_eq!(subject.db_password_opt, Some("new_password".to_string()))
}),
})
.unwrap();
System::current().stop();
assert_eq!(system.run(), 0);
todo!("modify this test to update the consuming wallet instead");
// let system = System::new("password_can_be_updated_using_configuration_change_msg");
// let mut subject = make_standard_subject();
// subject.db_password_opt = Some("old_password".to_string());
// let subject_addr = subject.start();
// let peer_actors = peer_actors_builder().build();
// subject_addr.try_send(BindMessage { peer_actors }).unwrap();
//
// subject_addr
// .try_send(ConfigurationChangeMessage {
// change: UpdatePassword("new_password".to_string()),
// })
// .unwrap();
//
// subject_addr
// .try_send(AssertionsMessage {
// assertions: Box::new(|subject: &mut Neighborhood| {
// assert_eq!(subject.db_password_opt, Some("new_password".to_string()))
// }),
// })
// .unwrap();
// System::current().stop();
// assert_eq!(system.run(), 0);
}

#[test]
Expand Down
Loading

0 comments on commit 3ec34fe

Please sign in to comment.