MCPcopy
hub / github.com/hashicorp/memberlist / TestCreate_keyringAndSecretKey

Function TestCreate_keyringAndSecretKey

memberlist_test.go:295–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

293}
294
295func TestCreate_keyringAndSecretKey(t *testing.T) {
296 c := DefaultLANConfig()
297 c.BindAddr = getBindAddr().String()
298
299 keyring, err := NewKeyring(nil, make([]byte, 16))
300 require.NoError(t, err)
301 c.Keyring = keyring
302 c.SecretKey = []byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
303
304 m, err := Create(c)
305 require.NoError(t, err)
306 defer func() {
307 if err := m.Shutdown(); err != nil {
308 t.Fatal(err)
309 }
310 }()
311
312 if !m.config.EncryptionEnabled() {
313 t.Fatalf("Expected encryption to be enabled")
314 }
315
316 ringKeys := c.Keyring.GetKeys()
317 if !bytes.Equal(c.SecretKey, ringKeys[0]) {
318 t.Fatalf("Unexpected primary key %v", ringKeys[0])
319 }
320}
321
322func TestCreate_invalidLoggerSettings(t *testing.T) {
323 c := DefaultLANConfig()

Callers

nothing calls this directly

Calls 10

DefaultLANConfigFunction · 0.85
getBindAddrFunction · 0.85
NewKeyringFunction · 0.85
CreateFunction · 0.85
FatalMethod · 0.80
EncryptionEnabledMethod · 0.80
FatalfMethod · 0.80
GetKeysMethod · 0.80
ShutdownMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…