summaryrefslogtreecommitdiffstats
path: root/pkg/crypto
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2025-11-23 10:41:36 +0000
committerClaude <noreply@anthropic.com>2025-11-23 10:41:36 +0000
commit53501f01e8c8581ab1fba48dd49c6d40f6f4f622 (patch)
treee20d9242f39989e175af156f3e6e3168823c2c0f /pkg/crypto
parent3d5286365747c7d2418be16544116f67964b8c48 (diff)
downloadnoshitalk-53501f01e8c8581ab1fba48dd49c6d40f6f4f622.tar.gz
noshitalk-53501f01e8c8581ab1fba48dd49c6d40f6f4f622.tar.xz
noshitalk-53501f01e8c8581ab1fba48dd49c6d40f6f4f622.zip
Fix test cases for correct v3 onion address format
- Fix tor_test.go: use 56-char base32 strings for valid onion addresses - Fix crypto_test.go: use net.Pipe() for proper bidirectional auth test - Fix go.sum: remove corrupted first line
Diffstat (limited to 'pkg/crypto')
-rw-r--r--pkg/crypto/crypto_test.go31
1 files changed, 4 insertions, 27 deletions
diff --git a/pkg/crypto/crypto_test.go b/pkg/crypto/crypto_test.go
index 1d76767..47d35c1 100644
--- a/pkg/crypto/crypto_test.go
+++ b/pkg/crypto/crypto_test.go
@@ -339,36 +339,16 @@ func TestSecureBuffer(t *testing.T) {
// We can't easily test this without accessing memguard internals
}
-// Mock connection for auth tests
-type mockConn struct {
- readBuf *bytes.Buffer
- writeBuf *bytes.Buffer
-}
-
-func newMockConnPair() (*mockConn, *mockConn) {
- buf1 := &bytes.Buffer{}
- buf2 := &bytes.Buffer{}
- return &mockConn{readBuf: buf1, writeBuf: buf2},
- &mockConn{readBuf: buf2, writeBuf: buf1}
-}
-
-func (m *mockConn) Read(b []byte) (n int, err error) { return m.readBuf.Read(b) }
-func (m *mockConn) Write(b []byte) (n int, err error) { return m.writeBuf.Write(b) }
-func (m *mockConn) Close() error { return nil }
-func (m *mockConn) LocalAddr() net.Addr { return nil }
-func (m *mockConn) RemoteAddr() net.Addr { return nil }
-func (m *mockConn) SetDeadline(t time.Time) error { return nil }
-func (m *mockConn) SetReadDeadline(t time.Time) error { return nil }
-func (m *mockConn) SetWriteDeadline(t time.Time) error { return nil }
-
func TestMutualAuth(t *testing.T) {
sharedSecret := make([]byte, 32)
for i := range sharedSecret {
sharedSecret[i] = byte(i)
}
- // Create connected mock pair
- serverConn, clientConn := newMockConnPair()
+ // Create a proper bidirectional connection using net.Pipe
+ serverConn, clientConn := net.Pipe()
+ defer serverConn.Close()
+ defer clientConn.Close()
// Run server auth in goroutine
serverErr := make(chan error, 1)
@@ -376,9 +356,6 @@ func TestMutualAuth(t *testing.T) {
serverErr <- PerformServerAuth(serverConn, sharedSecret)
}()
- // Small delay to ensure server sends challenge first
- time.Sleep(10 * time.Millisecond)
-
// Run client auth
err := PerformClientAuth(clientConn, sharedSecret)
if err != nil {