Skip to content

Commit

Permalink
fix notification of connection change on check connection
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Jan 8, 2025
1 parent 950c3ed commit 1e31649
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/monero/common/MoneroConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public MoneroConnectionManager checkConnection() {
MoneroRpcConnection connection = getConnection();
if (connection != null) {
if (connection.checkConnection(timeoutMs)) connectionChanged = true;
if (processResponses(Arrays.asList(connection)) != null) return this; // done if connection set from responses
processResponses(Arrays.asList(connection));
}
if (autoSwitch && !isConnected()) {
MoneroRpcConnection bestConnection = getBestAvailableConnection(connection);
Expand Down
4 changes: 1 addition & 3 deletions src/test/java/TestMoneroConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,9 @@ public void testConnectionManager() throws InterruptedException, IOException {
assertEquals(++numExpectedChanges, listener.changedConnections.size());

// connect to specific endpoint with authentication
connectionManager.setAutoSwitch(false);
orderedConnections.get(1).setCredentials("rpc_user", "abc123");
connectionManager.checkConnection();
assertEquals(connection.getUri(), walletRpcs.get(1).getRpcConnection().getUri());
assertEquals(connectionManager.getConnection().getUri(), walletRpcs.get(1).getRpcConnection().getUri());
assertTrue(connection.isOnline());
assertTrue(connection.isAuthenticated());
assertEquals(++numExpectedChanges, listener.changedConnections.size());
Expand Down Expand Up @@ -211,7 +210,6 @@ public void testConnectionManager() throws InterruptedException, IOException {
assertEquals(++numExpectedChanges, listener.changedConnections.size());

// check all connections and test auto switch
connectionManager.setAutoSwitch(true);
connectionManager.checkConnections();
assertEquals(++numExpectedChanges, listener.changedConnections.size());
assertTrue(connectionManager.isConnected());
Expand Down

0 comments on commit 1e31649

Please sign in to comment.