@Before public void setup() { memStore = new InMemoryStorage(); }
@Test public void testPutAndGetObjects() { memStore.putObject("TestStore", "Key1", "Foo"); assertEquals("Foo", memStore.getObject("TestStore", "Key1")); memStore.putObject("TestStore", "Key2", "Bar"); assertEquals("Bar", memStore.getObject("TestStore", "Key2")); memStore.putObject("TestStore", "Key2", "Baz"); assertEquals("Baz", memStore.getObject("TestStore", "Key2")); memStore.putObject("TestStore2", "Key2", "Fum"); assertEquals("Fum", memStore.getObject("TestStore2", "Key2")); assertNull(memStore.getObject("NonExistentStoreName", "Key")); assertNull(memStore.getObject("TestStore", "NonExistentKey")); }
@Before public void setup() { storage = new FilebasedStreamedStorageImpl(new InMemoryStorage()); }
@Test(expected = IllegalArgumentException.class) public void testDataSupplierExpPipeNotFound() { SpdzStorageDataSupplier supplier = new SpdzStorageDataSupplier(new FilebasedStreamedStorageImpl(new InMemoryStorage()), "invalid", 2); supplier.getNextExpPipe(); }
@Test(expected = IllegalArgumentException.class) public void testDataSupplierNextBitNotFound() { SpdzStorageDataSupplier supplier = new SpdzStorageDataSupplier(new FilebasedStreamedStorageImpl(new InMemoryStorage()), "invalid", 2); supplier.getNextBit(); }
@Test(expected = IllegalArgumentException.class) public void testDataSupplierModNotFound() { SpdzStorageDataSupplier supplier = new SpdzStorageDataSupplier(new FilebasedStreamedStorageImpl(new InMemoryStorage()), "invalid", 2); supplier.getFieldDefinition(); }
@Test(expected = IllegalArgumentException.class) public void testDataSupplierInputMaskNotFound() { SpdzStorageDataSupplier supplier = new SpdzStorageDataSupplier(new FilebasedStreamedStorageImpl(new InMemoryStorage()), "invalid", 2); supplier.getNextInputMask(1); }
@Test(expected = IllegalArgumentException.class) public void testDataSupplierSskNotFound() { SpdzStorageDataSupplier supplier = new SpdzStorageDataSupplier(new FilebasedStreamedStorageImpl(new InMemoryStorage()), "invalid", 2); supplier.getSecretSharedKey(); }
@Test(expected = IllegalArgumentException.class) public void testDataSupplierTripleNotFound() { SpdzStorageDataSupplier supplier = new SpdzStorageDataSupplier(new FilebasedStreamedStorageImpl(new InMemoryStorage()), "invalid", 2); supplier.getNextTriple(); }
@Test(expected = IllegalArgumentException.class) public void testDataSupplierRandomElmNotFound() { SpdzStorageDataSupplier supplier = new SpdzStorageDataSupplier(new FilebasedStreamedStorageImpl(new InMemoryStorage()), "invalid", 2); supplier.getNextRandomFieldElement(); } }
/** * Tests that we successfully can initialize the InMemory version of the storage with spdz * preprocessed data. Cannot currently easily be used within an actual MPC test since we now only * support a streamed version. */ @Test public void testInitInMemoryStorageAndDoubleFetch() { InitializeStorage.initStorage(new Storage[]{new InMemoryStorage()}, 2, 10, 10, 100, 10); }
private SpdzResourcePool createSpdzResourcePool(Properties properties) { String strat = properties.getProperty("spdz.preprocessingStrategy"); final PreprocessingStrategy strategy = PreprocessingStrategy.valueOf(strat); SpdzDataSupplier supplier = null; if (strategy == PreprocessingStrategy.DUMMY) { BigInteger modulus = ModulusFinder.findSuitableModulus(512); supplier = new SpdzDummyDataSupplier(myId, noOfPlayers, new BigIntegerFieldDefinition(modulus), modulus); } if (strategy == PreprocessingStrategy.STATIC) { int noOfThreadsUsed = 1; String storageName = SpdzStorageDataSupplier.STORAGE_NAME_PREFIX + noOfThreadsUsed + "_" + myId + "_" + 0 + "_"; supplier = new SpdzStorageDataSupplier( new FilebasedStreamedStorageImpl(new InMemoryStorage()), storageName, noOfPlayers); } return new SpdzResourcePoolImpl(myId, noOfPlayers, new SpdzOpenedValueStoreImpl(), supplier, new AesCtrDrbg(new byte[32])); }
@Test public void testNoIoExceptionOnClose() { HashMap<String, ObjectInputStream> inputs = new HashMap<>(); HashMap<String, ObjectOutputStream> outputs = new HashMap<>(); try { FileOutputStream fos = new FileOutputStream("foo"); ObjectOutputStream oos = new ObjectOutputStream(fos) { @Override public void close() throws IOException { throw new IOException("Mock Exception"); } }; outputs.put("bad-store", oos); FileInputStream fis = new FileInputStream("foo"); ObjectInputStream ois = new ObjectInputStream(fis) { @Override public void close() throws IOException { throw new IOException("Mock Exception"); } }; inputs.put("bad-store", ois); } catch (IOException e) { fail("Should not be reachable."); } FilebasedStreamedStorageImpl badStore = new FilebasedStreamedStorageImpl(new InMemoryStorage(), inputs, outputs); badStore.shutdown(); assertTrue("Should be reachable. Shutdown should handle the exceptions for us.", true); }
@Test public void testDataSupplierModFoundTwice() { FilebasedStreamedStorageImpl storage = new FilebasedStreamedStorageImpl(new InMemoryStorage()); storage.putNext("valid" + SpdzStorageDataSupplier.MODULUS_KEY, BigInteger.ONE); SpdzStorageDataSupplier supplier = new SpdzStorageDataSupplier(storage, "valid", 2); supplier.getFieldDefinition(); supplier.getFieldDefinition(); }
@Test @Ignore("This is not tested on windows and does not work here") public void test_compareLT_Sequential_static() throws Exception { int noOfThreads = 1; try { InitializeStorage.initStreamedStorage(new FilebasedStreamedStorageImpl(new InMemoryStorage()), 2, noOfThreads, 1000, 100, 10000, 100); runTest(new CompareTests.TestCompareLT<>(), PreprocessingStrategy.STATIC, 2); } catch (Exception e) { //Should not fail Assert.fail(); } finally { InitializeStorage.cleanup(); } }
+ myId + "_" + 0 + "_"; FilebasedStreamedStorageImpl storage = new FilebasedStreamedStorageImpl(new InMemoryStorage()); supplier = new SpdzStorageDataSupplier(storage, storageName, numberOfParties);