mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-21 10:27:30 +00:00
ipn,net,tsnet,wgengine: make an eventbus mandatory where it is used (#16594)
In the components where an event bus is already plumbed through, remove the exceptions that allow it to be omitted, and update all the tests that relied on those workarounds execute properly. This change applies only to the places where we're already using the bus; it does not enforce the existence of a bus in other components (yet), Updates #15160 Change-Id: Iebb92243caba82b5eb420c49fc3e089a77454f65 Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
This commit is contained in:
@@ -263,16 +263,21 @@ func (d *TestIGD) handlePCPQuery(pkt []byte, src netip.AddrPort) {
|
||||
}
|
||||
|
||||
// newTestClient configures a new test client connected to igd for mapping updates.
|
||||
// If bus != nil, update events are published to it.
|
||||
// A cleanup for the resulting client is added to t.
|
||||
// If bus == nil, a new empty event bus is constructed that is cleaned up when t exits.
|
||||
// A cleanup for the resulting client is also added to t.
|
||||
func newTestClient(t *testing.T, igd *TestIGD, bus *eventbus.Bus) *Client {
|
||||
if bus == nil {
|
||||
bus = eventbus.New()
|
||||
t.Log("Created empty event bus for test client")
|
||||
t.Cleanup(bus.Close)
|
||||
}
|
||||
var c *Client
|
||||
c = NewClient(Config{
|
||||
Logf: tstest.WhileTestRunningLogger(t),
|
||||
NetMon: netmon.NewStatic(),
|
||||
ControlKnobs: new(controlknobs.Knobs),
|
||||
EventBus: bus,
|
||||
OnChange: func() {
|
||||
OnChange: func() { // TODO(creachadair): Remove.
|
||||
t.Logf("port map changed")
|
||||
t.Logf("have mapping: %v", c.HaveMapping())
|
||||
},
|
||||
|
Reference in New Issue
Block a user