Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ainghazal committed Apr 15, 2024
1 parent 7c2afc4 commit 0d92753
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions internal/model/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package model

import "fmt"

// TestLogger is a logger that can be used whenever a test needs a logger to be passed around.
type TestLogger struct {
Lines []string
}
Expand All @@ -10,21 +11,32 @@ func (tl *TestLogger) append(msg string) {
tl.Lines = append(tl.Lines, msg)
}

// Debug implements model.Logger
func (tl *TestLogger) Debug(msg string) {
tl.append(msg)
}

// Debugf implements model.Logger
func (tl *TestLogger) Debugf(format string, v ...any) {
tl.append(fmt.Sprintf(format, v...))
}

// Info implements model.Logger
func (tl *TestLogger) Info(msg string) {
tl.append(msg)
}

// Infof implements model.Logger
func (tl *TestLogger) Infof(format string, v ...any) {
tl.append(fmt.Sprintf(format, v...))
}

// Warn implements model.Logger
func (tl *TestLogger) Warn(msg string) {
tl.append(msg)
}

// Warnf implements model.Logger
func (tl *TestLogger) Warnf(format string, v ...any) {
tl.append(fmt.Sprintf(format, v...))
}
Expand Down
6 changes: 3 additions & 3 deletions internal/session/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (m *Manager) IsRemoteSessionIDSet() bool {
return !m.remoteSessionID.IsNone()
}

// NewACKForPacket creates a new ACK for the given packet IDs.
// NewACKForPacketIDs creates a new ACK for the given packet IDs.
func (m *Manager) NewACKForPacketIDs(ids []model.PacketID) (*model.Packet, error) {
defer m.mu.Unlock()
m.mu.Lock()
Expand Down Expand Up @@ -163,9 +163,8 @@ func (m *Manager) NewPacket(opcode model.Opcode, payload []byte) (*model.Packet,
pid, err := func() (model.PacketID, error) {
if opcode.IsControl() {
return m.localControlPacketIDLocked()
} else {
return m.localDataPacketIDLocked()
}
return m.localDataPacketIDLocked()
}()
if err != nil {
return nil, err
Expand Down Expand Up @@ -264,6 +263,7 @@ func (m *Manager) SetRemoteSessionID(remoteSessionID model.SessionID) {
m.remoteSessionID = optional.Some(remoteSessionID)
}

// CurrentKeyID returns the key ID currently in use.
func (m *Manager) CurrentKeyID() uint8 {
defer m.mu.Unlock()
m.mu.Lock()
Expand Down

0 comments on commit 0d92753

Please sign in to comment.