import (
"bytes"
- "io/ioutil"
+ "os"
"testing"
"github.com/stretchr/testify/assert"
)
func loadFile(name string, t *testing.T) []byte {
- data, err := ioutil.ReadFile(name)
+ data, err := os.ReadFile(name)
require.NoError(t, err)
return data
}
"bufio"
"fmt"
"io"
- "io/ioutil"
"log"
"net"
"net/http"
return
}
- tmpdir, err := ioutil.TempDir("", "torrent-pick-")
+ tmpdir, err := os.MkdirTemp("", "torrent-pick-")
if err != nil {
log.Fatal(err)
}
package testutil
import (
- "io/ioutil"
"os"
"path/filepath"
// and a corresponding metainfo describing it. The temporary directory can be
// cleaned away with os.RemoveAll.
func GreetingTestTorrent() (tempDir string, metaInfo *metainfo.MetaInfo) {
- tempDir, err := ioutil.TempDir(os.TempDir(), "")
+ tempDir, err := os.MkdirTemp(os.TempDir(), "")
if err != nil {
panic(err)
}
import (
"io"
- "io/ioutil"
"strings"
"github.com/anacrolix/missinggo/expect"
}
}
err := info.GeneratePieces(func(fi metainfo.FileInfo) (io.ReadCloser, error) {
- return ioutil.NopCloser(strings.NewReader(t.GetFile(strings.Join(fi.Path, "/")).Data)), nil
+ return io.NopCloser(strings.NewReader(t.GetFile(strings.Join(fi.Path, "/")).Data)), nil
})
expect.Nil(err)
return info
import (
"io"
- "io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
r := tt.NewReader()
go tt.Drop()
- io.Copy(ioutil.Discard, r)
+ io.Copy(io.Discard, r)
}
import (
"io"
- "io/ioutil"
"os"
"path"
"path/filepath"
PieceLength: _case.PieceLength,
}
err := info.GeneratePieces(func(fi FileInfo) (io.ReadCloser, error) {
- return ioutil.NopCloser(missinggo.ZeroReader), nil
+ return io.NopCloser(missinggo.ZeroReader), nil
})
assert.NoError(t, err)
assert.EqualValues(t, _case.NumPieces, info.NumPieces())
"expvar"
"fmt"
"io"
- "io/ioutil"
"math"
"math/big"
"strconv"
if err != nil {
return
}
- _, err = io.CopyN(ioutil.Discard, r, int64(padLen))
+ _, err = io.CopyN(io.Discard, r, int64(padLen))
if err != nil {
return
}
}
cryptoProvidesCount.Add(strconv.FormatUint(uint64(provides), 16), 1)
chosen = h.chooseMethod(provides)
- _, err = io.CopyN(ioutil.Discard, r, int64(padLen))
+ _, err = io.CopyN(io.Discard, r, int64(padLen))
if err != nil {
return
}
"crypto/rand"
"crypto/rc4"
"io"
- "io/ioutil"
"net"
"sync"
"testing"
func TestReceiveRandomData(t *testing.T) {
tr := trackReader{rand.Reader, 0}
- _, _, err := ReceiveHandshake(readWriter{&tr, ioutil.Discard}, nil, DefaultCryptoSelector)
+ _, _, err := ReceiveHandshake(readWriter{&tr, io.Discard}, nil, DefaultCryptoSelector)
// No skey matches
require.Error(t, err)
// Establishing S, and then reading the maximum padding for giving up on
"bytes"
"fmt"
"io"
- "io/ioutil"
"path"
"sort"
"strconv"
if ccr, ok := s.rp.(ConsecutiveChunkReader); ok {
return ccr.ReadConsecutiveChunks(s.incompleteDirPath() + "/")
}
- return ioutil.NopCloser(io.NewSectionReader(incompleteChunks, 0, s.mp.Length())), nil
+ return io.NopCloser(io.NewSectionReader(incompleteChunks, 0, s.mp.Length())), nil
}()
if err != nil {
return fmt.Errorf("getting incomplete chunks reader: %w", err)
import (
"io"
- "io/ioutil"
"os"
"sync"
"testing"
storage.ResourcePiecesOpts{
Capacity: sharedCapacity,
}),
- ioutil.NopCloser(nil),
+ io.NopCloser(nil),
}
}
}
"crypto/rand"
"errors"
"fmt"
- "io/ioutil"
+ "io"
"net"
"net/url"
"sync"
r = bytes.NewReader(b[:n])
udp.Read(r, &h)
udp.Read(r, &AnnounceRequest{})
- all, _ := ioutil.ReadAll(r)
+ all, _ := io.ReadAll(r)
if string(all) != "\x02\x09/announce" {
t.FailNow()
}