@@ -730,6 +730,43 @@ where
730730 }
731731}
732732
733+ pub ( crate ) async fn stop_nodes ( node_a : TestNode , node_b : TestNode ) {
734+ let ( stop_a_sender, stop_a_receiver) = tokio:: sync:: oneshot:: channel ( ) ;
735+ let ( stop_b_sender, stop_b_receiver) = tokio:: sync:: oneshot:: channel ( ) ;
736+ std:: thread:: spawn ( move || {
737+ let _ = stop_a_sender. send ( node_a. stop ( ) ) ;
738+ } ) ;
739+ std:: thread:: spawn ( move || {
740+ let _ = stop_b_sender. send ( node_b. stop ( ) ) ;
741+ } ) ;
742+ stop_a_receiver. await . expect ( "node_a stop thread panicked" ) . unwrap ( ) ;
743+ stop_b_receiver. await . expect ( "node_b stop thread panicked" ) . unwrap ( ) ;
744+ }
745+
746+ pub ( crate ) async fn stop_nodes_concurrently ( nodes : Vec < TestNode > ) {
747+ let stop_receivers = nodes
748+ . into_iter ( )
749+ . map ( |node| {
750+ let ( stop_sender, stop_receiver) = tokio:: sync:: oneshot:: channel ( ) ;
751+ std:: thread:: spawn ( move || {
752+ let _ = stop_sender. send ( node. stop ( ) ) ;
753+ } ) ;
754+ stop_receiver
755+ } )
756+ . collect :: < Vec < _ > > ( ) ;
757+
758+ for stop_receiver in stop_receivers {
759+ stop_receiver. await . expect ( "node stop thread panicked" ) . unwrap ( ) ;
760+ }
761+ }
762+
763+ pub ( crate ) async fn stop_node ( node : TestNode ) {
764+ let ( stop_sender, stop_receiver) = tokio:: sync:: oneshot:: channel ( ) ;
765+ std:: thread:: spawn ( move || {
766+ let _ = stop_sender. send ( node. stop ( ) ) ;
767+ } ) ;
768+ stop_receiver. await . expect ( "node stop thread panicked" ) . unwrap ( ) ;
769+ }
733770pub ( crate ) async fn premine_and_distribute_funds < E : ElectrumApi > (
734771 bitcoind : & BitcoindClient , electrs : & E , addrs : Vec < Address > , amount : Amount ,
735772) {
0 commit comments