Fixes download stream error in peerDownloadHelper

This commit is contained in:
benbierens 2023-08-24 15:56:56 +02:00
parent 7da90fc53b
commit b276592daf
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 11 additions and 6 deletions

View File

@ -48,11 +48,7 @@ namespace DistTestCore.Helpers
try
{
var downloadedFile = fileManager.CreateEmptyTestFile(expectedFile.Label + "_downloaded");
using var downloadStream = File.OpenWrite(downloadedFile.Filename);
using var stream = to.Node.DownloadFile(contentId);
stream.CopyTo(downloadStream);
var downloadedFile = DownloadFile(to.Node, contentId, expectedFile.Label + "_downloaded");
expectedFile.AssertIsEqual(downloadedFile);
return PeerConnectionState.Connection;
}
@ -70,6 +66,15 @@ namespace DistTestCore.Helpers
// Should an exception occur during upload, then this try is inconclusive and we try again next loop.
}
private TestFile DownloadFile(CodexAccess node, string contentId, string label)
{
var downloadedFile = fileManager.CreateEmptyTestFile(label);
using var downloadStream = File.OpenWrite(downloadedFile.Filename);
using var stream = node.DownloadFile(contentId);
stream.CopyTo(downloadStream);
return downloadedFile;
}
private TestFile GenerateTestFile(CodexAccess uploader, CodexAccess downloader)
{
var up = uploader.GetName().Replace("<", "").Replace(">", "");

View File

@ -20,7 +20,7 @@ namespace Tests.PeerDiscoveryTests
[TestCase(3)]
[TestCase(10)]
[TestCase(20)]
public void VariableNodesInPods(int number)
public void VariableNodes(int number)
{
SetupCodexNodes(number);