mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-04 19:45:14 -04:00
Admits possible errors on Encode
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user