Răsfoiți Sursa

Fix: false negative test results due to incorrect condition

Rod Hynes 6 ani în urmă
părinte
comite
4886ab3c09
1 a modificat fișierele cu 7 adăugiri și 7 ștergeri
  1. 7 7
      psiphon/common/fragmentor/fragmentor_test.go

+ 7 - 7
psiphon/common/fragmentor/fragmentor_test.go

@@ -52,7 +52,7 @@ func TestFragmentor(t *testing.T) {
 	// before additional data is written, even when running tests with the
 	// before additional data is written, even when running tests with the
 	// race detector.
 	// race detector.
 
 
-	bytesFragmented := 1 << 15
+	bytesToFragment := 1 << 15
 	minWriteBytes := 1
 	minWriteBytes := 1
 	maxWriteBytes := 512
 	maxWriteBytes := 512
 	minDelay := 2 * time.Millisecond
 	minDelay := 2 * time.Millisecond
@@ -65,16 +65,16 @@ func TestFragmentor(t *testing.T) {
 	_, err = clientParameters.Set("", false, map[string]interface{}{
 	_, err = clientParameters.Set("", false, map[string]interface{}{
 		"FragmentorProbability":              1.0,
 		"FragmentorProbability":              1.0,
 		"FragmentorLimitProtocols":           protocol.TunnelProtocols{},
 		"FragmentorLimitProtocols":           protocol.TunnelProtocols{},
-		"FragmentorMinTotalBytes":            bytesFragmented,
-		"FragmentorMaxTotalBytes":            bytesFragmented,
+		"FragmentorMinTotalBytes":            bytesToFragment,
+		"FragmentorMaxTotalBytes":            bytesToFragment,
 		"FragmentorMinWriteBytes":            minWriteBytes,
 		"FragmentorMinWriteBytes":            minWriteBytes,
 		"FragmentorMaxWriteBytes":            maxWriteBytes,
 		"FragmentorMaxWriteBytes":            maxWriteBytes,
 		"FragmentorMinDelay":                 minDelay,
 		"FragmentorMinDelay":                 minDelay,
 		"FragmentorMaxDelay":                 maxDelay,
 		"FragmentorMaxDelay":                 maxDelay,
 		"FragmentorDownstreamProbability":    1.0,
 		"FragmentorDownstreamProbability":    1.0,
 		"FragmentorDownstreamLimitProtocols": protocol.TunnelProtocols{},
 		"FragmentorDownstreamLimitProtocols": protocol.TunnelProtocols{},
-		"FragmentorDownstreamMinTotalBytes":  bytesFragmented,
-		"FragmentorDownstreamMaxTotalBytes":  bytesFragmented,
+		"FragmentorDownstreamMinTotalBytes":  bytesToFragment,
+		"FragmentorDownstreamMaxTotalBytes":  bytesToFragment,
 		"FragmentorDownstreamMinWriteBytes":  minWriteBytes,
 		"FragmentorDownstreamMinWriteBytes":  minWriteBytes,
 		"FragmentorDownstreamMaxWriteBytes":  maxWriteBytes,
 		"FragmentorDownstreamMaxWriteBytes":  maxWriteBytes,
 		"FragmentorDownstreamMinDelay":       minDelay,
 		"FragmentorDownstreamMinDelay":       minDelay,
@@ -105,7 +105,7 @@ func TestFragmentor(t *testing.T) {
 			if err != nil {
 			if err != nil {
 				return common.ContextError(err)
 				return common.ContextError(err)
 			}
 			}
-			if m > maxWriteBytes && n < bytesFragmented {
+			if m > maxWriteBytes && n+maxWriteBytes <= bytesToFragment {
 				return common.ContextError(fmt.Errorf("unexpected write size: %d, %d", m, n))
 				return common.ContextError(fmt.Errorf("unexpected write size: %d, %d", m, n))
 			}
 			}
 			n += m
 			n += m
@@ -155,7 +155,7 @@ func TestFragmentor(t *testing.T) {
 			if err != nil {
 			if err != nil {
 				return common.ContextError(err)
 				return common.ContextError(err)
 			}
 			}
-			if m > maxWriteBytes && n < bytesFragmented {
+			if m > maxWriteBytes && n+maxWriteBytes <= bytesToFragment {
 				return common.ContextError(fmt.Errorf("unexpected write size: %d, %d", m, n))
 				return common.ContextError(fmt.Errorf("unexpected write size: %d, %d", m, n))
 			}
 			}
 			n += m
 			n += m