mirror of
https://github.com/libp2p/go-libp2p-core.git
synced 2025-04-28 17:10:14 +08:00
Add test for panic on unknown cipher type
This commit is contained in:
parent
58281f5c6d
commit
47983a3ab5
@ -145,3 +145,23 @@ func (pk testkey) Raw() ([]byte, error) {
|
||||
func (pk testkey) Equals(k Key) bool {
|
||||
return KeyEqual(pk, k)
|
||||
}
|
||||
|
||||
func TestPanicOnUnknownCipherType(t *testing.T) {
|
||||
passed := false
|
||||
defer func() {
|
||||
if !passed {
|
||||
t.Fatal("expected known cipher and hash to succeed")
|
||||
}
|
||||
err := recover()
|
||||
errStr, ok := err.(string)
|
||||
if !ok {
|
||||
t.Fatal("expected string in panic")
|
||||
}
|
||||
if errStr != "Unrecognized cipher, programmer error?" {
|
||||
t.Fatal("expected \"Unrecognized cipher, programmer error?\"")
|
||||
}
|
||||
}()
|
||||
KeyStretcher("AES-256", "SHA1", []byte("foo"))
|
||||
passed = true
|
||||
KeyStretcher("Fooba", "SHA1", []byte("foo"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user