fix(testcase): remove peer from PeerManager after testcase by 317787106 · Pull Request #6486 · tronprotocol/java-tron

Conversation

@317787106

What does this PR do?

  • remove peer from PeerManager after testcase, fix RpcApiServicesTest.testGetNodeInfo
  • add log when receives keep alive message in BackupManager to help for debug
  • check if tronNetDelegate is null in PeerStatusCheck to fix NullPointerException when use mock in several testcases, such as org.tron.core.net.peer.PeerStatusCheckMockTest. NullPointerException occurs only in mock test.

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

xxo1shine

Federico2014

public void clearPeers() {
for (PeerConnection p : PeerManager.getPeers()) {
PeerManager.remove(p.getChannel());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add Args.clearParam(); ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This testcase has extended BaseTest which implements Args.clearParam() in @afterclass method.

Federico2014

warku123

return;
}

logger.info("Receive keep alive message from {}", sender);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should be sender.getHostString() to keep consistency with lines 121 and 126?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's more accurate to logging InetSocketAddress, the style is /IP:port. Line 126 only needs IP

warku123

halibobo1205

lvs0075

kuny0707

warku123 pushed a commit to warku123/java-tron that referenced this pull request

Feb 6, 2026
…col#6486)

* remove peer from PeerManager after testcase
* add coverage of NodeInfoServiceTest

Reviewers

@kuny0707 kuny0707 kuny0707 approved these changes

@lvs0075 lvs0075 lvs0075 approved these changes

+4 more reviewers

@xxo1shine xxo1shine xxo1shine approved these changes

@warku123 warku123 warku123 approved these changes

Reviewers whose approvals may not affect merge requirements