Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-core
Commits
47983a3a
Commit
47983a3a
authored
Aug 06, 2019
by
Cole Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for panic on unknown cipher type
parent
58281f5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
crypto/key_test.go
crypto/key_test.go
+20
-0
No files found.
crypto/key_test.go
View file @
47983a3a
...
@@ -145,3 +145,23 @@ func (pk testkey) Raw() ([]byte, error) {
...
@@ -145,3 +145,23 @@ func (pk testkey) Raw() ([]byte, error) {
func
(
pk
testkey
)
Equals
(
k
Key
)
bool
{
func
(
pk
testkey
)
Equals
(
k
Key
)
bool
{
return
KeyEqual
(
pk
,
k
)
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"
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment