New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
secrets: improve tests on malformed message #2377
Conversation
secrets/drivertest/drivertest.go
Outdated
}, | ||
{ | ||
name: "missing second byte", | ||
malformed: append(encryptedMsg[:1], encryptedMsg[2:]...), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the byte for the rest of the test, though. Each of these slices should operate on a copy of encryptedMsg
. The most concise way I can think of to do the copy is by creating a small helper function above:
encryptedMsg, err := keeper.Encrypt(ctx, msg)
if err != nil {
t.Fatal(err)
}
copyEncryptedMsg := func() []byte {
return append([]byte(nil), encryptedMsg...)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
secrets/drivertest/drivertest.go
Outdated
}, | ||
{ | ||
name: "missing second byte", | ||
malformed: append(encryptedMsg[:1], encryptedMsg[2:]...), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Fixes #1692