Skip to content

Commit

Permalink
Various fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJohnson committed Jan 3, 2025
1 parent 91fc712 commit 2b5209c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public final class ConnectionInfo {
/**
* The remote identifier (as set on the remote node by {@link
* NetworkTableInstance#startClient4(String)}).
* NetworkTableInstance#startClient(String)}).
*/
public final String remote_id;

Expand Down
2 changes: 1 addition & 1 deletion ntcore/src/main/native/include/ntcore_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef NT_Handle NT_Topic;
typedef NT_Handle NT_Subscriber;
typedef NT_Handle NT_Publisher;

/** Default network tables port number (NT4) */
/** Default network tables port number */
#define NT_DEFAULT_PORT 5810

/** NetworkTables data types. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void tearDown() {

/** Connect to the server. */
private void connect(int port) {
m_serverInst.startServer("connectionlistenertest.json", "127.0.0.1", 0, port);
m_clientInst.startClient4("client");
m_serverInst.startServer("connectionlistenertest.json", "127.0.0.1", port);
m_clientInst.startClient("client");
m_clientInst.setServer("127.0.0.1", port);

// wait for client to report it's connected, then wait another 0.1 sec
Expand Down Expand Up @@ -113,7 +113,7 @@ void testJNI() {
@ParameterizedTest
@ValueSource(strings = {"127.0.0.1", "127.0.0.1 ", " 127.0.0.1 "})
void testThreaded(String address) {
m_serverInst.startServer("connectionlistenertest.json", address, 0, threadedPort);
m_serverInst.startServer("connectionlistenertest.json", address, threadedPort);
List<NetworkTableEvent> events = new ArrayList<>();
final int handle =
m_serverInst.addConnectionListener(
Expand All @@ -125,7 +125,7 @@ void testThreaded(String address) {
});

// trigger a connect event
m_clientInst.startClient4("client");
m_clientInst.startClient("client");
m_clientInst.setServer(address, threadedPort);
threadedPort++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ void addMessageTest() {
List<NetworkTableEvent> msgs = new ArrayList<>();
m_clientInst.addLogger(LogMessage.kInfo, 100, msgs::add);

m_clientInst.startClient4("client");
m_clientInst.startClient("client");
m_clientInst.setServer("127.0.0.1", 10000);

// wait for client to report it's started, then wait another 0.1 sec
try {
int count = 0;
while (!m_clientInst.getNetworkMode().contains(NetworkTableInstance.NetworkMode.kClient4)) {
while (!m_clientInst.getNetworkMode().contains(NetworkTableInstance.NetworkMode.kClient)) {
Thread.sleep(100);
count++;
if (count > 30) {
Expand Down
17 changes: 3 additions & 14 deletions ntcore/src/test/java/edu/wpi/first/networktables/TimeSyncTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void testServer() {
try (var poller = new NetworkTableListenerPoller(m_inst)) {
poller.addTimeSyncListener(false);

m_inst.startServer("timesynctest.json", "127.0.0.1", 0, 10030);
m_inst.startServer("timesynctest.json", "127.0.0.1", 10030);
var offset = m_inst.getServerTimeOffset();
assertTrue(offset.isPresent());
assertEquals(0L, offset.getAsLong());
Expand All @@ -61,19 +61,8 @@ void testServer() {
}

@Test
void testClient3() {
m_inst.startClient3("client");
var offset = m_inst.getServerTimeOffset();
assertFalse(offset.isPresent());

m_inst.stopClient();
offset = m_inst.getServerTimeOffset();
assertFalse(offset.isPresent());
}

@Test
void testClient4() {
m_inst.startClient4("client");
void testClient() {
m_inst.startClient("client");
var offset = m_inst.getServerTimeOffset();
assertFalse(offset.isPresent());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ void tearDown() {
}

private void connect() {
m_serverInst.startServer("topiclistenertest.json", "127.0.0.1", 0, 10010);
m_clientInst.startClient4("client");
m_serverInst.startServer("topiclistenertest.json", "127.0.0.1", 10010);
m_clientInst.startClient("client");
m_clientInst.setServer("127.0.0.1", 10010);

// Use connection listener to ensure we've connected
Expand Down
2 changes: 1 addition & 1 deletion ntcore/src/test/native/cpp/TimeSyncTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TEST_F(TimeSyncTest, TestServer) {
ASSERT_FALSE(data->valid);
}

TEST_F(TimeSyncTest, TestClient4) {
TEST_F(TimeSyncTest, TestClient) {
m_inst.StartClient("client");
auto offset = m_inst.GetServerTimeOffset();
ASSERT_FALSE(offset);
Expand Down

0 comments on commit 2b5209c

Please sign in to comment.