]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Limit keep alives for rate limited download test
authorMatt Joiner <anacrolix@gmail.com>
Wed, 18 Aug 2021 04:49:13 +0000 (14:49 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 19 Aug 2021 03:37:00 +0000 (13:37 +1000)
test/transfer_test.go

index c32dfa740c709e3fa1523753dcd278776cd86c6b..71de58b44b7b53fe0cd1ebe61f62865ebaf06f79 100644 (file)
@@ -250,6 +250,13 @@ func TestClientTransferRateLimitedUpload(t *testing.T) {
 func TestClientTransferRateLimitedDownload(t *testing.T) {
        testClientTransfer(t, testClientTransferParams{
                LeecherDownloadRateLimiter: rate.NewLimiter(512, 512),
+               ConfigureSeeder: ConfigureClient{
+                       Config: func(cfg *torrent.ClientConfig) {
+                               // If we send too many keep alives, we consume all the leechers available download
+                               // rate. The default isn't exposed, but a minute is pretty reasonable.
+                               cfg.KeepAliveTimeout = time.Minute
+                       },
+               },
        })
 }
 
@@ -427,6 +434,6 @@ func TestSeedAfterDownloading(t *testing.T) {
 }
 
 type ConfigureClient struct {
-       Config func(*torrent.ClientConfig)
-       Client func(*torrent.Client)
+       Config func(cfg *torrent.ClientConfig)
+       Client func(cl *torrent.Client)
 }