"testing"
"testing/iotest"
+ "github.com/anacrolix/log"
+
"github.com/anacrolix/torrent/internal/testutil"
qt "github.com/frankban/quicktest"
"github.com/stretchr/testify/assert"
cfg.MaxAllocPeerRequestDataPerConn = 4
cfg.DataDir = greetingTempDir
cfg.DisablePEX = true
- //cfg.Debug = true
+ cfg.Debug = true
cfg.AcceptPeerConnections = false
+ //cfg.DisableUTP = true
seeder, err := NewClient(cfg)
require.NoError(t, err)
defer seeder.Close()
cfg.Seed = false
cfg.DataDir = t.TempDir()
cfg.MaxAllocPeerRequestDataPerConn = 4
- cfg.Debug = true
+ //cfg.Debug = true
//cfg.DisableUTP = true
leecherLeecher, _ := NewClient(cfg)
require.NoError(t, err)
waitForConns(seederTorrent)
go llg.AddClientPeer(leecher)
waitForConns(llg)
+ //time.Sleep(time.Second)
llg.cl.lock()
+ targetAddr := seeder.ListenAddrs()[1]
+ log.Printf("trying to initiate to %v", targetAddr)
llg.initiateConn(PeerInfo{
- Addr: seeder.ListenAddrs()[0],
- }, true, false)
+ Addr: targetAddr,
+ }, true, false, false, false)
llg.cl.unlock()
wg.Wait()
+ // These checks would require that the leecher leecher first attempt to connect without
+ // holepunching.
+
+ //llClientStats := leecherLeecher.Stats()
+ //c := qt.New(t)
+ //c.Check(llClientStats.NumPeersDialedRequiringHolepunch, qt.Not(qt.Equals), 0)
+ //c.Check(
+ // llClientStats.NumPeersDialedRequiringHolepunch,
+ // qt.Equals,
+ // llClientStats.NumPeersUndiableWithoutHolepunch,
+ //)
}
func waitForConns(t *Torrent) {