What changed, and why it matters
This commit only adds a new unit test. It does not change any production code, so it cannot introduce a security vulnerability by itself. The test checks that btcd's sync-manager treats all peers as valid sync candidates on the Bitcoin 'regtest' private network, including Docker container addresses and remote IPs. This is expected behavior for regtest, which is meant for local testing and has no real-world Bitcoin value at stake.
No security action needed. Review the test as a normal code-quality change if desired.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds TestIsSyncCandidateRegtest in netsync/manager_test.go. It creates an inbound peer for each of four addresses (127.0.0.1, a Docker bridge IP, a public remote IP, and ::1) and asserts that SyncManager.isSyncCandidate returns true for all of them when running on RegressionNetParams. No production logic is modified. The test documents existing behavior: regtest disables the usual address-based sync-candidate restrictions.
Changed components
netsync/manager_test.goInspect captured patch +49 / −0
diff --git a/netsync/manager_test.go b/netsync/manager_test.go
index becf1a7..73eb0d5 100644
--- a/netsync/manager_test.go
+++ b/netsync/manager_test.go
@@ -1213,3 +1213,52 @@ func TestStartSyncChainCurrent(t *testing.T) {
require.False(t, sm.ibdMode,
"ibdMode should not be activated when chain is already current")
}
+
+// TestIsSyncCandidateRegtest verifies that isSyncCandidate accepts any peer
+// on regtest regardless of address, including non-localhost Docker bridge
+// addresses.
+func TestIsSyncCandidateRegtest(t *testing.T) {
+ t.Parallel()
+
+ params := chaincfg.RegressionNetParams
+ sm, tearDown := makeMockSyncManager(t, ¶ms)
+ defer tearDown()
+
+ tests := []struct {
+ name string
+ addr string
+ want bool
+ }{
+ {
+ name: "localhost",
+ addr: "127.0.0.1:18444",
+ want: true,
+ },
+ {
+ name: "docker bridge ip",
+ addr: "172.18.0.2:18444",
+ want: true,
+ },
+ {
+ name: "remote ip",
+ addr: "93.184.216.34:18444",
+ want: true,
+ },
+ {
+ name: "ipv6 loopback",
+ addr: "[::1]:18444",
+ want: true,
+ },
+ }
+
+ for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
+ p := peer.NewInboundPeer(&peer.Config{
+ ChainParams: sm.chainParams,
+ })
+
+ got := sm.isSyncCandidate(p)
+ require.Equal(t, tc.want, got)
+ })
+ }
+}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.