Skip to content

Commit

Permalink
Fix cipher test.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed May 1, 2024
1 parent a67f5db commit aa50580
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions service/tcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package service

import (
"bufio"
"bytes"
"errors"
"fmt"
Expand Down Expand Up @@ -101,7 +102,7 @@ func BenchmarkTCPFindCipherFail(b *testing.B) {
}
clientIP := clientConn.RemoteAddr().(*net.TCPAddr).IP
b.StartTimer()
findAccessKey(clientConn, clientIP, cipherList)
findAccessKey(bufio.NewReader(clientConn), clientIP, cipherList)
b.StopTimer()
}
}
Expand Down Expand Up @@ -199,17 +200,14 @@ func BenchmarkTCPFindCipherRepeat(b *testing.B) {
cipherNumber := byte(n % numCiphers)
reader, writer := io.Pipe()
clientIP := net.IPv4(192, 0, 2, cipherNumber)
addr := &net.TCPAddr{IP: clientIP, Port: 54321}
c := conn{clientAddr: addr, reader: reader, writer: writer}
cipher := cipherEntries[cipherNumber].CryptoKey
go shadowsocks.NewWriter(writer, cipher).Write(makeTestPayload(50))
b.StartTimer()
_, _, _, _, err := findAccessKey(&c, clientIP, cipherList)
_, _, _, err := findAccessKey(bufio.NewReader(reader), clientIP, cipherList)
b.StopTimer()
if err != nil {
b.Error(err)
}
c.Close()
}
}

Expand Down

0 comments on commit aa50580

Please sign in to comment.