@@ -29,19 +29,17 @@ macro_rules! assert_in_range {
2929
3030use bip39:: rand;
3131use bitcoin:: Amount ;
32- use nostr_rs_relay:: { config, server:: start_server} ;
3332use std:: {
3433 env,
3534 fs:: { self , create_dir_all, File } ,
3635 io:: { BufReader , Read } ,
37- net:: TcpStream ,
3836 path:: { Path , PathBuf } ,
3937 sync:: {
4038 atomic:: { AtomicBool , Ordering :: Relaxed } ,
41- mpsc , Arc , Mutex ,
39+ Arc , Mutex ,
4240 } ,
4341 thread:: { self , JoinHandle } ,
44- time:: { Duration , Instant } ,
42+ time:: Duration ,
4543} ;
4644
4745use flate2:: read:: GzDecoder ;
@@ -536,8 +534,6 @@ pub struct TestFramework {
536534 pub ( super ) bitcoind : BitcoinD ,
537535 pub ( super ) temp_dir : PathBuf ,
538536 shutdown : AtomicBool ,
539- nostr_relay_shutdown : mpsc:: Sender < ( ) > ,
540- nostr_relay_handle : Option < JoinHandle < ( ) > > ,
541537 block_generation_handle : Mutex < Option < JoinHandle < ( ) > > > ,
542538 makers : Mutex < Option < Vec < Arc < Maker > > > > ,
543539 taproot_makers : Mutex < Option < Vec < Arc < TaprootMaker > > > > , // Added
@@ -576,17 +572,11 @@ impl TestFramework {
576572
577573 let bitcoind = init_bitcoind ( & temp_dir, zmq_addr. clone ( ) ) ;
578574
579- log:: info!( "🌐 Spawning local nostr relay for tests" ) ;
580- let ( nostr_relay_shutdown, nostr_relay_handle) = spawn_nostr_relay ( & temp_dir) ;
581- _ = wait_for_relay_healthy ( ) ;
582-
583575 let shutdown = AtomicBool :: new ( false ) ;
584576 let test_framework = Arc :: new ( Self {
585577 bitcoind,
586578 temp_dir : temp_dir. clone ( ) ,
587579 shutdown,
588- nostr_relay_shutdown,
589- nostr_relay_handle : Some ( nostr_relay_handle) ,
590580 block_generation_handle : Mutex :: new ( None ) ,
591581 makers : Mutex :: new ( None ) ,
592582 taproot_makers : Mutex :: new ( None ) ,
@@ -714,16 +704,11 @@ impl TestFramework {
714704
715705 let bitcoind = init_bitcoind ( & temp_dir, zmq_addr. clone ( ) ) ;
716706
717- log:: info!( "🌐 Spawning local nostr relay for tests" ) ;
718- let ( nostr_relay_shutdown, nostr_relay_handle) = spawn_nostr_relay ( & temp_dir) ;
719-
720707 let shutdown = AtomicBool :: new ( false ) ;
721708 let test_framework = Arc :: new ( Self {
722709 bitcoind,
723710 temp_dir : temp_dir. clone ( ) ,
724711 shutdown,
725- nostr_relay_shutdown,
726- nostr_relay_handle : Some ( nostr_relay_handle) ,
727712 block_generation_handle : Mutex :: new ( None ) ,
728713 makers : Mutex :: new ( None ) ,
729714 taproot_makers : Mutex :: new ( None ) ,
@@ -848,15 +833,6 @@ impl Drop for TestFramework {
848833 log:: info!( "Shutting down bitcoind..." ) ;
849834 let _ = self . bitcoind . client . stop ( ) . unwrap ( ) ;
850835
851- log:: info!( "Shutting down nostr relay..." ) ;
852- _ = self . nostr_relay_shutdown . send ( ( ) ) ;
853-
854- if let Some ( handle) = self . nostr_relay_handle . take ( ) {
855- if let Err ( e) = handle. join ( ) {
856- log:: error!( "Nostr relay thread join failed: {:?}" , e) ;
857- }
858- }
859-
860836 log:: info!( "Test Framework cleanup complete." ) ;
861837 }
862838}
@@ -873,46 +849,3 @@ impl From<&TestFramework> for RPCConfig {
873849 }
874850 }
875851}
876-
877- fn spawn_nostr_relay ( temp_dir : & Path ) -> ( mpsc:: Sender < ( ) > , JoinHandle < ( ) > ) {
878- let data_dir = temp_dir. join ( "nostr-relay" ) ;
879- std:: fs:: create_dir_all ( & data_dir) . unwrap ( ) ;
880-
881- let addr = "127.0.0.1" . to_string ( ) ;
882- let port = 8000 ;
883-
884- let mut settings = config:: Settings :: default ( ) ;
885- settings. network . address = addr;
886- settings. network . port = port;
887- settings. database . min_conn = 4 ;
888- settings. database . max_conn = 8 ;
889- settings. database . in_memory = true ;
890- settings. diagnostics . tracing = true ;
891-
892- let ( shutdown_tx, shutdown_rx) = mpsc:: channel :: < ( ) > ( ) ;
893-
894- let handle = thread:: spawn ( move || {
895- start_server ( & settings, shutdown_rx) . expect ( "nostr relay crashed" ) ;
896- } ) ;
897-
898- ( shutdown_tx, handle)
899- }
900-
901- fn wait_for_relay_healthy ( ) -> Result < ( ) , String > {
902- let addr = "127.0.0.1:8000" . to_string ( ) ;
903- let timeout = Duration :: from_secs ( 10 ) ;
904- let start = Instant :: now ( ) ;
905-
906- while start. elapsed ( ) < timeout {
907- if TcpStream :: connect ( & addr) . is_ok ( ) {
908- log:: info!( "Nostr relay is alive" ) ;
909- return Ok ( ( ) ) ;
910- }
911-
912- std:: thread:: sleep ( Duration :: from_millis ( 50 ) ) ;
913- }
914-
915- log:: error!( "Nostr relay not alive" ) ;
916-
917- Err ( "nostr relay did not become healthy on port 8000" . to_string ( ) )
918- }
0 commit comments