I2NP: Fix DI test

This commit is contained in:
zzz
2018-08-04 16:31:10 +00:00
parent 21fe962abd
commit 775188a36c

View File

@@ -9,17 +9,39 @@ package net.i2p.data.i2np;
*/ */
import net.i2p.data.DataFormatException; import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.DataStructure; import net.i2p.data.DataStructure;
import net.i2p.data.Hash; import net.i2p.data.Hash;
import net.i2p.data.StructureTest; import net.i2p.data.StructureTest;
import net.i2p.data.TunnelId; import net.i2p.data.TunnelId;
import org.junit.Test;
/** /**
* Test harness for loading / storing DeliveryInstructions objects * Test harness for loading / storing DeliveryInstructions objects
* *
* @author jrandom * @author jrandom
*/ */
public class DeliveryInstructionsTest extends StructureTest { public class DeliveryInstructionsTest extends StructureTest {
/**
* Override because DI doesn't support input/output streams any more
*/
@Override
@Test
public void testStructure() throws Exception{
DeliveryInstructions orig = (DeliveryInstructions) createDataStructure();
byte[] temp = new byte[100];
int len = orig.writeBytes(temp, 0);
DeliveryInstructions ds = (DeliveryInstructions) createStructureToRead();
ds.readBytes(temp, 0);
byte[] temp2 = new byte[100];
int len2 = ds.writeBytes(temp2, 0);
assert(len2 == len);
assert(DataHelper.eq(temp, 0, temp2, 0, len));
}
public DataStructure createDataStructure() throws DataFormatException { public DataStructure createDataStructure() throws DataFormatException {
DeliveryInstructions instructions = new DeliveryInstructions(); DeliveryInstructions instructions = new DeliveryInstructions();
//instructions.setDelayRequested(true); //instructions.setDelayRequested(true);