From 52e8fa59cf694bc7fffd1245827e727f9afe30b4 Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Tue, 7 Oct 2025 22:12:46 -0400 Subject: [PATCH] fmt --- primary_stream_test.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/primary_stream_test.go b/primary_stream_test.go index 80aee9bf5..262d489c8 100644 --- a/primary_stream_test.go +++ b/primary_stream_test.go @@ -83,12 +83,12 @@ func Test_PrimaryStreamingServerClient(t *testing.T) { } fmt.Println("Test_PrimaryStreamingServerClient") - + // Create a test listener to act as the "server" - this avoids the problem // of trying to connect from one subsession to another within the same PRIMARY session testListener := SetupTestListenerWithHTTP(t, generateUniqueSessionID("primary_server_client_listener")) defer testListener.Close() - + // Create PRIMARY session for the client earlysam, err := NewSAM(SAMDefaultAddr("")) if err != nil { @@ -108,7 +108,7 @@ func Test_PrimaryStreamingServerClient(t *testing.T) { return } defer sam.Close() - + fmt.Println("\tClient: Creating multiple stream subsessions in PRIMARY session") // Per SAMv3.3 spec: Multiple STREAM subsessions in a PRIMARY session // MUST have unique LISTEN_PORT values to route incoming traffic correctly. @@ -119,16 +119,16 @@ func Test_PrimaryStreamingServerClient(t *testing.T) { return } defer ss1.Close() - + ss2, err := sam.NewStreamSubSession("primaryClient2", []string{"LISTEN_PORT=8002"}) if err != nil { t.Fatalf("Failed to create second subsession: %v", err) return } defer ss2.Close() - + fmt.Println("\tClient: Successfully created two stream subsessions with unique ports") - + // Test that both subsessions can dial external destinations fmt.Printf("\tClient subsession 1: Dialing test listener (%s)\n", testListener.AddrString()) conn1, err := ss1.DialI2P(testListener.Addr()) @@ -137,26 +137,26 @@ func Test_PrimaryStreamingServerClient(t *testing.T) { return } defer conn1.Close() - + fmt.Println("\tClient subsession 1: Sending HTTP GET /") if _, err := conn1.Write([]byte("GET /subsession1\n")); err != nil { t.Fatalf("Subsession 1 failed to write: %v", err) return } - + buf1 := make([]byte, 4096) n1, err := conn1.Read(buf1) if err != nil { t.Fatalf("Subsession 1 failed to read: %v", err) return } - + if !strings.Contains(strings.ToLower(string(buf1[:n1])), "http") && !strings.Contains(strings.ToLower(string(buf1[:n1])), "html") { t.Logf("\tWarning: Subsession 1 received %d bytes, but nothing that looked like http/html", n1) } else { fmt.Println("\tClient subsession 1: Successfully read HTTP/HTML from test listener") } - + // Test second subsession fmt.Printf("\tClient subsession 2: Dialing test listener (%s)\n", testListener.AddrString()) conn2, err := ss2.DialI2P(testListener.Addr()) @@ -165,26 +165,26 @@ func Test_PrimaryStreamingServerClient(t *testing.T) { return } defer conn2.Close() - + fmt.Println("\tClient subsession 2: Sending HTTP GET /") if _, err := conn2.Write([]byte("GET /subsession2\n")); err != nil { t.Fatalf("Subsession 2 failed to write: %v", err) return } - + buf2 := make([]byte, 4096) n2, err := conn2.Read(buf2) if err != nil { t.Fatalf("Subsession 2 failed to read: %v", err) return } - + if !strings.Contains(strings.ToLower(string(buf2[:n2])), "http") && !strings.Contains(strings.ToLower(string(buf2[:n2])), "html") { t.Logf("\tWarning: Subsession 2 received %d bytes, but nothing that looked like http/html", n2) } else { fmt.Println("\tClient subsession 2: Successfully read HTTP/HTML from test listener") } - + fmt.Println("\tTest passed: PRIMARY session with multiple STREAM subsessions working correctly") }