]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix benchmark failing due to mainReadLoop returning io.EOF
authorMatt Joiner <anacrolix@gmail.com>
Sun, 3 May 2020 09:31:20 +0000 (19:31 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 3 May 2020 09:31:20 +0000 (19:31 +1000)
go.mod
go.sum
peerconn_test.go

diff --git a/go.mod b/go.mod
index 5ec3438b73276860b9e8836edbc1e691618eef37..d8298624e4d9dc976df91f7d697812685d4120c2 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -20,6 +20,7 @@ require (
        github.com/dustin/go-humanize v1.0.0
        github.com/edsrzf/mmap-go v1.0.0
        github.com/elliotchance/orderedmap v1.2.2
+       github.com/frankban/quicktest v1.9.0
        github.com/fsnotify/fsnotify v1.4.9
        github.com/google/btree v1.0.0
        github.com/gorilla/websocket v1.4.2
diff --git a/go.sum b/go.sum
index 2424b320239965c768a2d91b514a35af3e453086..c6a1882b5d5af90177fce3f59f8482509c648eac 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -186,6 +186,8 @@ github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHj
 github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
 github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=
 github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
+github.com/frankban/quicktest v1.9.0 h1:jfEA+Psfr/pHsRJYPpHiNu7PGJnGctNxvTaM3K1EyXk=
+github.com/frankban/quicktest v1.9.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y=
 github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
@@ -304,6 +306,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
 github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
+github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
index 61d740547097363853209a8b2d618582b89a58c2..80950d5ff807dec513cb7b9c9f1501a0fc2f32e8 100644 (file)
@@ -9,6 +9,7 @@ import (
 
        "github.com/anacrolix/missinggo/pubsub"
        "github.com/bradfitz/iter"
+       "github.com/frankban/quicktest"
        "github.com/stretchr/testify/require"
 
        "github.com/anacrolix/torrent/metainfo"
@@ -87,6 +88,7 @@ func (me *torrentStorage) WriteAt(b []byte, _ int64) (int, error) {
 }
 
 func BenchmarkConnectionMainReadLoop(b *testing.B) {
+       c := quicktest.New(b)
        cl := &Client{
                config: &ClientConfig{
                        DownloadRateLimiter: unlimited,
@@ -140,8 +142,8 @@ func BenchmarkConnectionMainReadLoop(b *testing.B) {
                        ts.writeSem.Lock()
                }
        }()
-       require.NoError(b, <-mrlErr)
-       require.EqualValues(b, b.N, cn._stats.ChunksReadUseful.Int64())
+       c.Assert([]error{nil, io.EOF}, quicktest.Contains, <-mrlErr)
+       c.Assert(cn._stats.ChunksReadUseful.Int64(), quicktest.Equals, int64(b.N))
 }
 
 func TestConnPexPeerFlags(t *testing.T) {