Skip to content

Conversation

@oskarszoon
Copy link
Contributor

Readds #186

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

🤖 Claude Code Review

Status: Complete

Current Review:

Found 3 issues requiring attention:

  1. Critical Bug - Function call parameter mismatch in services/p2p/server_helpers.go:486 - This will cause a compilation error
  2. Code cleanup - Commented-out code in test file should be removed per project conventions
  3. Test consistency - Error handling should use t.Fatalf instead of t.Errorf for timeout failures

The PR adds useful multi-node test infrastructure, but the critical bug in InjectPeerForTesting must be fixed before this can compile and run.

// InjectPeerForTesting directly injects a peer into the registry for testing purposes.
// This method allows deterministic peer setup without requiring actual P2P network connections.
func (s *Server) InjectPeerForTesting(peerID peer.ID, clientName, dataHubURL string, height uint32, blockHash string) {
s.addConnectedPeer(peerID, clientName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Critical Bug: Incorrect function call parameters

The addConnectedPeer function signature expects 5 parameters:

func (s *Server) addConnectedPeer(peerID peer.ID, clientName string, height uint32, blockHash *chainhash.Hash, dataHubURL string)

But this call only passes 2 parameters. This will cause a compilation error.

Fix: The call should include all required parameters or the function should be updated to match the new signature.

coinbaseTx := nodeA.MineToMaturityAndGetSpendableCoinbaseTx(t, nodeA.Ctx)
t.Logf(" Coinbase transaction available for spending: %s", coinbaseTx.TxIDChainHash().String())

// nodeA.InjectPeer(t, nodeB)
Copy link
Contributor

Choose a reason for hiding this comment

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

Code cleanup: Commented-out code

This test file contains multiple instances of commented-out code (lines 80, 101, 106-111).

Per project conventions, commented-out code should be removed before merging. If this code is needed for debugging during development, consider using build tags or test helper flags instead.

for {
select {
case <-ctx.Done():
t.Errorf("Timeout waiting for block with hash %s", blockHash.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Test error handling: Use t.Fatalf instead of t.Errorf

When a timeout occurs in test wait functions, the test should fail immediately and stop execution. Using t.Errorf continues execution after logging the error, which can lead to confusing follow-up failures.

Suggested fix:

t.Fatalf("Timeout waiting for block with hash %s", blockHash.String())

This matches the pattern used in other wait functions like WaitForBlock (line 1332).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants