]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix small cache transfer tests
authorMatt Joiner <anacrolix@gmail.com>
Thu, 16 Apr 2020 04:12:17 +0000 (14:12 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 16 Apr 2020 04:12:17 +0000 (14:12 +1000)
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
config.go
test/transfer_test.go
torrent.go

index 7c440a952912130be47069682bafd1f4c371b8b9..b73672dd0ab613259d9d25e2f036edb96dd2097a 100644 (file)
@@ -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)
index d3a3c06656e0f80e3b4407a3e9191ea1b8b32bfa..1c9be6ef40b6278012eb7049c705b07853bc3472 100644 (file)
--- 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
 
index 74dd656e685bcf3df31f839e7afb8a119fe6bb26..30402793d963c3a26949b52594caed4e2166927a 100644 (file)
@@ -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
+                       },
+               },
        })
 }
 
index 1bf2211a0d8195db1a9120580c8544d9555f0576..9435fe63d2f89d808b37f7fe7a7155fc7316ecee 100644 (file)
@@ -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 {