@ -4,7 +4,6 @@
package controlclient
package controlclient
import (
import (
"bytes"
"context"
"context"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
@ -21,6 +20,7 @@ import (
"tailscale.com/tstest"
"tailscale.com/tstest"
"tailscale.com/tstime"
"tailscale.com/tstime"
"tailscale.com/types/key"
"tailscale.com/types/key"
"tailscale.com/types/logger"
"tailscale.com/types/netmap"
"tailscale.com/types/netmap"
"tailscale.com/types/ptr"
"tailscale.com/types/ptr"
"tailscale.com/util/mak"
"tailscale.com/util/mak"
@ -637,7 +637,7 @@ func TestDeltaDERPMap(t *testing.T) {
for stepi , s := range tt . steps {
for stepi , s := range tt . steps {
nm := ms . netmapForResponse ( & tailcfg . MapResponse { DERPMap : s . got } )
nm := ms . netmapForResponse ( & tailcfg . MapResponse { DERPMap : s . got } )
if ! reflect . DeepEqual ( nm . DERPMap , s . want ) {
if ! reflect . DeepEqual ( nm . DERPMap , s . want ) {
t . Errorf ( "unexpected result at step index %v; got: %s" , stepi , must. Get ( json . Marshal ( nm . DERPMap ) ) )
t . Errorf ( "unexpected result at step index %v; got: %s" , stepi , logger. AsJSON ( nm . DERPMap ) )
}
}
}
}
} )
} )
@ -740,17 +740,15 @@ func TestPeerChangeDiff(t *testing.T) {
pc , ok := peerChangeDiff ( tt . a . View ( ) , tt . b )
pc , ok := peerChangeDiff ( tt . a . View ( ) , tt . b )
if tt . wantEqual {
if tt . wantEqual {
if ! ok || pc != nil {
if ! ok || pc != nil {
t . Errorf ( "got (%p, %v); want (nil, true); pc=%v" , pc , ok , must. Get ( json . Marshal ( pc ) ) )
t . Errorf ( "got (%p, %v); want (nil, true); pc=%v" , pc , ok , logger. AsJSON ( pc ) )
}
}
return
return
}
}
if ( pc != nil ) != ok {
if ( pc != nil ) != ok {
t . Fatalf ( "inconsistent ok=%v, pc=%p" , ok , pc )
t . Fatalf ( "inconsistent ok=%v, pc=%p" , ok , pc )
}
}
gotj := must . Get ( json . Marshal ( pc ) )
if ! reflect . DeepEqual ( pc , tt . want ) {
wantj := must . Get ( json . Marshal ( tt . want ) )
t . Errorf ( "mismatch\n got: %v\nwant: %v\n" , logger . AsJSON ( pc ) , logger . AsJSON ( tt . want ) )
if ! bytes . Equal ( gotj , wantj ) {
t . Errorf ( "mismatch\n got: %s\nwant: %s\n" , gotj , wantj )
}
}
} )
} )
}
}
@ -762,7 +760,7 @@ func TestPeerChangeDiffAllocs(t *testing.T) {
n := testing . AllocsPerRun ( 10000 , func ( ) {
n := testing . AllocsPerRun ( 10000 , func ( ) {
diff , ok := peerChangeDiff ( a . View ( ) , b )
diff , ok := peerChangeDiff ( a . View ( ) , b )
if ! ok || diff != nil {
if ! ok || diff != nil {
t . Fatalf ( "unexpected result: (%s, %v)" , must. Get ( json . Marshal ( diff ) ) , ok )
t . Fatalf ( "unexpected result: (%s, %v)" , logger. AsJSON ( diff ) , ok )
}
}
} )
} )
if n != 0 {
if n != 0 {