Admits possible errors on Encode

This commit is contained in:
riccardom
2026-07-21 13:01:45 +02:00
parent ef6e89d4d6
commit 3efab33980
2 changed files with 6 additions and 4 deletions

View File

@@ -82,9 +82,10 @@ func (m *AnswerMsg) Encode() ([]byte, error) {
return frame(MsgAnswer, m.ExchangeID, m.KEMAnswer), nil
}
// Encode serialises the confirm with its framed header.
func (m *ConfirmMsg) Encode() []byte {
return frame(MsgConfirm, m.ExchangeID, nil)
// Encode serialises the confirm with its framed header. It returns an error only
// for signature uniformity with the other messages; it never actually fails.
func (m *ConfirmMsg) Encode() ([]byte, error) {
return frame(MsgConfirm, m.ExchangeID, nil), nil
}
// Decode parses a framed message into one of *OfferMsg / *AnswerMsg / *ConfirmMsg.

View File

@@ -29,7 +29,8 @@ func TestMessageRoundTrip(t *testing.T) {
require.Equal(t, MsgAnswer, typ)
require.Equal(t, answer, decoded.(*AnswerMsg).KEMAnswer)
confBytes := (&ConfirmMsg{ExchangeID: id}).Encode()
confBytes, err := (&ConfirmMsg{ExchangeID: id}).Encode()
require.NoError(t, err)
typ, decoded, err = Decode(confBytes)
require.NoError(t, err)
require.Equal(t, MsgConfirm, typ)