MCPcopy
hub / github.com/syncthing/syncthing / TestShortIDCheck

Function TestShortIDCheck

lib/syncthing/syncthing_test.go:33–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestShortIDCheck(t *testing.T) {
34 cfg := config.Wrap(tempCfgFilename(t), config.Configuration{
35 Devices: []config.DeviceConfiguration{
36 {DeviceID: protocol.DeviceID{8, 16, 24, 32, 40, 48, 56, 0, 0}},
37 {DeviceID: protocol.DeviceID{8, 16, 24, 32, 40, 48, 56, 1, 1}}, // first 56 bits same, differ in the first 64 bits
38 },
39 }, protocol.LocalDeviceID, events.NoopLogger)
40 defer os.Remove(cfg.ConfigPath())
41
42 if err := checkShortIDs(cfg); err != nil {
43 t.Error("Unexpected error:", err)
44 }
45
46 cfg = config.Wrap("/tmp/test", config.Configuration{
47 Devices: []config.DeviceConfiguration{
48 {DeviceID: protocol.DeviceID{8, 16, 24, 32, 40, 48, 56, 64, 0}},
49 {DeviceID: protocol.DeviceID{8, 16, 24, 32, 40, 48, 56, 64, 1}}, // first 64 bits same
50 },
51 }, protocol.LocalDeviceID, events.NoopLogger)
52
53 if err := checkShortIDs(cfg); err == nil {
54 t.Error("Should have gotten an error")
55 }
56}
57
58func TestStartupFail(t *testing.T) {
59 cert, err := tlsutil.NewCertificateInMemory("syncthing", 365)

Callers

nothing calls this directly

Calls 6

WrapFunction · 0.92
tempCfgFilenameFunction · 0.85
checkShortIDsFunction · 0.85
RemoveMethod · 0.65
ConfigPathMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected