<commit_before>package org.johnnei.javatorrent.it;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.InetSocketAddress;
import java.net.URL;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.johnnei.javatorrent.TorrentClient;
import org.johnnei.javatorrent.bittorrent.encoding.SHA1;
import org.johnnei.javatorrent.network.PeerConnectInfo;
import org.johnnei.javatorrent.phases.PhaseSeed;
import org.johnnei.javatorrent.torrent.DownloadTorrentIT;
import org.johnnei.javatorrent.torrent.Metadata;
import org.johnnei.javatorrent.torrent.Torrent;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public abstract class EndToEndDownload {

    private static final Logger LOGGER = LoggerFactory.getLogger(DownloadTorrentIT.class);
    private static final String SINGLE_FILE_TORRENT = "/torrent-files/gimp-2.8.16-setup-1.exe.torrent";
    private static final byte[] TORRENT_FILE_HASH = new byte[] {
            (byte) 0xc8,        0x36, (byte) 0x9f,        0x0b, (byte) 0xa4, (byte) 0xbf,       0x6c,
            (byte) 0xd8,        0x7f, (byte) 0xb1,        0x3b,        0x34,        0x37,       0x78,
                   0x2e,        0x2c,        0x78,        0x20, (byte) 0xbb,        0x38
    };
    private static final int PIECE_SIZE = 262144;
    private static final String EXECUTABLE_NAME = "gimp-2.8.16-setup-1.exe";
    private static final byte[] EXECUTABLE_HASH = new byte[] {
            (byte) 0x81,        0x6d, (byte) 0xd2,        0x48, (byte) 0xff,        0x18, (byte) 0x82,
                   0x35, (byte) 0xe7, (byte) 0x8b,        0x6d,        0x45, (byte) 0xbf, (byte) 0xec,
                   0x3e,        0x79, (byte) 0xe0, (byte) 0xcc,        0x08, (byte) 0xe1
    };

    @Rule
    public TemporaryFolder temporaryFolder = new TemporaryFolder();

    @Rule
    public Timeout timeout = new Timeout(2, TimeUnit.MINUTES);

    private void assertPreconditions(File torrentFile, File resultFile) throws Exception {
        if (!resultFile.exists()) {
            fail("Missing torrent output file: " + resultFile.getAbsolutePath());
        }

        byte[] bytes = new byte[(int) resultFile.length()];
        try (DataInputStream inputStream = new DataInputStream(new FileInputStream(resultFile))) {
            inputStream.readFully(bytes);
        }<commit_msg>JBT-63: Give the DownloadIT more wiggle room for server congestion.<commit_after>package org.johnnei.javatorrent.it;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.InetSocketAddress;
import java.net.URL;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.johnnei.javatorrent.TorrentClient;
import org.johnnei.javatorrent.bittorrent.encoding.SHA1;
import org.johnnei.javatorrent.network.PeerConnectInfo;
import org.johnnei.javatorrent.phases.PhaseSeed;
import org.johnnei.javatorrent.torrent.DownloadTorrentIT;
import org.johnnei.javatorrent.torrent.Metadata;
import org.johnnei.javatorrent.torrent.Torrent;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public abstract class EndToEndDownload {

    private static final Logger LOGGER = LoggerFactory.getLogger(DownloadTorrentIT.class);
    private static final String SINGLE_FILE_TORRENT = "/torrent-files/gimp-2.8.16-setup-1.exe.torrent";
    private static final byte[] TORRENT_FILE_HASH = new byte[] {
            (byte) 0xc8,        0x36, (byte) 0x9f,        0x0b, (byte) 0xa4, (byte) 0xbf,       0x6c,
            (byte) 0xd8,        0x7f, (byte) 0xb1,        0x3b,        0x34,        0x37,       0x78,
                   0x2e,        0x2c,        0x78,        0x20, (byte) 0xbb,        0x38
    };
    private static final int PIECE_SIZE = 262144;
    private static final String EXECUTABLE_NAME = "gimp-2.8.16-setup-1.exe";
    private static final byte[] EXECUTABLE_HASH = new byte[] {
            (byte) 0x81,        0x6d, (byte) 0xd2,        0x48, (byte) 0xff,        0x18, (byte) 0x82,
                   0x35, (byte) 0xe7, (byte) 0x8b,        0x6d,        0x45, (byte) 0xbf, (byte) 0xec,
                   0x3e,        0x79, (byte) 0xe0, (byte) 0xcc,        0x08, (byte) 0xe1
    };

    @Rule
    public TemporaryFolder temporaryFolder = new TemporaryFolder();

    @Rule
    public Timeout timeout = new Timeout(5, TimeUnit.MINUTES);

    private void assertPreconditions(File torrentFile, File resultFile) throws Exception {
        if (!resultFile.exists()) {
            fail("Missing torrent output file: " + resultFile.getAbsolutePath());
        }

        byte[] bytes = new byte[(int) resultFile.length()];
        try (DataInputStream inputStream = new DataInputStream(new FileInputStream(resultFile))) {
            inputStream.readFully(bytes);
        }
{'fraction_non_alphanumeric': 0.10364386387074596, 'fraction_numerical': 0.038844963905122036, 'mean_word_length': 3.2044797687861273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2566530', 'n_tokens_mistral': 2040, 'n_tokens_neox': 1916, 'n_words': 425}