Allow the initiator to close a connection without writing.

This will make it easier for simplex transports to discard empty
connections.
This commit is contained in:
akwizgran
2012-08-28 11:38:26 +01:00
parent ff73905330
commit 1762eaf3e9
2 changed files with 9 additions and 8 deletions

View File

@@ -131,9 +131,8 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase {
will(returnValue(null));
}});
connection.write();
// Nothing should have been written except the tag and an empty frame
int nothing = TAG_LENGTH + HEADER_LENGTH + MAC_LENGTH;
assertEquals(nothing, out.size());
// Nothing should have been written
assertEquals(0, out.size());
// The transport should have been disposed with exception == false
assertTrue(transport.getDisposed());
assertFalse(transport.getException());
@@ -183,8 +182,8 @@ public class OutgoingSimplexConnectionTest extends BriarTestCase {
}});
connection.write();
// Something should have been written
int nothing = TAG_LENGTH + HEADER_LENGTH + MAC_LENGTH;
assertTrue(out.size() > nothing + UniqueId.LENGTH + message.length);
int overhead = TAG_LENGTH + HEADER_LENGTH + MAC_LENGTH;
assertTrue(out.size() > overhead + UniqueId.LENGTH + message.length);
// The transport should have been disposed with exception == false
assertTrue(transport.getDisposed());
assertFalse(transport.getException());