try to get test to pass deterministically

reproducible
Zlatin Balevsky 2021-02-19 16:40:09 +00:00
parent 05e55a75e9
commit b89bb93c26
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 7 additions and 5 deletions

View File

@ -275,17 +275,19 @@ class DownloadSessionTest {
int start = Integer.parseInt(matcher[0][1]) int start = Integer.parseInt(matcher[0][1])
int end = Integer.parseInt(matcher[0][2]) int end = Integer.parseInt(matcher[0][2])
/* In case the downloader requests 0th piece first, pretend we have another one */
int iHave = 0
if (start == 0) if (start == 0)
fail("inconlcusive") iHave = 1
toDownloader.write("416 don't have it \r\n".bytes) toDownloader.write("416 don't have it \r\n".bytes)
toDownloader.write("X-Have: ${encodeXHave([0],2)}\r\n\r\n".bytes) toDownloader.write("X-Have: ${encodeXHave([iHave],2)}\r\n\r\n".bytes)
toDownloader.flush() toDownloader.flush()
downloadThread.join() downloadThread.join()
assert performed assert performed
performed = false performed = false
assert available.contains(0) assert available.contains(iHave)
assert thrown == null assert thrown == null
// request same session // request same session
@ -304,7 +306,7 @@ class DownloadSessionTest {
assert matcher.groupCount() > 0 assert matcher.groupCount() > 0
start = Integer.parseInt(matcher[0][1]) start = Integer.parseInt(matcher[0][1])
end = Integer.parseInt(matcher[0][2]) end = Integer.parseInt(matcher[0][2])
assert start == 0 assert start == iHave * (1 << pieceSize)
} }
@Test @Test