Skip to content

Commit 9e24f9d

Browse files
committed
Prevent tests from connecting to bootstrap servers
1 parent 1335ba5 commit 9e24f9d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

client.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"slices"
1717
"strings"
1818
"sync"
19+
"testing"
1920
"time"
2021

2122
"github.com/libp2p/go-libp2p"
@@ -86,8 +87,17 @@ func NewClient(config Config) (Client, error) {
8687
return nil, err
8788
}
8889

89-
// Get bootstrap peers from DHT library for DHT bootstrapping
90-
bootstrapPeers := dht.GetDefaultBootstrapPeerAddrInfos()
90+
// Get bootstrap peers based on environment
91+
// Test mode: empty list for fast, isolated tests
92+
// Production: IPFS default bootstrap peers
93+
var bootstrapPeers []peer.AddrInfo
94+
if testing.Testing() {
95+
bootstrapPeers = []peer.AddrInfo{}
96+
clientLogger.Infof("Test mode detected - using no bootstrap peers (isolated mode)")
97+
} else {
98+
bootstrapPeers = dht.GetDefaultBootstrapPeerAddrInfos()
99+
clientLogger.Infof("Using %d default IPFS bootstrap peers", len(bootstrapPeers))
100+
}
91101

92102
// Parse custom relay peers if provided
93103
customRelayPeers := parseRelayPeersFromConfig(config.RelayPeers, clientLogger)

0 commit comments

Comments
 (0)