mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Unit tests for TransportKeyManager.
This commit is contained in:
@@ -1,22 +1,8 @@
|
||||
package org.briarproject.transport;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.api.transport.TransportConstants;
|
||||
import org.briarproject.transport.ReorderingWindow.Change;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.briarproject.api.transport.TransportConstants.REORDERING_WINDOW_SIZE;
|
||||
import static org.briarproject.util.ByteUtils.MAX_32_BIT_UNSIGNED;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -24,6 +10,7 @@ import java.util.Random;
|
||||
|
||||
import static org.briarproject.api.transport.TransportConstants.REORDERING_WINDOW_SIZE;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ReorderingWindowTest extends BriarTestCase {
|
||||
|
||||
@@ -46,7 +33,8 @@ public class ReorderingWindowTest extends BriarTestCase {
|
||||
Change change = window.setSeen(0L);
|
||||
// The window should slide by one element
|
||||
assertEquals(1L, window.getBase());
|
||||
assertEquals(Collections.singletonList((long) REORDERING_WINDOW_SIZE), change.getAdded());
|
||||
assertEquals(Collections.singletonList((long) REORDERING_WINDOW_SIZE),
|
||||
change.getAdded());
|
||||
assertEquals(Collections.singletonList(0L), change.getRemoved());
|
||||
// All elements in the window should be unseen
|
||||
assertArrayEquals(bitmap, window.getBitmap());
|
||||
@@ -76,7 +64,8 @@ public class ReorderingWindowTest extends BriarTestCase {
|
||||
Change change = window.setSeen(aboveMidpoint);
|
||||
// The window should slide by one element
|
||||
assertEquals(1L, window.getBase());
|
||||
assertEquals(Collections.singletonList((long) REORDERING_WINDOW_SIZE), change.getAdded());
|
||||
assertEquals(Collections.singletonList((long) REORDERING_WINDOW_SIZE),
|
||||
change.getAdded());
|
||||
assertEquals(Arrays.asList(0L, aboveMidpoint), change.getRemoved());
|
||||
// The highest element below the midpoint should be seen
|
||||
bitmap[bitmap.length / 2 - 1] = (byte) 0x01; // 0000 0001
|
||||
|
||||
Reference in New Issue
Block a user