public static NodeInfo initFrom(ResultSet rs) throws SQLException, EncryptionError { return new NodeInfo(new PublicKey(rs.getBytes("public_key")), rs.getInt("node_number"), rs.getString("node_name"), rs.getString("host"),rs.getString("public_host"), rs.getInt("udp_server_port"), rs.getInt("http_client_port"), rs.getInt("http_server_port")); } }
return new NodeInfo( key, b.getIntOrThrow("node_number"),
@Test public void sendTrippleAndReceive() throws Exception { NodeInfo node1 = new NodeInfo(TestKeys.publicKey(0),10, "test_node_10", "localhost", 16201, 16202, 16301); NodeInfo node2 = new NodeInfo(TestKeys.publicKey(1),11, "test_node_11", "localhost", 16203, 16204, 16302); NodeInfo node3 = new NodeInfo(TestKeys.publicKey(2),12, "test_node_12", "localhost", 16204, 16205, 16303);
new NodeInfo( getNodeKey(i).getPublicKey(), i,
NodeInfo myInfo = new NodeInfo(getNodePublicKey(0), 1, "node1", "localhost", 7101, 7102, 7104); NetConfig nc = new NetConfig(asList(myInfo));
@Test public void sendAndReceive() throws Exception { NodeInfo node1 = new NodeInfo(TestKeys.publicKey(0),10, "test_node_10", "localhost", 16201, 16202, 16301); NodeInfo node2 = new NodeInfo(TestKeys.publicKey(1),11, "test_node_11", "localhost", 16203, 16204, 16302); NodeInfo node3 = new NodeInfo(TestKeys.publicKey(2),12, "test_node_12", "localhost", 16204, 16205, 16303);
@Test public void sendTrippleMultiTimesAndReceive() throws Exception { NodeInfo node1 = new NodeInfo(TestKeys.publicKey(0),10, "test_node_10", "localhost", 16201, 16202, 16301); NodeInfo node2 = new NodeInfo(TestKeys.publicKey(1),11, "test_node_11", "localhost", 16203, 16204, 16302); NodeInfo node3 = new NodeInfo(TestKeys.publicKey(2),12, "test_node_12", "localhost", 16204, 16205, 16303);
@Test public void packUnpack() throws Exception { NodeInfo ni = new NodeInfo(TestKeys.publicKey(0),1, "test1", "localhost", 17101, 17102, 17104); HashId id1 = HashId.createRandom(); ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS); ZonedDateTime expiresAt = now.plusDays(30); ItemResult ir1 = new ItemResult(ItemState.PENDING, false, now, expiresAt); ItemResult ir2 = new ItemResult(ItemState.REVOKED, true, now, expiresAt); ItemNotification n1 = new ItemNotification(ni, id1, ir1, true); ItemNotification n2 = new ItemNotification(ni, id1, ir1, false); ItemNotification n3 = new ItemNotification(ni, id1, ir1, true); byte[] packed = Notification.pack(asList(n1, n2, n3)); List<Notification> l = Notification.unpack(ni, packed); assertEquals(3, l.size()); ItemNotification n = (ItemNotification) l.get(0); assertEquals(n, n1); n = (ItemNotification) l.get(1); assertEquals(n, n2); n = (ItemNotification) l.get(2); assertEquals(n, n3); }
int offset = 7100 + 10 * i; NodeInfo info = new NodeInfo( getNodeKey(i).getPublicKey(), i,
private void loadNodeConfig() throws IOException, SQLException { Yaml yaml = new Yaml(); configRoot = (String) options.valueOf("config"); nodeKey = null; Binder settings = Binder.of(yaml.load(new FileInputStream(configRoot + "/config/config.yaml"))); log("node settings: " + settings); String nodeKeyFileName = configRoot + "/tmp/" + settings.getStringOrThrow("node_name") + ".private.unikey"; log(nodeKeyFileName); nodeKey = new PrivateKey(Do.read(nodeKeyFileName)); myInfo = new NodeInfo(nodeKey.getPublicKey(), settings.getIntOrThrow("node_number"), settings.getStringOrThrow("node_name"), (String) settings.getListOrThrow("ip").get(0), settings.getStringOrThrow("public_host"), settings.getIntOrThrow("udp_server_port"), settings.getIntOrThrow("http_client_port"), settings.getIntOrThrow("http_server_port") ); config.setIsFreeRegistrationsAllowedFromYaml(settings.getBoolean("allow_free_registrations", false)); config.setPermanetMode(settings.getBoolean("permanet_mode", false)); ledger = new PostgresLedger(settings.getStringOrThrow("database")); log("ledger constructed"); log("key loaded: " + nodeKey.info()); log("node local URL: " + myInfo.publicUrlString()); log("node info: " + myInfo.toBinder()); }
int offset = 7100 + 10 * i; NodeInfo info = new NodeInfo( getNodeKey(i).getPublicKey(), i,
@Test public void sendBadNetConfig() throws Exception { NodeInfo node1 = new NodeInfo(TestKeys.publicKey(0),10, "test_node_10", "localhost", 16201, 16202, 16301); NodeInfo node2 = new NodeInfo(TestKeys.publicKey(1),11, "test_node_11", "localhost", 16203, 16204, 16302); NodeInfo node3 = new NodeInfo(TestKeys.publicKey(2),12, "test_node_12", "localhost", 16204, 16205, 16303);