Avoid DB lookups where possible.

This commit is contained in:
akwizgran
2011-11-24 22:09:04 +00:00
parent ff8010a945
commit 9345b5c71b
4 changed files with 510 additions and 144 deletions

View File

@@ -2,6 +2,7 @@ package net.sf.briar.transport;
import static net.sf.briar.api.transport.TransportConstants.IV_LENGTH;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -16,13 +17,13 @@ import net.sf.briar.api.ContactId;
import net.sf.briar.api.crypto.CryptoComponent;
import net.sf.briar.api.crypto.ErasableKey;
import net.sf.briar.api.db.DatabaseComponent;
import net.sf.briar.api.db.DbException;
import net.sf.briar.api.db.event.ContactRemovedEvent;
import net.sf.briar.api.db.event.RemoteTransportsUpdatedEvent;
import net.sf.briar.api.db.event.TransportAddedEvent;
import net.sf.briar.api.protocol.Transport;
import net.sf.briar.api.protocol.TransportId;
import net.sf.briar.api.protocol.TransportIndex;
import net.sf.briar.api.transport.ConnectionContext;
import net.sf.briar.api.transport.ConnectionRecogniser;
import net.sf.briar.api.transport.ConnectionRecogniser.Callback;
import net.sf.briar.api.transport.ConnectionWindow;
import net.sf.briar.crypto.CryptoModule;
import net.sf.briar.plugins.ImmediateExecutor;
@@ -41,8 +42,7 @@ public class ConnectionRecogniserImplTest extends TestCase {
private final byte[] inSecret;
private final TransportId transportId;
private final TransportIndex localIndex, remoteIndex;
private final Collection<Transport> transports;
private final ConnectionWindow connectionWindow;
private final Collection<Transport> localTransports, remoteTransports;
public ConnectionRecogniserImplTest() {
super();
@@ -54,51 +54,486 @@ public class ConnectionRecogniserImplTest extends TestCase {
transportId = new TransportId(TestUtils.getRandomId());
localIndex = new TransportIndex(13);
remoteIndex = new TransportIndex(7);
Transport transport = new Transport(transportId, localIndex,
Collections.singletonMap("foo", "bar"));
transports = Collections.singletonList(transport);
connectionWindow = new ConnectionWindowImpl(crypto, remoteIndex,
inSecret);
Map<String, String> properties = Collections.singletonMap("foo", "bar");
Transport localTransport = new Transport(transportId, localIndex,
properties);
localTransports = Collections.singletonList(localTransport);
Transport remoteTransport = new Transport(transportId, remoteIndex,
properties);
remoteTransports = Collections.singletonList(remoteTransport);
}
@Test
public void testUnexpectedIv() throws Exception {
final ConnectionWindow window = createConnectionWindow(remoteIndex);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
// Initialise
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(transports));
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(connectionWindow));
will(returnValue(window));
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniser c = new ConnectionRecogniserImpl(crypto, db,
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
c.acceptConnection(transportId, new byte[IV_LENGTH], new Callback() {
public void connectionAccepted(ConnectionContext ctx) {
fail();
}
public void connectionRejected() {
// Expected
}
public void handleException(DbException e) {
fail();
}
});
assertNull(c.acceptConnection(transportId, new byte[IV_LENGTH]));
context.assertIsSatisfied();
}
@Test
public void testExpectedIv() throws Exception {
final ConnectionWindow window = createConnectionWindow(remoteIndex);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
// Update the window
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
oneOf(db).setConnectionWindow(contactId, remoteIndex, window);
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// The IV should not be expected by the wrong transport
TransportId wrong = new TransportId(TestUtils.getRandomId());
assertNull(c.acceptConnection(wrong, encryptedIv));
// The IV should be expected by the right transport
ConnectionContext ctx = c.acceptConnection(transportId, encryptedIv);
assertNotNull(ctx);
assertEquals(contactId, ctx.getContactId());
assertEquals(remoteIndex, ctx.getTransportIndex());
assertEquals(3, ctx.getConnectionNumber());
// The IV should no longer be expected
assertNull(c.acceptConnection(transportId, encryptedIv));
// The window should have advanced
Map<Long, byte[]> unseen = window.getUnseen();
assertEquals(19, unseen.size());
for(int i = 0; i < 19; i++) {
assertEquals(i != 3, unseen.containsKey(Long.valueOf(i)));
}
context.assertIsSatisfied();
}
@Test
public void testContactRemovedAfterInit() throws Exception {
final ConnectionWindow window = createConnectionWindow(remoteIndex);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise before removing contact
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// Ensure the recogniser is initialised
assertFalse(c.isInitialised());
assertNull(c.acceptConnection(transportId, new byte[IV_LENGTH]));
assertTrue(c.isInitialised());
// Remove the contact
c.eventOccurred(new ContactRemovedEvent(contactId));
// The IV should not be expected
assertNull(c.acceptConnection(transportId, encryptedIv));
context.assertIsSatisfied();
}
@Test
public void testContactRemovedBeforeInit() throws Exception {
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise after removing contact
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.emptyList()));
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// Remove the contact
c.eventOccurred(new ContactRemovedEvent(contactId));
// The IV should not be expected
assertFalse(c.isInitialised());
assertNull(c.acceptConnection(transportId, encryptedIv));
assertTrue(c.isInitialised());
context.assertIsSatisfied();
}
@Test
public void testLocalTransportAddedAfterInit() throws Exception {
final ConnectionWindow window = createConnectionWindow(remoteIndex);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise before adding transport
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(Collections.emptyList()));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
// Add the transport
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
// Update the window
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
oneOf(db).setConnectionWindow(contactId, remoteIndex, window);
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// The IV should not be expected
assertFalse(c.isInitialised());
assertNull(c.acceptConnection(transportId, encryptedIv));
assertTrue(c.isInitialised());
// Add the transport
c.eventOccurred(new TransportAddedEvent(transportId));
// The IV should be expected
ConnectionContext ctx = c.acceptConnection(transportId, encryptedIv);
assertNotNull(ctx);
assertEquals(contactId, ctx.getContactId());
assertEquals(remoteIndex, ctx.getTransportIndex());
assertEquals(3, ctx.getConnectionNumber());
// The IV should no longer be expected
assertNull(c.acceptConnection(transportId, encryptedIv));
// The window should have advanced
Map<Long, byte[]> unseen = window.getUnseen();
assertEquals(19, unseen.size());
for(int i = 0; i < 19; i++) {
assertEquals(i != 3, unseen.containsKey(Long.valueOf(i)));
}
context.assertIsSatisfied();
}
@Test
public void testLocalTransportAddedBeforeInit() throws Exception {
final ConnectionWindow window = createConnectionWindow(remoteIndex);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise after adding transport
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
// Update the window
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
oneOf(db).setConnectionWindow(contactId, remoteIndex, window);
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// Add the transport
c.eventOccurred(new TransportAddedEvent(transportId));
// The IV should be expected
assertFalse(c.isInitialised());
ConnectionContext ctx = c.acceptConnection(transportId, encryptedIv);
assertTrue(c.isInitialised());
assertNotNull(ctx);
assertEquals(contactId, ctx.getContactId());
assertEquals(remoteIndex, ctx.getTransportIndex());
assertEquals(3, ctx.getConnectionNumber());
// The IV should no longer be expected
assertNull(c.acceptConnection(transportId, encryptedIv));
// The window should have advanced
Map<Long, byte[]> unseen = window.getUnseen();
assertEquals(19, unseen.size());
for(int i = 0; i < 19; i++) {
assertEquals(i != 3, unseen.containsKey(Long.valueOf(i)));
}
context.assertIsSatisfied();
}
@Test
public void testRemoteTransportAddedAfterInit() throws Exception {
final ConnectionWindow window = createConnectionWindow(remoteIndex);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise before updating the contact
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(null));
// Update the contact
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
// Update the window
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
oneOf(db).setConnectionWindow(contactId, remoteIndex, window);
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// The IV should not be expected
assertFalse(c.isInitialised());
assertNull(c.acceptConnection(transportId, encryptedIv));
assertTrue(c.isInitialised());
// Update the contact
c.eventOccurred(new RemoteTransportsUpdatedEvent(contactId,
remoteTransports));
// The IV should be expected
ConnectionContext ctx = c.acceptConnection(transportId, encryptedIv);
assertNotNull(ctx);
assertEquals(contactId, ctx.getContactId());
assertEquals(remoteIndex, ctx.getTransportIndex());
assertEquals(3, ctx.getConnectionNumber());
// The IV should no longer be expected
assertNull(c.acceptConnection(transportId, encryptedIv));
// The window should have advanced
Map<Long, byte[]> unseen = window.getUnseen();
assertEquals(19, unseen.size());
for(int i = 0; i < 19; i++) {
assertEquals(i != 3, unseen.containsKey(Long.valueOf(i)));
}
context.assertIsSatisfied();
}
@Test
public void testRemoteTransportAddedBeforeInit() throws Exception {
final ConnectionWindow window = createConnectionWindow(remoteIndex);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise after updating the contact
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
// Update the window
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
oneOf(db).setConnectionWindow(contactId, remoteIndex, window);
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// Update the contact
c.eventOccurred(new RemoteTransportsUpdatedEvent(contactId,
remoteTransports));
// The IV should be expected
assertFalse(c.isInitialised());
ConnectionContext ctx = c.acceptConnection(transportId, encryptedIv);
assertTrue(c.isInitialised());
assertNotNull(ctx);
assertEquals(contactId, ctx.getContactId());
assertEquals(remoteIndex, ctx.getTransportIndex());
assertEquals(3, ctx.getConnectionNumber());
// The IV should no longer be expected
assertNull(c.acceptConnection(transportId, encryptedIv));
// The window should have advanced
Map<Long, byte[]> unseen = window.getUnseen();
assertEquals(19, unseen.size());
for(int i = 0; i < 19; i++) {
assertEquals(i != 3, unseen.containsKey(Long.valueOf(i)));
}
context.assertIsSatisfied();
}
@Test
public void testRemoteTransportRemovedAfterInit() throws Exception {
final ConnectionWindow window = createConnectionWindow(remoteIndex);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise before updating the contact
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// Ensure the recogniser is initialised
assertFalse(c.isInitialised());
assertNull(c.acceptConnection(transportId, new byte[IV_LENGTH]));
assertTrue(c.isInitialised());
// Update the contact
c.eventOccurred(new RemoteTransportsUpdatedEvent(contactId,
Collections.<Transport>emptyList()));
// The IV should not be expected
assertNull(c.acceptConnection(transportId, encryptedIv));
context.assertIsSatisfied();
}
@Test
public void testRemoteTransportRemovedBeforeInit() throws Exception {
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise after updating the contact
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(null));
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// Update the contact
c.eventOccurred(new RemoteTransportsUpdatedEvent(contactId,
Collections.<Transport>emptyList()));
// The IV should not be expected
assertFalse(c.isInitialised());
assertNull(c.acceptConnection(transportId, encryptedIv));
assertTrue(c.isInitialised());
context.assertIsSatisfied();
}
@Test
public void testRemoteTransportIndexChangedAfterInit() throws Exception {
// The contact changes the transport ID <-> index relationships
final TransportId transportId1 =
new TransportId(TestUtils.getRandomId());
final TransportIndex remoteIndex1 = new TransportIndex(11);
Map<String, String> properties = Collections.singletonMap("foo", "bar");
Transport remoteTransport = new Transport(transportId, remoteIndex1,
properties);
Transport remoteTransport1 = new Transport(transportId1, remoteIndex,
properties);
Collection<Transport> remoteTransports1 = Arrays.asList(
new Transport[] {remoteTransport, remoteTransport1});
// Use two local transports for this test
TransportIndex localIndex1 = new TransportIndex(17);
Transport localTransport = new Transport(transportId, localIndex,
properties);
Transport localTransport1 = new Transport(transportId1, localIndex1,
properties);
final Collection<Transport> localTransports1 = Arrays.asList(
new Transport[] {localTransport, localTransport1});
final ConnectionWindow window = createConnectionWindow(remoteIndex);
final ConnectionWindow window1 = createConnectionWindow(remoteIndex1);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
// Initialise before updating the contact
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
oneOf(db).getLocalTransports();
will(returnValue(localTransports1));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
// First, transportId <-> remoteIndex, transportId1 <-> remoteIndex
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
oneOf(db).getRemoteIndex(contactId, transportId1);
will(returnValue(remoteIndex1));
oneOf(db).getConnectionWindow(contactId, remoteIndex1);
will(returnValue(window1));
// Later, transportId <-> remoteIndex1, transportId1 <-> remoteIndex
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
oneOf(db).getConnectionWindow(contactId, remoteIndex1);
will(returnValue(window1));
// Update the window
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(window));
oneOf(db).setConnectionWindow(contactId, remoteIndex, window);
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniserImpl c = new ConnectionRecogniserImpl(crypto, db,
executor);
byte[] encryptedIv = calculateIv();
// Ensure the recogniser is initialised
assertFalse(c.isInitialised());
assertNull(c.acceptConnection(transportId, new byte[IV_LENGTH]));
assertTrue(c.isInitialised());
// Update the contact
c.eventOccurred(new RemoteTransportsUpdatedEvent(contactId,
remoteTransports1));
// The IV should not be expected by the old transport
assertNull(c.acceptConnection(transportId, encryptedIv));
// The IV should be expected by the new transport
ConnectionContext ctx = c.acceptConnection(transportId1, encryptedIv);
assertNotNull(ctx);
assertEquals(contactId, ctx.getContactId());
assertEquals(remoteIndex, ctx.getTransportIndex());
assertEquals(3, ctx.getConnectionNumber());
// The IV should no longer be expected
assertNull(c.acceptConnection(transportId1, encryptedIv));
// The window should have advanced
Map<Long, byte[]> unseen = window.getUnseen();
assertEquals(19, unseen.size());
for(int i = 0; i < 19; i++) {
assertEquals(i != 3, unseen.containsKey(Long.valueOf(i)));
}
context.assertIsSatisfied();
}
private ConnectionWindow createConnectionWindow(TransportIndex index) {
return new ConnectionWindowImpl(crypto, index, inSecret) {
@Override
public void erase() {}
};
}
private byte[] calculateIv() throws Exception {
// Calculate the shared secret for connection number 3
byte[] secret = inSecret;
for(int i = 0; i < 4; i++) {
@@ -109,85 +544,6 @@ public class ConnectionRecogniserImplTest extends TestCase {
Cipher ivCipher = crypto.getIvCipher();
ivCipher.init(Cipher.ENCRYPT_MODE, ivKey);
byte[] iv = IvEncoder.encodeIv(true, remoteIndex.getInt(), 3);
byte[] encryptedIv = ivCipher.doFinal(iv);
Mockery context = new Mockery();
final DatabaseComponent db = context.mock(DatabaseComponent.class);
context.checking(new Expectations() {{
oneOf(db).addListener(with(any(ConnectionRecogniserImpl.class)));
// Initialise
oneOf(db).getLocalTransports();
will(returnValue(transports));
oneOf(db).getContacts();
will(returnValue(Collections.singletonList(contactId)));
oneOf(db).getRemoteIndex(contactId, transportId);
will(returnValue(remoteIndex));
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(connectionWindow));
// Update the window
oneOf(db).getConnectionWindow(contactId, remoteIndex);
will(returnValue(connectionWindow));
oneOf(db).setConnectionWindow(contactId, remoteIndex,
connectionWindow);
}});
Executor executor = new ImmediateExecutor();
ConnectionRecogniser c = new ConnectionRecogniserImpl(crypto, db,
executor);
// The IV should not be expected by the wrong transport
TransportId wrong = new TransportId(TestUtils.getRandomId());
c.acceptConnection(wrong, encryptedIv, new Callback() {
public void connectionAccepted(ConnectionContext ctx) {
fail();
}
public void connectionRejected() {
// Expected
}
public void handleException(DbException e) {
fail();
}
});
// The IV should be expected by the right transport
c.acceptConnection(transportId, encryptedIv, new Callback() {
public void connectionAccepted(ConnectionContext ctx) {
assertNotNull(ctx);
assertEquals(contactId, ctx.getContactId());
assertEquals(remoteIndex, ctx.getTransportIndex());
assertEquals(3L, ctx.getConnectionNumber());
}
public void connectionRejected() {
fail();
}
public void handleException(DbException e) {
fail();
}
});
// The IV should no longer be expected
c.acceptConnection(transportId, encryptedIv, new Callback() {
public void connectionAccepted(ConnectionContext ctx) {
fail();
}
public void connectionRejected() {
// Expected
}
public void handleException(DbException e) {
fail();
}
});
// The window should have advanced
Map<Long, byte[]> unseen = connectionWindow.getUnseen();
assertEquals(19, unseen.size());
for(int i = 0; i < 19; i++) {
assertEquals(i != 3, unseen.containsKey(Long.valueOf(i)));
}
context.assertIsSatisfied();
return ivCipher.doFinal(iv);
}
}