private Map<Integer, NetworkConfiguration> getNetConf() { int noOfParties = 2; List<Integer> ports = new ArrayList<>(noOfParties); for (int i = 1; i <= noOfParties; i++) { ports.add(9000 + i * (noOfParties - 1)); } return NetworkUtil.getNetworkConfigurations(ports); } }
@Before public void setUp() { confs = NetworkUtil.getNetworkConfigurations(n); }
/** * As getConfigurations(n, ports) but tries to find free ephemeral ports (but note that there is * no guarantee that ports will remain unused). */ public static Map<Integer, NetworkConfiguration> getNetworkConfigurations(int n) { List<Integer> ports = getFreePorts(n); return getNetworkConfigurations(ports); } }
@Test(expected = InterruptedException.class) public void testInterruptWhileConnecting() throws Throwable { ExecutorService es = Executors.newFixedThreadPool(2); Map<Integer, NetworkConfiguration> confs = NetworkUtil.getNetworkConfigurations(2); List<Future<?>> futures = new ArrayList<>(2); for (NetworkConfiguration conf : confs.values()) { futures.add(es.submit(() -> new Connector(conf, Connector.DEFAULT_CONNECTION_TIMEOUT))); } es.shutdownNow(); try { futures.get(0).get(); } catch (ExecutionException e) { if (e.getCause() instanceof RuntimeException && e.getCause().getCause() instanceof InterruptedException) { throw e.getCause().getCause(); } else { throw e; } } }
protected void runTest( TestThreadRunner.TestThreadFactory<SpdzResourcePool, ProtocolBuilderNumeric> f, EvaluationStrategy evalStrategy, int noOfParties, boolean corruptMac) throws Exception { List<Integer> ports = new ArrayList<>(noOfParties); for (int i = 1; i <= noOfParties; i++) { ports.add(9000 + i * (noOfParties - 1)); } Map<Integer, NetworkConfiguration> netConf = NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadConfiguration<SpdzResourcePool, ProtocolBuilderNumeric>> conf = new HashMap<>(); for (int playerId : netConf.keySet()) { ProtocolSuiteNumeric<SpdzResourcePool> protocolSuite = new SpdzProtocolSuite(150); BatchEvaluationStrategy<SpdzResourcePool> batchEvalStrat = evalStrategy.getStrategy(); ProtocolEvaluator<SpdzResourcePool> evaluator = new BatchedProtocolEvaluator<>(batchEvalStrat, protocolSuite); SecureComputationEngine<SpdzResourcePool, ProtocolBuilderNumeric> sce = new SecureComputationEngineImpl<>(protocolSuite, evaluator); TestThreadRunner.TestThreadConfiguration<SpdzResourcePool, ProtocolBuilderNumeric> ttc = new TestThreadRunner.TestThreadConfiguration<>(sce, () -> createResourcePool(playerId, noOfParties, new Random(), new SecureRandom(), corruptMac), () -> new SocketNetwork(netConf.get(playerId))); conf.put(playerId, ttc); } TestThreadRunner.run(f, conf); }
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadConfiguration<SpdzResourcePool, ProtocolBuilderNumeric>> conf = new HashMap<>();
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadRunner.TestThreadConfiguration<ResourcePoolImpl, ProtocolBuilderBinary>> conf =
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadRunner .TestThreadConfiguration<ResourcePoolImpl, ProtocolBuilderBinary>> conf =
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadRunner .TestThreadConfiguration<ResourcePoolImpl, ProtocolBuilderBinary>> conf =
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadRunner.TestThreadConfiguration<DummyArithmeticResourcePool, ProtocolBuilderNumeric>> conf = new HashMap<>();
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadRunner.TestThreadConfiguration<DummyArithmeticResourcePool, ProtocolBuilderNumeric>> conf = new HashMap<>();
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadConfiguration<ResourcePoolImpl, ProtocolBuilderBinary>> conf = new HashMap<>();
List<Integer> ports = NetworkUtil.getFreePorts(noPlayers); Map<Integer, NetworkConfiguration> netConf = NetworkUtil .getNetworkConfigurations(ports); Map<Integer, TestThreadConfiguration<ResourcePoolImpl, ProtocolBuilderBinary>> conf = new HashMap<>();
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadRunner.TestThreadConfiguration<
NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadRunner.TestThreadConfiguration<SpdzResourcePool, ProtocolBuilderNumeric>> conf = new HashMap<>();
List<Integer> ports = NetworkUtil.getFreePorts(noPlayers); Map<Integer, NetworkConfiguration> netConf = NetworkUtil .getNetworkConfigurations(ports); Map<Integer, TestThreadConfiguration<ResourcePoolImpl, ProtocolBuilderBinary>> conf = new HashMap<>();