]> Sergey Matveev's repositories - btrtrc.git/blob - test/unix_test.go
Test both sqlite file and in-memory leecher storages
[btrtrc.git] / test / unix_test.go
1 package test
2
3 import (
4         "io"
5         "log"
6         "net"
7         "path/filepath"
8         "testing"
9
10         "github.com/anacrolix/torrent"
11 )
12
13 func TestUnixConns(t *testing.T) {
14         var closers []io.Closer
15         defer func() {
16                 for _, c := range closers {
17                         c.Close()
18                 }
19         }()
20         configure := ConfigureClient{
21                 Config: func(cfg *torrent.ClientConfig) {
22                         cfg.DisableUTP = true
23                         cfg.DisableTCP = true
24                         cfg.Debug = true
25                 },
26                 Client: func(cl *torrent.Client) {
27                         cl.AddDialer(torrent.NetDialer{Network: "unix"})
28                         l, err := net.Listen("unix", filepath.Join(torrent.TestingTempDir.NewSub(), "socket"))
29                         if err != nil {
30                                 panic(err)
31                         }
32                         log.Printf("created listener %q", l)
33                         closers = append(closers, l)
34                         cl.AddListener(l)
35                 },
36         }
37         testClientTransfer(t, testClientTransferParams{
38                 ConfigureSeeder:  configure,
39                 ConfigureLeecher: configure,
40         })
41 }