mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Unit tests for ConnectionWriterImpl.
This commit is contained in:
@@ -2,7 +2,6 @@ package net.sf.briar.transport;
|
||||
|
||||
import static net.sf.briar.api.transport.TransportConstants.HEADER_LENGTH;
|
||||
import static net.sf.briar.api.transport.TransportConstants.MAC_LENGTH;
|
||||
import static net.sf.briar.util.ByteUtils.MAX_32_BIT_UNSIGNED;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -22,7 +21,6 @@ class ConnectionWriterImpl extends OutputStream implements ConnectionWriter {
|
||||
private final int frameLength;
|
||||
|
||||
private int length = 0;
|
||||
private long frameNumber = 0L;
|
||||
|
||||
ConnectionWriterImpl(FrameWriter out, int frameLength) {
|
||||
this.out = out;
|
||||
@@ -80,9 +78,7 @@ class ConnectionWriterImpl extends OutputStream implements ConnectionWriter {
|
||||
}
|
||||
|
||||
private void writeFrame(boolean finalFrame) throws IOException {
|
||||
if(frameNumber > MAX_32_BIT_UNSIGNED) throw new IllegalStateException();
|
||||
out.writeFrame(frame, length, finalFrame);
|
||||
length = 0;
|
||||
frameNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ class OutgoingEncryptionLayer implements FrameWriter {
|
||||
|
||||
public void writeFrame(byte[] frame, int payloadLength, boolean finalFrame)
|
||||
throws IOException {
|
||||
if(frameNumber > MAX_32_BIT_UNSIGNED) throw new IllegalStateException();
|
||||
// If the initiator's side of the connection is closed without writing
|
||||
// any data, don't write anything to the underlying transport
|
||||
if(writeTag && finalFrame && payloadLength == 0) return;
|
||||
|
||||
Reference in New Issue
Block a user