From e5f7765dfa88f18e6ffaa0fc6fe8faca71190b82 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 16 Apr 2020 14:12:17 +1000 Subject: [PATCH] Fix small cache transfer tests Since hashing Peer Addrs in the Torrent pending peers, clients are getting more than one connection to the seeder in the tests and failing. --- client_test.go | 2 +- config.go | 2 +- test/transfer_test.go | 9 +++++++++ torrent.go | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client_test.go b/client_test.go index 7c440a95..b73672dd 100644 --- a/client_test.go +++ b/client_test.go @@ -612,7 +612,7 @@ func TestSetMaxEstablishedConn(t *testing.T) { ih := testutil.GreetingMetaInfo().HashInfoBytes() cfg := TestingConfig() cfg.DisableAcceptRateLimiting = true - cfg.dropDuplicatePeerIds = true + cfg.DropDuplicatePeerIds = true for i := range iter.N(3) { cl, err := NewClient(cfg) require.NoError(t, err) diff --git a/config.go b/config.go index d3a3c066..1c9be6ef 100644 --- a/config.go +++ b/config.go @@ -120,7 +120,7 @@ type ClientConfig struct { DisableAcceptRateLimiting bool // Don't add connections that have the same peer ID as an existing // connection for a given Torrent. - dropDuplicatePeerIds bool + DropDuplicatePeerIds bool ConnTracker *conntrack.Instance diff --git a/test/transfer_test.go b/test/transfer_test.go index 74dd656e..30402793 100644 --- a/test/transfer_test.go +++ b/test/transfer_test.go @@ -217,6 +217,15 @@ func testClientTransferSmallCache(t *testing.T, setReadahead bool, readahead int // thought we had. Readahead: readahead, ExportClientStatus: true, + + // These tests don't work well with more than 1 connection to the seeder. + ConfigureLeecher: ConfigureClient{ + Config: func(cfg *torrent.ClientConfig) { + cfg.DropDuplicatePeerIds = true + //cfg.DisableIPv6 = true + //cfg.DisableUTP = true + }, + }, }) } diff --git a/torrent.go b/torrent.go index 1bf2211a..9435fe63 100644 --- a/torrent.go +++ b/torrent.go @@ -1560,7 +1560,7 @@ func (t *Torrent) addConnection(c *PeerConn) (err error) { if c.PeerID != c0.PeerID { continue } - if !t.cl.config.dropDuplicatePeerIds { + if !t.cl.config.DropDuplicatePeerIds { continue } if left, ok := c.hasPreferredNetworkOver(c0); ok && left { -- 2.48.1