mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Fix FileTransferSession tests.
This commit is contained in:
parent
bddbe6b7ae
commit
09a7a09ec3
@ -182,7 +182,7 @@ public final class Dispute implements NetworkPayload, PersistablePayload {
|
||||
public FileTransferSender createFileTransferSender(NetworkNode networkNode,
|
||||
NodeAddress peerNodeAddress,
|
||||
FileTransferSession.FtpCallback callback) {
|
||||
return new FileTransferSender(networkNode, peerNodeAddress, this.tradeId, this.traderId, this.getRoleStringForLogFile(), callback);
|
||||
return new FileTransferSender(networkNode, peerNodeAddress, this.tradeId, this.traderId, this.getRoleStringForLogFile(), false, callback);
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,15 +55,18 @@ import static bisq.common.file.FileUtil.doesFileContainKeyword;
|
||||
@Slf4j
|
||||
public class FileTransferSender extends FileTransferSession {
|
||||
protected final String zipFilePath;
|
||||
private final boolean isTest;
|
||||
|
||||
public FileTransferSender(NetworkNode networkNode,
|
||||
NodeAddress peerNodeAddress,
|
||||
String tradeId,
|
||||
int traderId,
|
||||
String traderRole,
|
||||
boolean isTest,
|
||||
@Nullable FileTransferSession.FtpCallback callback) {
|
||||
super(networkNode, peerNodeAddress, tradeId, traderId, traderRole, callback);
|
||||
zipFilePath = Utilities.getUserDataDir() + FileSystems.getDefault().getSeparator() + zipId + ".zip";
|
||||
this.isTest = isTest;
|
||||
updateProgress();
|
||||
}
|
||||
|
||||
@ -172,6 +175,9 @@ public class FileTransferSender extends FileTransferSession {
|
||||
dataAwaitingAck = Optional.empty();
|
||||
checkpointLastActivity();
|
||||
updateProgress();
|
||||
if (isTest) {
|
||||
return true;
|
||||
}
|
||||
UserThread.runAfter(() -> { // to trigger continuing the file transfer
|
||||
try {
|
||||
sendNextBlock();
|
||||
|
@ -55,20 +55,21 @@ public class FileTransferSessionTest implements FileTransferSession.FtpCallback
|
||||
|
||||
@Test
|
||||
public void testSendCreate() {
|
||||
new FileTransferSender(networkNode, counterpartyNodeAddress, testTradeId, testTraderId, testClientId, this);
|
||||
new FileTransferSender(networkNode, counterpartyNodeAddress, testTradeId, testTraderId, testClientId, true, this);
|
||||
Assert.assertEquals(0.0, notedProgressPct, 0.0);
|
||||
Assert.assertEquals(1, progressInvocations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateZip() {
|
||||
FileTransferSender sender = new FileTransferSender(networkNode, counterpartyNodeAddress, testTradeId, testTraderId, testClientId, this);
|
||||
FileTransferSender sender = new FileTransferSender(networkNode, counterpartyNodeAddress, testTradeId, testTraderId, testClientId, true, this);
|
||||
Assert.assertEquals(0.0, notedProgressPct, 0.0);
|
||||
Assert.assertEquals(1, progressInvocations);
|
||||
sender.createZipFileToSend();
|
||||
File file = new File(sender.zipFilePath);
|
||||
Assert.assertTrue(file.exists());
|
||||
Assert.assertTrue(file.length() > 0);
|
||||
Assert.assertTrue(file.getAbsoluteFile().exists());
|
||||
Assert.assertTrue(file.getAbsoluteFile().length() > 0);
|
||||
file.deleteOnExit();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -192,7 +193,7 @@ public class FileTransferSessionTest implements FileTransferSession.FtpCallback
|
||||
|
||||
private FileTransferSender initializeSession(int testSize) {
|
||||
try {
|
||||
FileTransferSender session = new FileTransferSender(networkNode, counterpartyNodeAddress, testTradeId, testTraderId, testClientId, this);
|
||||
FileTransferSender session = new FileTransferSender(networkNode, counterpartyNodeAddress, testTradeId, testTraderId, testClientId, true, this);
|
||||
// simulate a file for sending
|
||||
FileWriter fileWriter = new FileWriter(session.zipFilePath);
|
||||
char[] buf = new char[testSize];
|
||||
|
Loading…
Reference in New Issue
Block a user