WIP: rebase fork onto upstream/main (v1.103.0) #15
@@ -425,6 +425,13 @@ type Conn struct {
|
||||
// homeDERPGauge is the usermetric gauge for the home DERP region ID.
|
||||
// This can be nil when [Options.Metrics] are not enabled.
|
||||
homeDERPGauge *usermetric.Gauge
|
||||
|
||||
// checkNetworkUpDuringTests controls whether [Conn.networkDown]
|
||||
// will report the value of [Conn.networkUp] while running tests.
|
||||
//
|
||||
// This allows tests to pass when the user's machine is offline,
|
||||
// but allows us to still test network-down behaviour when desired.
|
||||
checkNetworkUpDuringTests bool
|
||||
}
|
||||
|
||||
// SetDebugLoggingEnabled controls whether spammy debug logging is enabled.
|
||||
@@ -1482,14 +1489,10 @@ func (c *Conn) LocalPort() uint16 {
|
||||
|
||||
var errNetworkDown = errors.New("magicsock: network down")
|
||||
|
||||
// This allows tests to pass when the user's machine is offline, but allows us
|
||||
// to still test network-down behaviour when desired.
|
||||
var checkNetworkDownDuringTests = false
|
||||
|
||||
func (c *Conn) networkDown() bool {
|
||||
// For tests, always assume the network is up unless we're explicitly
|
||||
// testing this behaviour.
|
||||
if envknob.AssumeNetworkUp() || (testenv.InTest() && !checkNetworkDownDuringTests) {
|
||||
if envknob.AssumeNetworkUp() || (testenv.InTest() && !c.checkNetworkUpDuringTests) {
|
||||
return false
|
||||
}
|
||||
return !c.networkUp.Load()
|
||||
|
||||
@@ -3386,9 +3386,8 @@ func TestNetworkSendErrors(t *testing.T) {
|
||||
t.Skipf("skipping on %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
tstest.Replace(t, &checkNetworkDownDuringTests, true)
|
||||
|
||||
conn, reg := newTestConnAndRegistry(t)
|
||||
conn.checkNetworkUpDuringTests = true
|
||||
|
||||
buffs := [][]byte{{00, 00, 00, 00, 00, 00, 00, 00}}
|
||||
ep := &lazyEndpoint{
|
||||
|
||||
Reference in New Issue
Block a user